PR: MPEAR-17

Submitted by: Charles Crouch
Added support to set the description in the generated application.xml

git-svn-id: https://svn.apache.org/repos/asf/maven/maven-1/plugins/trunk@388486 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
aheritier 2006-03-24 11:01:54 +00:00
parent 2a139378ae
commit 837fcaa52f
5 changed files with 170 additions and 248 deletions

View File

@ -16,48 +16,28 @@
* limitations under the License.
*/
-->
<project
xmlns:j="jelly:core"
xmlns:ant="jelly:ant"
xmlns:artifact="artifact"
xmlns:license="license"
xmlns:maven="jelly:maven"
xmlns:util="jelly:util"
xmlns:x="jelly:xml"
xmlns:define="jelly:define"
xmlns:ear="ear"
>
<project xmlns:j="jelly:core" xmlns:ant="jelly:ant" xmlns:artifact="artifact" xmlns:license="license" xmlns:maven="jelly:maven" xmlns:util="jelly:util" xmlns:x="jelly:xml" xmlns:define="jelly:define" xmlns:ear="ear">
<!--==================================================================-->
<!-- Default goal : Builds a ear file -->
<!--==================================================================-->
<goal name="ear" prereqs="ear:ear" description="Build an ear file"/>
<!--==================================================================-->
<!-- Initializations -->
<!--==================================================================-->
<goal name="ear:init"
description="Initialise filesystem and other resources for an ear">
<goal name="ear:init" description="Initialise filesystem and other resources for an ear">
</goal>
<!--==================================================================-->
<!-- Builds an ear file -->
<!--==================================================================-->
<goal name="ear:ear" prereqs="ear:init" description="Build an ear file">
<!-- maven.ear.src and maven.war.resources cannot have the same value -->
<j:if test="${context.getVariable('maven.ear.src') == context.getVariable('maven.ear.resources')}">
<ant:fail>Properties maven.ear.src and maven.ear.resources cannot have the same value</ant:fail>
</j:if>
<ant:mkdir dir="${maven.build.dir}" />
<ant:mkdir dir="${maven.build.dir}"/>
<j:set var="finalAppxml" value="${maven.ear.descriptordir}/application.xml"/>
<j:set var="isGenerateAppXML"
value="${context.getVariable('maven.ear.appxml.generate')}"/>
<j:set var="isGenerateAppXML" value="${context.getVariable('maven.ear.appxml.generate')}"/>
<!-- make sure that target directory exists -->
<ant:mkdir dir="${maven.ear.descriptordir}"/>
<j:choose>
@ -70,37 +50,24 @@
</util:available>
</j:otherwise>
</j:choose>
<ant:echo>Building EAR ${maven.ear.final.name} with appxml "${finalAppxml}"</ant:echo>
<ant:available property="maven.ear.manifest.available"
file="${maven.ear.manifest}"/>
<ant:ear destfile="${maven.build.dir}/${maven.ear.final.name}"
appxml="${finalAppxml}">
<ant:available property="maven.ear.manifest.available" file="${maven.ear.manifest}"/>
<ant:ear destfile="${maven.build.dir}/${maven.ear.final.name}" appxml="${finalAppxml}">
<!-- include files from maven.ear.src if available -->
<util:available file="${maven.ear.src}">
<fileset dir="${maven.ear.src}" casesensitive="false"
excludes="**/META-INF/application.xml"/>
<fileset dir="${maven.ear.src}" casesensitive="false" excludes="**/META-INF/application.xml"/>
</util:available>
<!-- include marked dependencies -->
<j:set var="tmpDependenciesDir" value="${maven.build.dir}/tmpEarDeps"/>
<j:forEach var="lib" items="${pom.artifacts}">
<j:set var="dep" value="${lib.dependency}"/>
<j:if test="${dep.getProperty('ear.bundle')=='true' || dep.getProperty('ear.module')=='true'}">
<!--
We know that this dep "wants" to be bundled. Now we need to decide how it is copied into the
EAR
-->
<j:set var="originalPath" value="${lib.file.name}"/>
<ear:setPath lib="${lib}" var="bundledPath"/>
<j:choose>
<j:when test="${originalPath.equals(bundledPath)}">
<ant:fileset dir="${lib.file.parent}">
@ -112,74 +79,52 @@
<ant:copy file="${lib.file.parent}/${originalPath}" tofile="${tmpDependenciesDir}/${bundledPath}"/>
</j:otherwise>
</j:choose>
</j:if>
</j:forEach>
<!-- bundle all dependencies that were copied to a temporary dir -->
<util:available file="${tmpDependenciesDir}">
<ant:fileset dir="${tmpDependenciesDir}"/>
</util:available>
<!-- include license -->
<j:set var="licenseFileName"><license:fileName/></j:set>
<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.ear.manifest.available}">
<ant:setProperty name="manifest" value="${maven.ear.manifest}" />
<ant:setProperty name="manifest" value="${maven.ear.manifest}"/>
</j:if>
<!-- standard manifest entries -->
<ant:manifest>
<ant:attribute name="Built-By" value="${user.name}" />
<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: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>
</ant:manifest>
<j:if test="${!pom.build.resources.isEmpty()}">
<mkdir dir="${maven.ear.resources}"/>
<maven:copy-resources resources="${pom.build.resources}" todir="${maven.ear.resources}"/>
<fileset dir="${maven.ear.resources}" />
<fileset dir="${maven.ear.resources}"/>
</j:if>
</ant:ear>
<!-- delete temporary directory -->
<util:available file="${tmpDependenciesDir}">
<ant:delete dir="${tmpDependenciesDir}"/>
</util:available>
</goal>
<!--==================================================================-->
<!-- Creates ear descriptor - application.xml file -->
<!--==================================================================-->
<goal name="ear:generate-ear-descriptor" description="Generates the ear descriptor">
<ant:echo>Generating appxml file:"${finalAppxml} version ${maven.ear.appxml.version} encoding: ${maven.ear.appxml.encoding}"</ant:echo>
<j:file name="${finalAppxml}"
outputMode="xml"
prettyPrint="true"
encoding="${maven.ear.appxml.encoding}"
>
<j:file name="${finalAppxml}" outputMode="xml" prettyPrint="true" encoding="${maven.ear.appxml.encoding}">
<j:switch on="${maven.ear.appxml.version}">
<j:case value="1.3">
<x:doctype name="application" publicId="-//Sun Microsystems, Inc.//DTD J2EE Application 1.3//EN" systemId="http://java.sun.com/dtd/application_1_3.dtd"/>
@ -188,9 +133,12 @@
<x:doctype name="application" publicId="-//Sun Microsystems, Inc.//DTD J2EE Application 1.2//EN" systemId="http://java.sun.com/j2ee/dtds/application_1_2.dtd"/>
</j:default>
</j:switch>
<x:element name="application">
<x:element name="display-name">${maven.ear.displayname}</x:element>
<j:set var="applicationDescription" value="${maven.ear.appxml.description}"/>
<j:if test="${!empty(applicationDescription)}">
<x:element name="description">${maven.ear.appxml.description}</x:element>
</j:if>
<j:forEach var="lib" items="${pom.artifacts}">
<j:set var="dep" value="${lib.dependency}"/>
<ear:setPath lib="${lib}" var="bundledPath"/>
@ -243,70 +191,34 @@
<x:element name="role-name">${role.trim()}</x:element>
</x:element>
</j:forEach>
</j:if >
</j:if>
</x:element>
</j:file>
</goal>
<!--==================================================================-->
<!-- Install the ear in the local repository -->
<!--==================================================================-->
<goal name="ear:install"
prereqs="ear:ear"
description="Install the ear in the local repository">
<artifact:install
artifact="${maven.build.dir}/${maven.ear.final.name}"
type="ear"
project="${pom}"/>
<goal name="ear:install" prereqs="ear:ear" description="Install the ear in the local repository">
<artifact:install artifact="${maven.build.dir}/${maven.ear.final.name}" type="ear" project="${pom}"/>
</goal>
<!--==================================================================-->
<!-- Install the snapshot version of the ear in the local repository -->
<!--==================================================================-->
<goal name="ear:install-snapshot"
prereqs="ear:ear"
description="Install the snapshot version of the ear in the local repository">
<artifact:install-snapshot
artifact="${maven.build.dir}/${maven.ear.final.name}"
type="ear"
project="${pom}"/>
<goal name="ear:install-snapshot" prereqs="ear:ear" description="Install the snapshot version of the ear in the local repository">
<artifact:install-snapshot artifact="${maven.build.dir}/${maven.ear.final.name}" type="ear" project="${pom}"/>
</goal>
<!--==================================================================-->
<!-- Deploys the ear to the remote repository -->
<!--==================================================================-->
<goal name="ear:deploy"
prereqs="ear:ear"
description="Deploys the ear to the remote repository">
<artifact:deploy
artifact="${maven.build.dir}/${maven.ear.final.name}"
type="ear"
project="${pom}"/>
<goal name="ear:deploy" prereqs="ear:ear" description="Deploys the ear to the remote repository">
<artifact:deploy artifact="${maven.build.dir}/${maven.ear.final.name}" type="ear" project="${pom}"/>
</goal>
<!--==================================================================-->
<!-- Deploys the snapshot version of the ear to the remote repository -->
<!--==================================================================-->
<goal name="ear:deploy-snapshot"
prereqs="ear:ear"
description="Deploys the snapshot version of the ear to remote repository">
<artifact:deploy-snapshot
artifact="${maven.build.dir}/${maven.ear.final.name}"
type="ear"
project="${pom}"/>
<goal name="ear:deploy-snapshot" prereqs="ear:ear" description="Deploys the snapshot version of the ear to remote repository">
<artifact:deploy-snapshot artifact="${maven.build.dir}/${maven.ear.final.name}" type="ear" project="${pom}"/>
</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 -->
@ -315,11 +227,7 @@
<goal name="ear:load">
<echo>DEPRECATED: do not use ear:load, there is no need</echo>
</goal>
<define:taglib uri="ear">
<!--
Sets the relative path of a dependency in the EAR file
parameters:
@ -347,13 +255,9 @@
</j:choose>
${context.setVariable(var,'parent',thePath)}
</define:tag>
<define:tag name="resolver">
<j:new var="resolver" className="org.apache.maven.ear.j2ee.J2EEEntityResolver" />
<j:set var="${var}" value="${resolver}" scope="parent" />
<j:new var="resolver" className="org.apache.maven.ear.j2ee.J2EEEntityResolver"/>
<j:set var="${var}" value="${resolver}" scope="parent"/>
</define:tag>
</define:taglib>
</project>

