- Added auto generation of application.xml file
- Process of bundling artifacts in ear is type senstive now git-svn-id: https://svn.apache.org/repos/asf/maven/maven-1/plugins/trunk@113414 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
0c8d13974e
commit
5878b8d99e
100
ear/plugin.jelly
100
ear/plugin.jelly
@ -4,7 +4,9 @@
|
||||
xmlns:j="jelly:core"
|
||||
xmlns:ant="jelly:ant"
|
||||
xmlns:license="license"
|
||||
xmlns:util="jelly:util">
|
||||
xmlns:util="jelly:util"
|
||||
xmlns:x="jelly:xml"
|
||||
>
|
||||
|
||||
<!--==================================================================-->
|
||||
<!-- Default goal : Builds a ear file -->
|
||||
@ -24,11 +26,18 @@
|
||||
<!--==================================================================-->
|
||||
<goal name="ear:ear" prereqs="ear:init" description="Build an ear file">
|
||||
|
||||
<ant:echo>Building EAR ${maven.final.name} with appxml "${maven.ear.appxml}"</ant:echo>
|
||||
|
||||
<ant:mkdir dir="${maven.build.dir}" />
|
||||
|
||||
|
||||
|
||||
<j:set var="isGenerateAppXML"
|
||||
value="${context.getVariable('maven.ear.appxml.generate')}"/>
|
||||
<j:if test="${isGenerateAppXML == 'true'}">
|
||||
<!-- make sure that target directory exists -->
|
||||
<ant:mkdir dir="${maven.ear.descriptordir}"/>
|
||||
<attainGoal name="ear:generate-ear-descriptor"/>
|
||||
</j:if >
|
||||
|
||||
<ant:echo>Building EAR ${maven.final.name} with appxml "${maven.ear.appxml}"</ant:echo>
|
||||
|
||||
<ant:available property="maven.ear.manifest.available"
|
||||
file="${maven.ear.manifest}"/>
|
||||
|
||||
@ -39,21 +48,26 @@
|
||||
|
||||
<!-- include marked dependencies -->
|
||||
<j:forEach var="dep" items="${pom.dependencies}">
|
||||
<j:if test="${dep.getProperty('ear.bundle.jar')=='true'}">
|
||||
<ant:fileset dir="${maven.repo.local}/${dep.artifactDirectory}/jars/">
|
||||
<ant:include name="${dep.artifact}"/>
|
||||
</ant:fileset>
|
||||
</j:if>
|
||||
<j:if test="${dep.getProperty('ear.bundle.war')=='true'}">
|
||||
<ant:fileset dir="${maven.repo.local}/${dep.artifactDirectory}/wars/">
|
||||
<ant:include name="${dep.artifact}"/>
|
||||
</ant:fileset>
|
||||
</j:if>
|
||||
<j:if test="${dep.getProperty('ear.bundle.ejb')=='true'}">
|
||||
<ant:fileset dir="${maven.repo.local}/${dep.artifactDirectory}/ejbs/">
|
||||
<ant:include name="${dep.artifact}"/>
|
||||
</ant:fileset>
|
||||
</j:if>
|
||||
<j:if test="${dep.getProperty('ear.bundle')=='true'}">
|
||||
<ant:echo>Bundling: ${dep.type}</ant:echo>
|
||||
<j:choose>
|
||||
<j:when test="${dep.type == 'jar'}">
|
||||
<ant:fileset dir="${maven.repo.local}/${dep.artifactDirectory}/jars/">
|
||||
<ant:include name="${dep.artifact}"/>
|
||||
</ant:fileset>
|
||||
</j:when>
|
||||
<j:when test="${dep.type == 'war' }">
|
||||
<ant:fileset dir="${maven.repo.local}/${dep.artifactDirectory}/wars/">
|
||||
<ant:include name="${dep.artifact}"/>
|
||||
</ant:fileset>
|
||||
</j:when>
|
||||
<j:when test="${dep.type == 'ejb' }">
|
||||
<ant:fileset dir="${maven.repo.local}/${dep.artifactDirectory}/ejbs/">
|
||||
<ant:include name="${dep.artifact}"/>
|
||||
</ant:fileset>
|
||||
</j:when>
|
||||
</j:choose>
|
||||
</j:if>
|
||||
</j:forEach>
|
||||
|
||||
<!-- include license -->
|
||||
@ -100,7 +114,51 @@
|
||||
<ant:mkdir dir="${maven.ear.install.dir}"/>
|
||||
<ant:copy file="${maven.build.dir}/${maven.final.name}.ear"
|
||||
tofile="${maven.ear.install.dir}/${maven.final.name}.ear"/>
|
||||
|
||||
|
||||
</goal>
|
||||
|
||||
<!--==================================================================-->
|
||||
<!-- Creates ear descriptor - application.xml file -->
|
||||
<!--==================================================================-->
|
||||
<goal name="ear:generate-ear-descriptor" description="Generates the ear descriptor">
|
||||
|
||||
<ant:echo>Generating appxml file:"${maven.ear.appxml}"</ant:echo>
|
||||
|
||||
<j:file name="${maven.ear.appxml}"
|
||||
outputMode="xml"
|
||||
prettyPrint="true"
|
||||
encoding="UTF-8"
|
||||
>
|
||||
<x:element name="application">
|
||||
<x:element name="display-name">${maven.ear.displayname}</x:element>
|
||||
<j:forEach var="dep" items="${pom.dependencies}">
|
||||
<j:if test="${dep.getProperty('ear.bundle')=='true'}">
|
||||
<j:choose>
|
||||
<j:when test="${dep.type=='war'}">
|
||||
<x:element name="module">
|
||||
<x:element name="web">
|
||||
<x:element name="web-uri">${dep.getArtifact()}</x:element>
|
||||
<x:element name="context-root">${dep.getProperty('ear.appxml.war.context-root')}</x:element>
|
||||
</x:element>
|
||||
</x:element>
|
||||
</j:when>
|
||||
<j:when test="${dep.type=='ejb'}">
|
||||
<x:element name="module">
|
||||
<x:element name="ejb">${dep.getArtifact()}</x:element>
|
||||
</x:element>
|
||||
</j:when>
|
||||
<j:when test="${dep.type=='jar'}">
|
||||
<x:element name="module">
|
||||
<x:element name="java">${dep.getArtifact()}</x:element>
|
||||
</x:element>
|
||||
</j:when>
|
||||
</j:choose>
|
||||
</j:if>
|
||||
</j:forEach>
|
||||
</x:element>
|
||||
</j:file>
|
||||
|
||||
</goal>
|
||||
|
||||
|
||||
</project>
|
||||
|
||||
@ -9,4 +9,5 @@ maven.ear.src=${maven.src.dir}/application
|
||||
maven.ear.descriptordir=${maven.ear.src}/META-INF
|
||||
maven.ear.appxml=${maven.ear.descriptordir}/application.xml
|
||||
maven.ear.manifest=${maven.ear.descriptordir}/MANIFEST.MF
|
||||
|
||||
maven.ear.appxml.generate=false
|
||||
maven.ear.displayname=${pom.id}
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
<pomVersion>3</pomVersion>
|
||||
<id>maven-ear-plugin</id>
|
||||
<name>Maven EAR Plugin</name>
|
||||
<currentVersion>1.0</currentVersion>
|
||||
<currentVersion>1.1</currentVersion>
|
||||
<description>Ear Plugin for Maven</description>
|
||||
<shortDescription>Ear Plugin for Maven</shortDescription>
|
||||
<url>http://maven.apache.org/reference/plugins/ear/</url>
|
||||
@ -35,6 +35,15 @@
|
||||
<role>Java Developer</role>
|
||||
</roles>
|
||||
</developer>
|
||||
<developer>
|
||||
<name>Michal Maczka</name>
|
||||
<id>michal</id>
|
||||
<email>michal.maczka@dimatics.com</email>
|
||||
<organization/>
|
||||
<roles>
|
||||
<role>Java Developer</role>
|
||||
</roles>
|
||||
</developer>
|
||||
</developers>
|
||||
<dependencies/>
|
||||
</project>
|
||||
|
||||
@ -10,6 +10,11 @@
|
||||
Initial plugin created
|
||||
</action>
|
||||
</release>
|
||||
<release version="1.1" date="2003-05-08">
|
||||
<action dev="michal" type="add">
|
||||
Added autogeneration of application.xml file
|
||||
</action>
|
||||
</release>
|
||||
</body>
|
||||
</document>
|
||||
|
||||
|
||||
@ -28,5 +28,13 @@
|
||||
</description>
|
||||
</goal>
|
||||
</goals>
|
||||
|
||||
<goal>
|
||||
<name>ear:generate-ear-descriptor</name>
|
||||
<description>
|
||||
Generates application.xml
|
||||
file based on information from POM
|
||||
</description>
|
||||
</goal>
|
||||
</body>
|
||||
</document>
|
||||
|
||||
@ -20,6 +20,42 @@
|
||||
src/application/META-INF/MANIFEST.MF
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>maven.j2ee.ear.appxml</td>
|
||||
<td>Yes</td>
|
||||
<td>
|
||||
Location of the application.xml file
|
||||
to be used within the ear file.
|
||||
</td>
|
||||
<td>
|
||||
src/application/META-INF/application.xml
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>maven.j2ee.ear.appxml.generate</td>
|
||||
<td>Yes</td>
|
||||
<td>
|
||||
Indicates if application.xml files should
|
||||
be autogenerated
|
||||
</td>
|
||||
<td>
|
||||
false
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>maven.ear.displayname</td>
|
||||
<td>Yes</td>
|
||||
<td>
|
||||
Display name of the application to be used
|
||||
when application.xml file is autogenerated
|
||||
</td>
|
||||
<td>
|
||||
${pom.id}
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
|
||||
</table>
|
||||
</section>
|
||||
<section name="other settings">
|
||||
@ -41,23 +77,45 @@
|
||||
</tr>
|
||||
</table>
|
||||
</section>
|
||||
<section name="Including jars in the ear file">
|
||||
<section name="Including artifacts in the ear file">
|
||||
<p>
|
||||
You must tell Maven what jars you want included in the ear. This
|
||||
is achieved by specifying meta-information in the POM, using the
|
||||
You must tell Maven what artifact you want to include in the ear.
|
||||
This operation is type sensitive.
|
||||
Maven can bundle in ear artifacts of following types: jar, war, ejb.
|
||||
Artifacts of other types are ignored.
|
||||
This is achieved by specifying meta-information in the POM, using the
|
||||
following syntax:
|
||||
</p>
|
||||
|
||||
<source><![CDATA[
|
||||
<dependency>
|
||||
<id>jarid</id>
|
||||
<version>jarversion</version>
|
||||
<id>id</id>
|
||||
<version>aversion</version>
|
||||
<type>jar<type>
|
||||
<properties>
|
||||
<ear.bundle.jar>true</ear.bundle.jar>
|
||||
<ear.bundle>true</ear.bundle>
|
||||
</properties>
|
||||
</dependency>
|
||||
]]></source>
|
||||
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Those artifact will be also "visible" during generation
|
||||
of application.xml file. In case of war artifacts you can also
|
||||
specify context root which will be set in application.xml file:
|
||||
</p>
|
||||
<source><![CDATA[
|
||||
<dependency>
|
||||
<id>your_war</id>
|
||||
<version>your_version</version>
|
||||
<type>war<type>
|
||||
<properties>
|
||||
<ear.bundle>true</ear.bundle>
|
||||
<ear.appxml.context-root>maven</ear.appxml.war.context-root>
|
||||
</properties>
|
||||
</dependency>
|
||||
]]></source>
|
||||
|
||||
</section>
|
||||
</body>
|
||||
</document>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user