Fix for MPEAR-31: created a tag that defines the path of a dependency and then used that tag on both teh ear creation as appxml generation
git-svn-id: https://svn.apache.org/repos/asf/maven/maven-1/plugins/trunk@116280 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
6ba7eec7f6
commit
b8251627b1
@ -26,6 +26,8 @@
|
||||
xmlns:maven="jelly:maven"
|
||||
xmlns:util="jelly:util"
|
||||
xmlns:x="jelly:xml"
|
||||
xmlns:define="jelly:define"
|
||||
xmlns:ear="ear"
|
||||
>
|
||||
|
||||
<!--==================================================================-->
|
||||
@ -122,22 +124,11 @@
|
||||
</ant:echo>
|
||||
</j:if>
|
||||
|
||||
<ant:echo>Bundling: ${dep.type} - ${dep.id} - ${dep.version}</ant:echo>
|
||||
<!-- define the directory where the dependency will be included -->
|
||||
<!-- (if the property is not set, dir is the root) -->
|
||||
<j:set var="bundleDir" value="${dep.getProperty('ear.bundle.dir')}"/>
|
||||
<!-- define the name of the dependency -->
|
||||
<j:set var="bundleName" value="${dep.getProperty('ear.bundle.name')}"/>
|
||||
<j:if test="${empty(bundleName)}">
|
||||
<j:set var="bundleName" value="${lib.name}"/>
|
||||
</j:if>
|
||||
|
||||
<j:set var="bundlePath" value="${bundleDir}/${bundleName}"/>
|
||||
|
||||
<echo>Dependency ${lib.file.name} will be bundled as ${bundlePath}</echo>
|
||||
<ear:setPath lib="${lib}" var="bundledPath"/>
|
||||
<echo>Dependency ${lib.file.name} will be bundled as ${bundledPath}</echo>
|
||||
|
||||
<!-- after the definitions, copy the dependency -->
|
||||
<ant:copy file="${lib.file.parent}/${lib.file.name}" tofile="${tmpDependenciesDir}/${bundlePath}"/>
|
||||
<ant:copy file="${lib.file.parent}/${lib.file.name}" tofile="${tmpDependenciesDir}/${bundledPath}"/>
|
||||
|
||||
</j:if>
|
||||
</j:forEach>
|
||||
@ -219,36 +210,37 @@
|
||||
<x:element name="display-name">${maven.ear.displayname}</x:element>
|
||||
<j:forEach var="lib" items="${pom.artifacts}">
|
||||
<j:set var="dep" value="${lib.dependency}"/>
|
||||
<ear:setPath lib="${lib}" var="bundledPath"/>
|
||||
<j:if test="${dep.getProperty('ear.bundle')=='true' || dep.getProperty('ear.module')=='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="web-uri">${bundledPath}</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 name="ejb">${bundledPath}</x:element>
|
||||
</x:element>
|
||||
</j:when>
|
||||
<j:when test="${dep.type=='jar'}">
|
||||
<j:if test="${dep.getProperty('ear.module')=='true'}">
|
||||
<x:element name="module">
|
||||
<x:element name="java">${dep.getArtifact()}</x:element>
|
||||
<x:element name="java">${bundledPath}</x:element>
|
||||
</x:element>
|
||||
</j:if>
|
||||
</j:when>
|
||||
<j:when test="${dep.type=='rar'}">
|
||||
<x:element name="module">
|
||||
<x:element name="connector">${dep.getArtifact()}</x:element>
|
||||
<x:element name="connector">${bundledPath}</x:element>
|
||||
</x:element>
|
||||
</j:when>
|
||||
<j:when test="${dep.type=='sar'}">
|
||||
<x:element name="module">
|
||||
<x:element name="connector">${dep.getArtifact()}</x:element>
|
||||
<x:element name="connector">${bundledPath}</x:element>
|
||||
</x:element>
|
||||
</j:when>
|
||||
</j:choose>
|
||||
@ -325,7 +317,40 @@
|
||||
<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:
|
||||
lib: dependency to be bundled
|
||||
var: name of the variable that will get the result
|
||||
|
||||
-->
|
||||
<define:tag name="setPath">
|
||||
<j:set var="dep" value="${lib.dependency}"/>
|
||||
<!-- define the directory where the dependency will be included -->
|
||||
<!-- (if the property is not set, dir is the root) -->
|
||||
<j:set var="bundleDir" value="${dep.getProperty('ear.bundle.dir')}"/>
|
||||
<!-- define the name of the dependency -->
|
||||
<j:set var="bundleName" value="${dep.getProperty('ear.bundle.name')}"/>
|
||||
<j:if test="${empty(bundleName)}">
|
||||
<j:set var="bundleName" value="${lib.name}"/>
|
||||
</j:if>
|
||||
<j:choose>
|
||||
<j:when test="${empty(bundleDir)}">
|
||||
<j:set var="thePath" value="${bundleName}"/>
|
||||
</j:when>
|
||||
<j:otherwise>
|
||||
<j:set var="thePath" value="${bundleDir}/${bundleName}"/>
|
||||
</j:otherwise>
|
||||
</j:choose>
|
||||
${context.setVariable(var,'parent',thePath)}
|
||||
</define:tag>
|
||||
|
||||
</define:taglib>
|
||||
|
||||
|
||||
</project>
|
||||
|
||||
@ -17,14 +17,15 @@
|
||||
-->
|
||||
<project xmlns:j="jelly:core"
|
||||
xmlns:assert="assert"
|
||||
xmlns:util="jelly:util"
|
||||
xmlns:x="jelly:xml"
|
||||
default="testPlugin">
|
||||
|
||||
<goal name="testPlugin" prereqs="test-ear">
|
||||
<goal name="testPlugin" prereqs="ear,test-ear">
|
||||
<attainGoal name="clean"/>
|
||||
</goal>
|
||||
|
||||
<goal name="test-ear">
|
||||
<attainGoal name="ear"/>
|
||||
|
||||
<!-- tests that the ear is generated -->
|
||||
<assert:assertFileExists file="${maven.build.dir}/${maven.final.name}.ear"/>
|
||||
@ -37,7 +38,8 @@
|
||||
<unzip src="${earFile}" dest="${unzipDir}"/>
|
||||
|
||||
<!-- check for commons-logging -->
|
||||
<assert:assertFileExists file="${unzipDir}/APP-INF/lib/commons-logging-1.0.3.jar"
|
||||
<j:set var="commonsExpectedPath" value="/APP-INF/lib/commons-logging-1.0.3.jar"/>
|
||||
<assert:assertFileExists file="${unzipDir}${commonsExpectedPath}"
|
||||
msg="commons-logging was not bundled"/>
|
||||
|
||||
<!-- check that commons-collections has been packaged in the right place-->
|
||||
@ -52,6 +54,16 @@
|
||||
<assert:assertFileExists file="${unzipDir}/APP-INF/lib/LOG4J.JAR"
|
||||
msg="log4j was bundled incorrectly"/>
|
||||
|
||||
<!-- check that the application.xml was generated -->
|
||||
<j:set var="appXml" value="${unzipDir}/META-INF/application.xml"/>
|
||||
<assert:assertFileExists file="${appXml}"
|
||||
msg="application.xml was not generated"/>
|
||||
|
||||
<!-- check that commons-loggin was set with the right path -->
|
||||
<util:file var="appXmlFile" name="${appXml}"/>
|
||||
<x:parse var="appXmlDoc" xml="${appXmlFile}"/>
|
||||
<x:set var="commonsLogging" select="string($appXmlDoc/application/module/java)"/>
|
||||
<assert:assertEquals expected="${commonsExpectedPath}" value="${commonsLogging}"/>
|
||||
|
||||
</goal>
|
||||
</project>
|
||||
|
||||
1
ear/src/plugin-test/test02/project.properties
Normal file
1
ear/src/plugin-test/test02/project.properties
Normal file
@ -0,0 +1 @@
|
||||
maven.ear.appxml.generate=true
|
||||
@ -51,7 +51,7 @@
|
||||
<artifactId>commons-logging</artifactId>
|
||||
<version>1.0.3</version>
|
||||
<properties>
|
||||
<ear.bundle.dir>APP-INF/lib</ear.bundle.dir>
|
||||
<ear.bundle.dir>/APP-INF/lib</ear.bundle.dir>
|
||||
<ear.module>true</ear.module>
|
||||
</properties>
|
||||
</dependency>
|
||||
|
||||
@ -25,6 +25,8 @@
|
||||
</properties>
|
||||
<body>
|
||||
<release version="1.7-SNAPSHOT" date="on CVS">
|
||||
<action dev="felipeal" type="fix" issue="MPEAR-31">Fixed path of bundled dependency on generated <code>application.xml</code>.
|
||||
</action>
|
||||
<action dev="felipeal" type="update" issue="MAVEN-1526">Issues a warning (instead of failing the build) when a case-sensitiveness dependency issue is found</action>
|
||||
</release>
|
||||
<release version="1.6" date="2004-12-05">
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user