View File

@ -25,15 +25,17 @@ maven.ear.src=${maven.src.dir}/application
# Location of xml configs and manifest files
maven.ear.descriptordir=${maven.build.dir}
maven.ear.appxml=${maven.ear.src}/META-INF/application.xml
maven.ear.manifest=${maven.ear.src}/META-INF/MANIFEST.MF
maven.ear.appxml.generate=false
maven.ear.displayname=${pom.artifactId}
maven.ear.appxml.version=1.3
maven.ear.resources=${maven.build.dir}/ear
maven.ear.appxml.encoding=UTF-8
# Name of generated EAR file
maven.ear.final.name=${maven.final.name}.ear
maven.ear.appxml=${maven.ear.src}/META-INF/application.xml
maven.ear.appxml.generate=false
maven.ear.appxml.version=1.3
maven.ear.appxml.encoding=UTF-8
# Security role (a comma separated list)
# maven.ear.appxml.securityRoles = role1, role2
# Description
maven.ear.appxml.description=${pom.description}

View File

@ -56,6 +56,9 @@
value="${firstJavaModule}"
msg="commons collections was not the first java module"/>
<x:set var="description" select="string($applicationDoc/application/description)"/>
<assert:assertEquals expected="${pom.description.trim()}" value="${description.trim()}"/>
<!-- check for resources -->
<assert:assertFileExists file="${unzipDir}/resource.txt"/>

