Author: snicoll Date: Wed Jun 7 11:22:28 2006 New Revision: 412476 URL: http://svn.apache.org/viewvc?rev=412476&view=rev Log: MPWAR-47: Specification and Implementation attributes of the manifest are now defined as main attributes.
Modified: maven/maven-1/plugins/trunk/war/plugin.jelly maven/maven-1/plugins/trunk/war/project.xml maven/maven-1/plugins/trunk/war/xdocs/changes.xml Modified: maven/maven-1/plugins/trunk/war/plugin.jelly URL: http://svn.apache.org/viewvc/maven/maven-1/plugins/trunk/war/plugin.jelly?rev=412476&r1=412475&r2=412476&view=diff ============================================================================== --- maven/maven-1/plugins/trunk/war/plugin.jelly (original) +++ maven/maven-1/plugins/trunk/war/plugin.jelly Wed Jun 7 11:22:28 2006 @@ -43,10 +43,16 @@ <!-- 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 --> + <!-- 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}"/> @@ -56,6 +62,12 @@ <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}" @@ -73,25 +85,48 @@ </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> - <ant:attribute name="Built-By" value="${user.name}" /> - <ant:section name="${pom.package}"> - <ant:attribute name="Specification-Title" value="${pom.artifactId}" /> - <ant:attribute name="Specification-Version" - value="${pom.currentVersion}" /> - <ant:attribute name="Specification-Vendor" - value="${pom.organization.name}" /> - <ant:attribute name="Implementation-Title" - value="${pom.package}" /> - <ant:attribute name="Implementation-Version" - value="${pom.currentVersion}" /> - <ant:attribute name="Implementation-Vendor" - value="${pom.organization.name}" /> - </ant:section> + <!-- 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> + + <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:manifest> </ant:jar> Modified: maven/maven-1/plugins/trunk/war/project.xml URL: http://svn.apache.org/viewvc/maven/maven-1/plugins/trunk/war/project.xml?rev=412476&r1=412475&r2=412476&view=diff ============================================================================== --- maven/maven-1/plugins/trunk/war/project.xml (original) +++ maven/maven-1/plugins/trunk/war/project.xml Wed Jun 7 11:22:28 2006 @@ -85,5 +85,15 @@ <timezone>-3</timezone> </developer> </developers> - <dependencies/> + <dependencies> + <dependency> + <groupId>commons-lang</groupId> + <artifactId>commons-lang</artifactId> + <version>2.0</version> + <url>http://jakarta.apache.org/commons/lang/</url> + <properties> + <comment>This library is already loaded by maven's core. Be careful to use the same version number as in the core.</comment> + </properties> + </dependency> + </dependencies> </project> Modified: maven/maven-1/plugins/trunk/war/xdocs/changes.xml URL: http://svn.apache.org/viewvc/maven/maven-1/plugins/trunk/war/xdocs/changes.xml?rev=412476&r1=412475&r2=412476&view=diff ============================================================================== --- maven/maven-1/plugins/trunk/war/xdocs/changes.xml (original) +++ maven/maven-1/plugins/trunk/war/xdocs/changes.xml Wed Jun 7 11:22:28 2006 @@ -25,6 +25,7 @@ </properties> <body> <release version="1.6.2-SNAPSHOT" date="in SVN"> + <action dev="snicoll" type="fix" issue="MPWAR-47">Specification and Implementation attributes of the manifest are now defined as main attributes.</action> <action dev="snicoll" type="add" issue="MPWAR-43">Aded the ability to customize the Class-Path entry of the manifest</action> <action dev="snicoll" type="update" issue="MPWAR-49">Added property <code>maven.war.resources.overwrite</code> to control is resources overwrites the ones in the generated webapp directory.</action> <action dev="snicoll" type="update" issue="MPWAR-37" due-to="Troy Poppe">Added ability to expand properties when copying war resources.</action>