dion        02/05/01 23:29:44

  Modified:    src/templates/build build-maven.xml Control.vm
                        build-j2ee.xml j2ee.properties build.init.target
                        Control-j2ee.vm
               src/java/org/apache/maven BaseProjectTask.java
  Log:
  Patch supplied by Glenn McAllister to handle generic call backs as part of the
  j2ee 'plug-in'
  
  Revision  Changes    Path
  1.42      +2 -2      jakarta-turbine-maven/src/templates/build/build-maven.xml
  
  Index: build-maven.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-maven/src/templates/build/build-maven.xml,v
  retrieving revision 1.41
  retrieving revision 1.42
  diff -u -r1.41 -r1.42
  --- build-maven.xml   1 May 2002 19:51:05 -0000       1.41
  +++ build-maven.xml   2 May 2002 06:29:44 -0000       1.42
  @@ -376,10 +376,10 @@
           <section name="${package}">
             <attribute name="Specification-Title" value="${id}"/>
             <attribute name="Specification-Version" value="${currentVersion}"/>
  -          <attribute name="Specification-Vendor" value="${organization}"/>
  +          <attribute name="Specification-Vendor" value="${maven.organization}"/>
             <attribute name="Implementation-Title" value="${package}"/>
             <attribute name="Implementation-Version" value="${currentVersion}"/>
  -          <attribute name="Implementation-Vendor" value="${organization}"/>
  +          <attribute name="Implementation-Vendor" value="${maven.organization}"/>
           </section>
         </manifest>
       </jar>
  
  
  
  1.18      +8 -0      jakarta-turbine-maven/src/templates/build/Control.vm
  
  Index: Control.vm
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-maven/src/templates/build/Control.vm,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- Control.vm        1 May 2002 16:54:31 -0000       1.17
  +++ Control.vm        2 May 2002 06:29:44 -0000       1.18
  @@ -1,3 +1,11 @@
  +
  +## -------------------------------------------------------
  +## Macro for adding a callback target name in a build file
  +## -------------------------------------------------------
  +
  +#macro( callback $cbName )
  +${cbName}-callback#end
  +
   ## -------------------------------------------------------
   ## Make our list of build system elements
   ## -------------------------------------------------------
  
  
  
  1.4       +58 -74    jakarta-turbine-maven/src/templates/build/build-j2ee.xml
  
  Index: build-j2ee.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-maven/src/templates/build/build-j2ee.xml,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- build-j2ee.xml    1 May 2002 15:47:58 -0000       1.3
  +++ build-j2ee.xml    2 May 2002 06:29:44 -0000       1.4
  @@ -2,7 +2,9 @@
   
   <project name="$project.id" default="war" basedir="$antBasedir">
   
  +#set( $callbackCategory = "j2ee" )
   #parse("build.init.target")
  +#set( $callbackCategory = "" )
   
       <!-- ================================================================== -->
       <!-- L O C A L   I N I T                                                -->
  @@ -11,106 +13,88 @@
       <target name="local-init" depends="init">
           <!-- Pick up tool specific defaults -->
           <property file="${maven.home}/j2ee.properties"/>
  +        
           <!-- Check all requirements are available -->
           <condition property="maven.war.ready">
               <and>
  +                <not>
  +                    <equals arg1="${maven.war.name}"
  +                            arg2="$${maven.war.name}" />
  +                </not>
                   <available file="${maven.war.src}" type="dir"/>
                   <available file="${maven.war.content}" type="dir"/>
                   <available file="${maven.war.webxml}" type="file"/>
               </and>
           </condition>
  -        <!-- set maven.war.preprocessing if the user has set both properties,
  -             maven.war.preprocessBuildFile and maven.war.preprocessTarget
  -         -->
  -        <condition property="maven.war.preprocessing">
  -            <and>
  -                <not>
  -                    <or>
  -                        <equals arg1="${maven.war.preprocessBuildFile}"
  -                                arg2="${maven.war.preprocessBuildFile}"/>
  -                        <equals arg1="${maven.war.preprocessTarget}"
  -                                arg2="${maven.war.preprocessTarget}"/>
  -                        <equals arg1="${maven.war.ready}"
  -                                arg2="${maven.war.ready}"/>
  -                    </or>
  -                </not>
  -            </and>
  -        </condition>
  -        <!-- set maven.war.postprocessing if the user has set both properties,
  -             maven.war.postprocessBuildFile and maven.war.postprocessTarget
  -         -->
  -        <condition property="maven.war.postprocessing">
  -            <not>
  -                <or>
  -                    <equals arg1="${maven.war.postprocessBuildFile}"
  -                            arg2="${maven.war.postprocessBuildFile}"/>
  -                    <equals arg1="${maven.war.postprocessTarget}"
  -                            arg2="${maven.war.postprocessTarget}"/>
  -                    <equals arg1="${maven.war.ready}"
  -                            arg2="${maven.war.ready}"/>
  -                </or>
  -            </not>
  -        </condition>
  -
       </target>
     
       <target name="war"
  -        
