felipeal    2004/12/08 18:05:40

  Modified:    ear      plugin.jelly
               ear/src/plugin-test/test02 maven.xml project.xml
               ear/xdocs changes.xml
  Added:       ear/src/plugin-test/test02 project.properties
  Log:
  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
  
  Revision  Changes    Path
  1.31      +45 -20    maven-plugins/ear/plugin.jelly
  
  Index: plugin.jelly
  ===================================================================
  RCS file: /home/cvs/maven-plugins/ear/plugin.jelly,v
  retrieving revision 1.30
  retrieving revision 1.31
  diff -u -r1.30 -r1.31
  --- plugin.jelly      8 Dec 2004 12:00:21 -0000       1.30
  +++ plugin.jelly      9 Dec 2004 02:05:40 -0000       1.31
  @@ -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>
  
  
  
  1.4       +15 -3     maven-plugins/ear/src/plugin-test/test02/maven.xml
  
  Index: maven.xml
  ===================================================================
  RCS file: /home/cvs/maven-plugins/ear/src/plugin-test/test02/maven.xml,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- maven.xml 16 Nov 2004 03:22:59 -0000      1.3
  +++ maven.xml 9 Dec 2004 02:05:40 -0000       1.4
  @@ -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.5       +1 -1      maven-plugins/ear/src/plugin-test/test02/project.xml
  
  Index: project.xml
  ===================================================================
  RCS file: /home/cvs/maven-plugins/ear/src/plugin-test/test02/project.xml,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- project.xml       16 Nov 2004 03:22:59 -0000      1.4
  +++ project.xml       9 Dec 2004 02:05:40 -0000       1.5
  @@ -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>
  
  
  
  1.1                  
maven-plugins/ear/src/plugin-test/test02/project.properties
  
  Index: project.properties
  ===================================================================
  maven.ear.appxml.generate=true
  
  
  
  1.33      +2 -0      maven-plugins/ear/xdocs/changes.xml
  
  Index: changes.xml
  ===================================================================
  RCS file: /home/cvs/maven-plugins/ear/xdocs/changes.xml,v
  retrieving revision 1.32
  retrieving revision 1.33
  diff -u -r1.32 -r1.33
  --- changes.xml       8 Dec 2004 12:00:21 -0000       1.32
  +++ changes.xml       9 Dec 2004 02:05:40 -0000       1.33
  @@ -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">
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to