View File

@ -23,6 +23,9 @@
<author email="nathan.coast@blueyonder.co.uk">Nathan Coast</author>
</properties>
<body>
<release version="1.9-SNAPSHOT" date="In SVN">
<action dev="aheritier" type="add" issue="MPEAR-17">Added support to set the description and the security roles in the generated application.xml.</action>
</release>
<release version="1.8" date="2006-03-08">
<action dev="snicoll" type="fix" issue="MPEAR-33">Added support of JbossNet archive in application.xml generation.</action>
<action dev="aheritier" type="update" issue="MAVEN-1712">Update dependencies to match ones in maven 1.1 core and to unify them between plugins. The following dependencies are updated :

View File

@ -45,6 +45,47 @@
${maven.ear.src}/META-INF/MANIFEST.MF
</td>
</tr>
<tr>
<td>maven.ear.displayname</td>
<td>Yes</td>
<td>
Display name of the application to be used
when <code>application.xml</code> file is autogenerated
</td>
<td>
${pom.artifactId}
</td>
</tr>
<tr>
<td>maven.ear.resources</td>
<td>Yes</td>
<td>
Directory that resources are copied to during the build.<b>NOTE:</b> cannot have the same value of ${maven.ear.src}!
</td>
<td>
${maven.build.dir}/ear
</td>
</tr>
<tr>
<td>maven.ear.src</td>
<td>Yes</td>
<td>
Single directory for extra files to include in the EAR. <b>NOTE:</b> cannot have the same value of ${maven.ear.resources}!
</td>
<td>
${maven.src.dir}/application
</td>
</tr>
<tr>
<td>maven.ear.descriptordir</td>
<td>Yes</td>
<td>
Directory where the <code>application.xml</code> file will be auto-generated (only if <code>maven.ear.appxml.generate</code> is true).
</td>
<td>
${maven.build.dir}
</td>
</tr>
<tr>
<td>maven.ear.appxml</td>
<td>Yes</td>
@ -77,37 +118,6 @@
1.3
</td>
</tr>
<tr>
<td>maven.ear.displayname</td>
<td>Yes</td>
<td>
Display name of the application to be used
when <code>application.xml</code> file is autogenerated
</td>
<td>
${pom.artifactId}
</td>
</tr>
<tr>
<td>maven.ear.resources</td>
<td>Yes</td>
<td>
Directory that resources are copied to during the build.<b>NOTE:</b> cannot have the same value of ${maven.ear.src}!
</td>
<td>
${maven.build.dir}/ear
</td>
</tr>
<tr>
<td>maven.ear.src</td>
<td>Yes</td>
<td>
Single directory for extra files to include in the EAR. <b>NOTE:</b> cannot have the same value of ${maven.ear.resources}!
</td>
<td>
${maven.src.dir}/application
</td>
</tr>
<tr>
<td>maven.ear.appxml.encoding</td>
<td>Yes</td>
@ -119,13 +129,13 @@
</td>
</tr>
<tr>
<td>maven.ear.descriptordir</td>
<td>maven.ear.appxml.description</td>
<td>Yes</td>
<td>
Directory where the <code>application.xml</code> file will be auto-generated (only if <code>maven.ear.appxml.generate</code> is true).
The description element inserted in the descriptor.
</td>
<td>
${maven.build.dir}
${pom.description}
</td>
</tr>
<tr>