depends="local-init,war-error,war-init,war-preprocess,war-build,war-postprocess"
  +        depends="local-init,
  +                 war-error,
  +                 war-init,
  +                 #callback("preprocess-war"),
  +                 war-build,
  +                 #callback("postprocess-war")"
           description="o Create a war file" />
  -       
  + 
  +    <target name="war-error" unless="maven.war.ready">
  +        <!-- extend this list with requirements as needed -->
  +        <fail>
  +    +------------------------------------------------------------------------------
  +    |
  +    | ERROR: One of the required properties for maven:war was not provided.
  +    |
  +    |        Please ensure that the property maven.war.name is defined:
  +    |
  +    |        maven.war.name = ${maven.war.name}
  +    |
  +    |        Please ensure that the following directories exist:
  +    |
  +    |        ${maven.war.src}
  +    |        ${maven.war.content}
  +    |
  +    |        and the following files:
  +    |
  +    |        ${maven.war.webxml}
  +    +------------------------------------------------------------------------------
  +        </fail>
  +    </target>
  +      
       <target name="war-init" if="maven.war.ready">
  -        <!-- Create build directories -->
  -        <mkdir dir="${maven.build.war}/${maven.war.name}"/>
  -        <mkdir dir="${maven.build.war}/${maven.war.name}/META-INF"/>
  -        <mkdir dir="${maven.build.war}/${maven.war.name}/WEB-INF"/>
  -        <mkdir dir="${maven.build.war}/${maven.war.name}/WEB-INF/classes"/>
  -        <mkdir dir="${maven.build.war}/${maven.war.name}/WEB-INF/lib"/>
  +        <!-- nothing to do as of yet -->
       </target>    
       
       <target name="war-build" if="maven.war.ready">
  +        <!-- make sure the source is compiled -->
           <ant antfile="${maven.home}/build-maven.xml" target="compile" />
  +
  +        <!-- setup any required resources -->
           <ant antfile="${maven.home}/build-maven.xml" target="jar-resources" />
  -        <echo>building for ${maven.war.name}</echo>
  -        <war warfile="${maven.build.war}/${maven.war.name}.war"
  +        
  +        <echo>Building WAR ${maven.war.name}</echo>
  +        
  +        <war warfile="${build.dir}/${maven.war.name}.war"
                webxml="${maven.war.webxml}">
               <fileset dir="${maven.war.content}"/>
  -            <!--<fileset dir="${maven.war.templates}"/> -->
               <lib dir="${lib.repo}">
  -                <include name="${maven.war.lib.includes}"/>
  -                <exclude name="${maven.war.lib.excludes}"/>
  +                <patternset refid="classpath.patternset" />
               </lib>
               <classes dir="${build.dest}">
                   <include name="${maven.war.classes.includes}" />
                   <exclude name="${maven.war.classes.excludes}" />
               </classes>
  +            <manifest>
  +                <attribute name="Built-By" value="${user.name}" />
  +                <section name="${package}">
  +                    <attribute name="Specification-Title" value="${id}" />
  +                    <attribute name="Specification-Version" 
value="${currentVersion}" />
  +                    <attribute name="Specification-Vendor" 
value="${maven.organization}" />
  +                    <attribute name="Implementation-Title" value="${package}" />
  +                    <attribute name="Implementation-Version" 
value="${currentVersion}" />
  +                    <attribute name="Implementation-Vendor" 
