- 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
165 lines
6.6 KiB
XML
165 lines
6.6 KiB
XML
<?xml version="1.0"?>
|
|
|
|
<project
|
|
xmlns:j="jelly:core"
|
|
xmlns:ant="jelly:ant"
|
|
xmlns:license="license"
|
|
xmlns:util="jelly:util"
|
|
xmlns:x="jelly:xml"
|
|
>
|
|
|
|
<!--==================================================================-->
|
|
<!-- 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>
|
|
|
|
<!--==================================================================-->
|
|
<!-- Builds an ear file -->
|
|
<!--==================================================================-->
|
|
<goal name="ear:ear" prereqs="ear:init" description="Build an ear file">
|
|
|
|
<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}"/>
|
|
|
|
<ant:ear destfile="${maven.build.dir}/${maven.final.name}.ear"
|
|
appxml="${maven.ear.appxml}"
|
|
basedir="${maven.ear.src}"
|
|
excludes="${maven.ear.appxml}">
|
|
|
|
<!-- include marked dependencies -->
|
|
<j:forEach var="dep" items="${pom.dependencies}">
|
|
<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 -->
|
|
<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}" />
|
|
</j:if>
|
|
|
|
<!-- standard manifest entries -->
|
|
<ant:manifest>
|
|
<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>
|
|
</ant:manifest>
|
|
</ant:ear>
|
|
|
|
</goal>
|
|
|
|
<!--==================================================================-->
|
|
<!-- Install the ear in the local repository -->
|
|
<!--==================================================================-->
|
|
<goal name="ear:install"
|
|
prereqs="ear:ear"
|
|
description="Install the ear in the local repository">
|
|
|
|
<ant:property name="maven.ear.install.dir"
|
|
value="${maven.repo.local}/${pom.artifactDirectory}/ears"/>
|
|
<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>
|