git-svn-id: https://svn.apache.org/repos/asf/maven/maven-1/plugins/trunk@534128 13f79535-47bb-0310-9956-ffa450edef68
349 lines
14 KiB
XML
349 lines
14 KiB
XML
<?xml version="1.0"?>
|
|
<!--
|
|
/*
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
* contributor license agreements. See the NOTICE file distributed with
|
|
* this work for additional information regarding copyright ownership.
|
|
* The ASF licenses this file to You under the Apache License, Version 2.0
|
|
* (the "License"); you may not use this file except in compliance with
|
|
* the License. You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
-->
|
|
|
|
|
|
<project xmlns:j="jelly:core"
|
|
xmlns:license="license"
|
|
xmlns:util="jelly:util"
|
|
xmlns:ant="jelly:ant"
|
|
xmlns:maven="jelly:maven"
|
|
xmlns:artifact="artifact">
|
|
|
|
<!--==================================================================-->
|
|
<!-- Default goal : Builds a war file -->
|
|
<!--==================================================================-->
|
|
<goal name="war" prereqs="war:war" description="Build a war file"/>
|
|
|
|
<!--==================================================================-->
|
|
<!-- Initializations -->
|
|
<!--==================================================================-->
|
|
<goal name="war:init">
|
|
|
|
<ant:available property="webSourcesPresent" type="dir"
|
|
file="${maven.war.src}"/>
|
|
|
|
</goal>
|
|
|
|
<!--==================================================================-->
|
|
<!-- Builds a war file -->
|
|
<!--==================================================================-->
|
|
<goal name="war:war" prereqs="war:webapp" description="Build a war file">
|
|
|
|
<j:choose>
|
|
<j:when test="${pom.currentVersion == null}">
|
|
<ant:fail>You must define currentVersion in your POM.</ant:fail>
|
|
</j:when>
|
|
</j:choose>
|
|
|
|
<ant:echo>Building WAR ${pom.artifactId}</ant:echo>
|
|
|
|
<!-- build dependency list -->
|
|
<j:forEach var="dep" items="${pom.dependencies}">
|
|
<j:if test="${dep.getProperty('war.manifest.classpath')=='true'}">
|
|
<j:set var="maven.war.classpath" value="${maven.war.classpath} ${dep.artifact}"/>
|
|
</j:if>
|
|
</j:forEach>
|
|
|
|
<ant:available property="maven.war.manifest.available"
|
|
file="${maven.war.manifest}"/>
|
|
|
|
<j:set var="specificationTitle" value="${pom.shortDescription.trim()}"/>
|
|
<j:if test="${specificationTitle.length() gt 49}">
|
|
<ant:echo>Warning: shortDescription is greater than 49 characters - trimming for specification title.</ant:echo>
|
|
<j:set var="specificationTitle" value="${specificationTitle.substring(0,46)}..."/>
|
|
</j:if>
|
|
|
|
<ant:mkdir dir="${maven.war.build.dir}" />
|
|
<ant:jar
|
|
destfile="${maven.war.build.dir}/${maven.war.final.name}"
|
|
basedir="${maven.war.webapp.dir}"
|
|
index="${maven.war.index}">
|
|
|
|
<j:set var="licenseFileName"><license:fileName/></j:set>
|
|
<util:file name="${licenseFileName}" var="licenseFile"/>
|
|
<ant:metainf dir="${licenseFile.canonicalFile.parent}">
|
|
<ant:include name="${licenseFile.canonicalFile.name}"/>
|
|
</ant:metainf>
|
|
|
|
<j:if test="${maven.war.manifest.available}">
|
|
<ant:setProperty name="manifest" value="${maven.war.manifest}" />
|
|
</j:if>
|
|
|
|
<ant:manifest>
|
|
<ant:attribute name="Built-By" value="${user.name}"/>
|
|
|
|
<j:set var="mavenVersion" value="${maven.application.version}"/>
|
|
<j:if test="${mavenVersion != null}">
|
|
<ant:attribute name="Maven-Version" value="${mavenVersion}"/>
|
|
</j:if>
|
|
|
|
<j:set var="classPath" value="${maven.war.classpath}"/>
|
|
<j:if test="${!empty(classPath)}">
|
|
<ant:attribute name="Class-Path" value="${maven.war.classpath}"/>
|
|
</j:if>
|
|
|
|
<!-- Remove SNAPSHOT -->
|
|
<j:choose>
|
|
<j:when test="${pom.currentVersion.endsWith('-SNAPSHOT')}">
|
|
<j:invokeStatic className="org.apache.commons.lang.StringUtils" method="substringBeforeLast" var="pomCurrentVersion">
|
|
<j:arg value="${pom.currentVersion}" type="java.lang.String"/>
|
|
<j:arg value="-SNAPSHOT" type="java.lang.String"/>
|
|
</j:invokeStatic>
|
|
</j:when>
|
|
<j:otherwise>
|
|
<j:set var="pomCurrentVersion" value="${pom.currentVersion}"/>
|
|
</j:otherwise>
|
|
</j:choose>
|
|
|
|
<util:tokenize var="versionItems" delim="." trim="true">${pomCurrentVersion}</util:tokenize>
|
|
<j:if test="${size(versionItems) > 0}">
|
|
<j:set var="specificationVersion" value="${versionItems[0]}" />
|
|
</j:if>
|
|
<j:if test="${size(versionItems) > 1}">
|
|
<j:set var="specificationVersion" value="${specificationVersion}.${versionItems[1]}" />
|
|
</j:if>
|
|
<j:if test="${size(versionItems) > 2}">
|
|
<j:set var="specificationVersion" value="${specificationVersion}.${versionItems[2]}" />
|
|
</j:if>
|
|
|
|
<util:replace var="packagePath" oldChar="." newChar="/" value="${pom.package}"/>
|
|
<ant:section name="${packagePath}">
|
|
<ant:attribute name="Extension-name" value="${pom.package}"/>
|
|
<ant:attribute name="Specification-Title" value="${specificationTitle}"/>
|
|
<ant:attribute name="Specification-Vendor" value="${pom.organization.name}"/>
|
|
<ant:attribute name="Specification-Version" value="${specificationVersion}"/>
|
|
<ant:attribute name="Implementation-Title" value="${pom.package}"/>
|
|
<ant:attribute name="Implementation-Vendor" value="${pom.organization.name}"/>
|
|
<ant:attribute name="Implementation-Version" value="${pom.currentVersion}"/>
|
|
</ant:section>
|
|
</ant:manifest>
|
|
|
|
</ant:jar>
|
|
|
|
</goal>
|
|
|
|
<!--==================================================================-->
|
|
<!-- Copies webapp files to target dir -->
|
|
<!--==================================================================-->
|
|
<goal name="war:war-resources" prereqs="war:init"
|
|
description="Copy webapp resources to target directory">
|
|
|
|
<ant:mkdir dir="${maven.war.webapp.dir}"/>
|
|
|
|
<j:set var="webapp.build.webinf" value="${maven.war.webapp.dir}/WEB-INF"/>
|
|
<ant:mkdir dir="${webapp.build.webinf}"/>
|
|
|
|
<j:if test="${webSourcesPresent == 'true'}">
|
|
<ant:copy todir="${maven.war.webapp.dir}" filtering="${maven.war.src.filtering}"
|
|
preservelastmodified="true"
|
|
overwrite="${maven.war.resources.overwrite}">
|
|
<ant:fileset dir="${maven.war.src}">
|
|
<include name="${maven.war.src.includes}"/>
|
|
<exclude name="${maven.war.src.excludes}"/>
|
|
<exclude name="${maven.war.expansion.excludes}"/>
|
|
</ant:fileset>
|
|
<j:if test="${maven.war.property.expansion}" >
|
|
<ant:filterchain>
|
|
<ant:expandproperties/>
|
|
</ant:filterchain>
|
|
</j:if>
|
|
</ant:copy>
|
|
<j:if test="${maven.war.property.expansion}" >
|
|
<ant:copy todir="${maven.war.webapp.dir}" filtering="false"
|
|
preservelastmodified="true"
|
|
overwrite="${maven.war.resources.overwrite}">
|
|
<ant:fileset dir="${maven.war.src}">
|
|
<include name="${maven.war.expansion.excludes}"/>
|
|
</ant:fileset>
|
|
</ant:copy>
|
|
</j:if>
|
|
</j:if>
|
|
|
|
<util:available file="${maven.war.webxml}">
|
|
<ant:copy file="${maven.war.webxml}"
|
|
tofile="${webapp.build.webinf}/web.xml"
|
|
filtering="${maven.war.src.filtering}"
|
|
overwrite="${maven.war.webxml.overwrite}" />
|
|
<j:if test="${maven.war.property.expansion}" >
|
|
<ant:filterchain>
|
|
<ant:expandproperties/>
|
|
</ant:filterchain>
|
|
</j:if>
|
|
</util:available>
|
|
|
|
</goal>
|
|
|
|
<!--==================================================================-->
|
|
<!-- Builds an expanded webapp -->
|
|
<!--==================================================================-->
|
|
<goal name="war:webapp" prereqs="war:war-resources,test:test"
|
|
description="Build a webapp directory">
|
|
|
|
<!-- If maven.test.skip != true, java:compile is attained in test:test -->
|
|
<maven:get var="testsSkipped" plugin="maven-test-plugin" property="maven.test.skip"/>
|
|
<j:if test="${unitTestSourcesPresent != 'true' or testsSkipped == 'true'}">
|
|
<attainGoal name="java:compile"/>
|
|
<attainGoal name="java:jar-resources"/>
|
|
</j:if>
|
|
|
|
<ant:echo>Assembling webapp ${pom.artifactId}</ant:echo>
|
|
|
|
<j:set var="webapp.build.lib" value="${webapp.build.webinf}/lib"/>
|
|
<j:set var="webapp.build.tlds" value="${maven.war.webapp.dir}/${maven.war.tld.dir}"/>
|
|
<j:set var="webapp.build.classes" value="${webapp.build.webinf}/classes"/>
|
|
|
|
<j:forEach var="lib" items="${pom.artifacts}">
|
|
<j:set var="dep" value="${lib.dependency}"/>
|
|
<j:if test="${dep.getProperty('war.bundle')=='true'}">
|
|
<j:choose>
|
|
<j:when test="${dep.type =='jar' or dep.type =='ejb' or dep.type == 'ejb-client'}">
|
|
<ant:mkdir dir="${webapp.build.lib}"/>
|
|
<ant:copy todir="${webapp.build.lib}" file="${lib.path}"/>
|
|
</j:when>
|
|
<j:when test="${dep.type =='tld'}">
|
|
<ant:mkdir dir="${webapp.build.tlds}"/>
|
|
<ant:copy todir="${webapp.build.tlds}" file="${lib.path}"/>
|
|
</j:when>
|
|
</j:choose>
|
|
</j:if>
|
|
<!-- TO BE REMOVED -->
|
|
<j:if test="${dep.getProperty('war.bundle.jar')=='true'}">
|
|
<ant:echo>
|
|
DEPRECATION WARNING:
|
|
Use : war.bundle instead of war.bundle.jar
|
|
</ant:echo>
|
|
<ant:mkdir dir="${webapp.build.lib}"/>
|
|
<ant:copy todir="${webapp.build.lib}" file="${lib.path}"/>
|
|
</j:if>
|
|
<!-- END OF TO BE REMOVED -->
|
|
|
|
<j:set var="targetPath" value="${dep.getProperty('war.target.path')}"/>
|
|
<j:if test="${!empty(targetPath)}">
|
|
<ant:copy todir="${maven.war.webapp.dir}/${targetPath}" file="${lib.path}"/>
|
|
</j:if>
|
|
</j:forEach>
|
|
|
|
<util:available file="${maven.build.dest}">
|
|
<ant:mkdir dir="${webapp.build.classes}"/>
|
|
<ant:copy todir="${webapp.build.classes}">
|
|
<ant:fileset dir="${maven.build.dest}"
|
|
includes="${maven.war.classes.includes}"
|
|
excludes="${maven.war.classes.excludes}">
|
|
</ant:fileset>
|
|
</ant:copy>
|
|
</util:available>
|
|
|
|
</goal>
|
|
|
|
<!--==================================================================-->
|
|
<!-- Install the war in the local repository -->
|
|
<!--==================================================================-->
|
|
<goal name="war:install"
|
|
prereqs="war:war"
|
|
description="Install the war in the local repository">
|
|
|
|
<artifact:install
|
|
artifact="${maven.war.build.dir}/${maven.war.final.name}"
|
|
type="war"
|
|
project="${pom}"/>
|
|
|
|
</goal>
|
|
|
|
<!--==================================================================-->
|
|
<!-- Install the snapshot version of the war in the local repository -->
|
|
<!--==================================================================-->
|
|
<goal name="war:install-snapshot"
|
|
prereqs="war:war"
|
|
description="Install the snapshot version of the war in the local repository">
|
|
|
|
<artifact:install-snapshot
|
|
artifact="${maven.war.build.dir}/${maven.war.final.name}"
|
|
type="war"
|
|
project="${pom}"/>
|
|
|
|
</goal>
|
|
|
|
<!--==================================================================-->
|
|
<!-- Deploys the war to the remote repository -->
|
|
<!--==================================================================-->
|
|
<goal name="war:deploy"
|
|
prereqs="war:war"
|
|
description="Deploys the war to the remote repository">
|
|
|
|
<artifact:deploy
|
|
artifact="${maven.war.build.dir}/${maven.war.final.name}"
|
|
type="war"
|
|
project="${pom}"/>
|
|
|
|
</goal>
|
|
|
|
<!--==================================================================-->
|
|
<!-- Deploys the snapshot of the war to the remote repository -->
|
|
<!--==================================================================-->
|
|
<goal name="war:deploy-snapshot"
|
|
prereqs="war:war"
|
|
description="Deploys the snapshot version of the war to remote repository">
|
|
|
|
<artifact:deploy-snapshot
|
|
artifact="${maven.war.build.dir}/${maven.war.final.name}"
|
|
type="war"
|
|
project="${pom}"/>
|
|
|
|
</goal>
|
|
|
|
|
|
<!--==================================================================-->
|
|
<!-- Clean -->
|
|
<!--==================================================================-->
|
|
<goal name="war:clean"
|
|
prereqs="war:init"
|
|
description="Remove all artifacts created by war plugin">
|
|
|
|
<!-- TODO: delete also snapshot and md5 files -->
|
|
<j:if test="${context.getVariable('maven.war.webapp.dir') != context.getVariable('maven.war.src')}">
|
|
<ant:delete dir="${maven.war.webapp.dir}"/>
|
|
</j:if>
|
|
<ant:delete file="${maven.war.build.dir}/${maven.war.final.name}" quiet="true" failonerror="false"/>
|
|
</goal>
|
|
|
|
<!--==================================================================-->
|
|
<!-- In-place deployment of the web application -->
|
|
<!--==================================================================-->
|
|
<goal name="war:inplace"
|
|
prereqs="war:init"
|
|
description="Deploy a webapp into maven.war.src - in particular setting up WEB-INF/lib and WEB-INF/classes">
|
|
<j:set var="maven.war.webapp.dir" value="${maven.war.src}"/>
|
|
<j:if test="${webSourcesPresent == 'true'}">
|
|
<attainGoal name="war:webapp"/>
|
|
</j:if>
|
|
</goal>
|
|
|
|
<!--==================================================================-->
|
|
<!-- Special no-op goal which can be used by other plugin which need -->
|
|
<!-- to get access to any of this plugin's property. This is -->
|
|
<!-- temporary, until we get explicit plugin dependencies. -->
|
|
<!--==================================================================-->
|
|
<goal name="war:load">
|
|
<echo>DEPRECATED: war:load is deprecated, please use maven:get tags</echo>
|
|
</goal>
|
|
|
|
</project>
|
|
|