value="${maven.organization}" />
  +                </section>
  +            </manifest>
            </war>
       </target>
       
  -    <target name="war-error" unless="maven.war.ready">
  -        <!-- extend this list with requirements as needed -->
  -        <echo>
  -        One of the required properties for maven:war was not provided.
  -        Please ensure that the following directories exist:
  -        ${maven.war.src}
  -        ${maven.war.content}
  -        ------------------------------------------------------------------------
  -        and the following files:
  -        ${maven.war.webxml}
  -        ------------------------------------------------------------------------
  -        </echo>
  -    </target>
  -    
  -    <target name="war-preprocess" if="maven.war.preprocessing">
  -        <echo>pre processing for ${maven.war.name}</echo>
  -        <ant antfile="${maven.war.preprocessBuildFile}"
  -             target="${maven.war.preprocessBuildFile}" />
  -    </target>
  -
  -    <target name="war-postprocess" if="maven.war.postprocessing">
  -        <echo>post processing for ${maven.war.name}</echo>
  -        <ant antfile="${maven.war.postprocessBuildFile}"
  -             target="${maven.war.postprocessTarget}" />
  -    </target>
  -
  -    
  -</project>
  \ No newline at end of file
  +</project>
  
  
  
  1.4       +3 -3      jakarta-turbine-maven/src/templates/build/j2ee.properties
  
  Index: j2ee.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-maven/src/templates/build/j2ee.properties,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- j2ee.properties   1 May 2002 15:47:22 -0000       1.3
  +++ j2ee.properties   2 May 2002 06:29:44 -0000       1.4
  @@ -3,8 +3,8 @@
   maven.war.src=${src.dir}/webapps
   maven.war.content=${maven.war.src}/${maven.war.name}
   # classes are relative to build.dir
  -maven.war.classes.includes=**/*.class
  -maven.war.classes.excludes=
  +maven.war.classes.includes=**
  +maven.war.classes.excludes=**/package.html
   #jars are relative to lib.repo
   maven.war.lib.includes=*.jar
   maven.war.lib.excludes=
  @@ -13,4 +13,4 @@
   #maven.war.prepareBuildFile=build.xml
   #maven.war.prepareBuildTarget=maven:war:preProcess
   #maven.war.updateBuildFile=build.xml
  -#maven.war.updateBuildTarget=maven:war:postProcess
  \ No newline at end of file
  +#maven.war.updateBuildTarget=maven:war:postProcess
  
  
  
  1.27      +40 -0     jakarta-turbine-maven/src/templates/build/build.init.target
  
  Index: build.init.target
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-maven/src/templates/build/build.init.target,v
  retrieving revision 1.26
  retrieving revision 1.27
  diff -u -r1.26 -r1.27
  --- build.init.target 1 May 2002 19:51:05 -0000       1.26
  +++ build.init.target 2 May 2002 06:29:44 -0000       1.27
  @@ -322,3 +322,43 @@
       <delete file="project.xml.${toVersion}"/>
       
     </target>
  +
  +  #if ($callbacks.get( $callbackCategory ))
  +  #set( $cbPrefix = "${maven" )
  +  #set( $cbFile = "buildFile}" )
  +  #set( $cbTarget = "buildTarget}" )
  +    
  +  <!-- ================================================================== -->
  +  <!-- C A L L B A C K S                                                  -->
  +  <!-- ================================================================== -->
  +  #foreach( $cbName in $callbacks.get( $callbackCategory ) )
  +  #set( $buildFile = "${cbPrefix}.callback.${cbName}.${cbFile}" )
  +  #set( $buildTarget = "${cbPrefix}.callback.${cbName}.${cbTarget}" )
  +  
  +  <target name="${cbName}-callback-check">
  +    <condition property="maven.callback.${cbName}.ok">
  +      <not>
  +        <or>
  +          <equals arg1="$buildFile"
  +                  arg2="$$buildFile" />
  +          <equals arg1="$buildTarget"
  +                  arg2="$$buildTarget" />
  +        </or>
  +      </not>
  +    </condition>
  +  </target>
  +  
  +  <target name="#callback( $cbName )"
  +          depends="${cbName}-callback-check"
  +          if="maven.callback.${cbName}.ok">
  +
  +    <ant antfile="$buildFile"
  +         target="$buildTarget">
  +      <property name="maven.build.classpath" value="classpath" />
  +    </ant>
  +
  +  </target>
  +  
  +  #end
  +  #end
  +  
  
  
  
  1.2       +6 -0      jakarta-turbine-maven/src/templates/build/Control-j2ee.vm
  
  Index: Control-j2ee.vm
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-maven/src/templates/build/Control-j2ee.vm,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Control-j2ee.vm   1 May 2002 16:54:31 -0000       1.1
  +++ Control-j2ee.vm   2 May 2002 06:29:44 -0000       1.2
  @@ -12,3 +12,9 @@
   ## Make the list of build-j2ee.xml delegators
   ## -------------------------------------------------------
   $delegators.put("war","build-j2ee.xml")
  +
  +
  +## -------------------------------------------------------
  +## Make the list of build-j2ee.xml callbacks
  +## -------------------------------------------------------
  +$callbacks.put( "j2ee", [ "preprocess-war", "postprocess-war" ] );
  
  
  
  1.9       +2 -1      
jakarta-turbine-maven/src/java/org/apache/maven/BaseProjectTask.java
  
  Index: BaseProjectTask.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/BaseProjectTask.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- BaseProjectTask.java      1 May 2002 16:54:31 -0000       1.8
  +++ BaseProjectTask.java      2 May 2002 06:29:44 -0000       1.9
  @@ -74,7 +74,7 @@
    * An ant task for creating an xml schema from an sql schema
    *
    * @author <a href="[EMAIL PROTECTED]">Jason van Zyl</a>
  - * @version $Id: BaseProjectTask.java,v 1.8 2002/05/01 16:54:31 dion Exp $
  + * @version $Id: BaseProjectTask.java,v 1.9 2002/05/02 06:29:44 dion Exp $
    */
   public class BaseProjectTask
       extends TexenTask
  @@ -140,6 +140,7 @@
               context.put("delegators", new HashMap());
               context.put("project", mavenProject);
               context.put("jars", ListTask.getList(listFile));
  +            context.put("callbacks", new HashMap());
               return context;
           }
           catch (Exception e)
  
  
  


Reply via email to