kaz         02/05/14 10:59:42

  Modified:    src/java/org/apache/maven BaseProjectTask.java
               src/templates/build Control.vm build.init.target
  Added:       src/templates/build/plugins/j2ee Control.vm build.xml
                        default.properties
  Removed:     src/templates/build Control-j2ee.vm build-j2ee.xml
                        j2ee.properties
  Log:
  Trying to further separate plugin stuff from core functionality.  Some
  notes regarding the change:
  
  - Plugins should now be placed in an subdirectory (named after the
    plugin) of the src/templates/build/plugins directory.  For example,
    the j2ee plugin is now located in the following directory:
  
      src/templates/build/plugins/j2ee
  
  - Likewise, in the user's Maven install directory, plugins are located
    in the ${maven.home}/plugins directory.  For example, the j2ee plugin
    is installed in my ${maven.home}/plugins/j2ee directory.
  
  - Each plugin directory in the source tree must have a Control.vm file
    that controls the processing of the plugin.  Within this template the
    variable "$plugin" expands to the name of the current plugin.  Note:
    filename references in this file are relative to the
    src/templates/build directory.
  
  - When Texen's $generator.parse() method is called on a file in a plugin
    directory, the context is stuffed with a variable called $plugin that
    contains the name of the current plugin.  As a result of this, the
    callback name doesn't have to be explicity set in a plugin's build
    file (see the diff's between the old build-j2ee.xml and the new
    build.xml file).
  
  Revision  Changes    Path
  1.10      +1 -2      
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.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- BaseProjectTask.java      2 May 2002 06:29:44 -0000       1.9
  +++ BaseProjectTask.java      14 May 2002 17:59:42 -0000      1.10
  @@ -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.9 2002/05/02 06:29:44 dion Exp $
  + * @version $Id: BaseProjectTask.java,v 1.10 2002/05/14 17:59:42 kaz Exp $
    */
   public class BaseProjectTask
       extends TexenTask
  @@ -136,7 +136,6 @@
                   "org.apache.maven.project.Project");
               
               context.put("buildElements", new ArrayList());
  -            context.put("plugins", new ArrayList());
               context.put("delegators", new HashMap());
               context.put("project", mavenProject);
               context.put("jars", ListTask.getList(listFile));
  
  
  
  1.19      +30 -6     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.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- Control.vm        2 May 2002 06:29:44 -0000       1.18
  +++ Control.vm        14 May 2002 17:59:42 -0000      1.19
  @@ -7,6 +7,23 @@
   ${cbName}-callback#end
   
   ## -------------------------------------------------------
  +## Macro to get the plugin name from the buildElement's 
  +## filename.  If buildElement is plugins/j2ee/somefile will
  +## set $plugin to the value of "j2ee".
  +## -------------------------------------------------------
  +
  +#macro( parsePluginName $buildElement )
  +    #set ($idx1 = $buildElement.indexOf("/"))
  +    #set ($idx1 = $idx1 + 1)
  +    #set ($idx2 = $buildElement.indexOf("/", $idx1))
  +    #if ($idx1 == -1 || $idx2 == -1)
  +      #set ($plugin = "")
  +    #else
  +      #set ($plugin = $buildElement.substring($idx1, $idx2))
  +    #end
  +#end
  +
  +## -------------------------------------------------------
   ## Make our list of build system elements
   ## -------------------------------------------------------
   
  @@ -72,14 +89,16 @@
   ## -------------------------------------------------------
   ## Call plug-ins
   ## -------------------------------------------------------
  -$plugins.add("j2ee")
  -#set ($pluginPrefix = "Control-")
  -#set ($pluginSuffix = ".vm")
  +#set ($dir = "$generator.templatePath/plugins")
  +#set ($plugins = $files.file($dir).list())
  +
   #foreach ($plugin in $plugins)
  -    #parse("$pluginPrefix$plugin$pluginSuffix")
  +  #if ($plugin != "CVS")
  +    $files.mkdir("$outputDir/plugins/$plugin")
  +    #parse("plugins/$plugin/Control.vm")
  +  #end
   #end
   
  -
   ## -------------------------------------------------------
   ## Generate all the maven specific build elements that
   ## are placed in the maven directory.
  @@ -88,7 +107,12 @@
   #set ($antBasedir = "..")
   
   #foreach ($buildElement in $buildElements)
  -$generator.parse($buildElement,"$outputDir/$buildElement")
  +  #if ($buildElement.startsWith("plugins/"))
  +    #parsePluginName( $buildElement )
  +    $generator.parse($buildElement,"$outputDir/$buildElement","plugin",$plugin)
  +  #else
  +    $generator.parse($buildElement,"$outputDir/$buildElement")
  +  #end
   #end
   
   ## We don't want to overwrite an existing build.xml file
  
  
  
  1.32      +2 -2      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.31
  retrieving revision 1.32
  diff -u -r1.31 -r1.32
  --- build.init.target 8 May 2002 12:12:58 -0000       1.31
  +++ build.init.target 14 May 2002 17:59:42 -0000      1.32
  @@ -329,7 +329,7 @@
       
     </target>
   
  -  #if ($callbacks.get( $callbackCategory ))
  +  #if ($callbacks.get( $plugin ))
     #set( $cbPrefix = "${maven" )
     #set( $cbFile = "buildFile}" )
     #set( $cbTarget = "buildTarget}" )
  @@ -337,7 +337,7 @@
     <!-- ================================================================== -->
     <!-- C A L L B A C K S                                                  -->
     <!-- ================================================================== -->
  -  #foreach( $cbName in $callbacks.get( $callbackCategory ) )
  +  #foreach( $cbName in $callbacks.get( $plugin ) )
     #set( $buildFile = "${cbPrefix}.callback.${cbName}.${cbFile}" )
     #set( $buildTarget = "${cbPrefix}.callback.${cbName}.${cbTarget}" )
     
  
  
  
  1.1                  
jakarta-turbine-maven/src/templates/build/plugins/j2ee/Control.vm
  
  Index: Control.vm
  ===================================================================
  ## -------------------------------------------------------
  ## Control file for Maven j2ee plug-in
  ## -------------------------------------------------------
  
  ## -------------------------------------------------------
  ## Add build files to the list
  ## -------------------------------------------------------
  $buildElements.add("plugins/$plugin/build.xml")
  $buildElements.add("plugins/$plugin/default.properties")
  
  ## -------------------------------------------------------
  ## Make the list of build-j2ee.xml delegators
  ## -------------------------------------------------------
  $delegators.put("war",          "plugins/$plugin/build.xml")
  $delegators.put("validate-war", "plugins/$plugin/build.xml")
  $delegators.put("ear",          "plugins/$plugin/build.xml")
  
  ## -------------------------------------------------------
  ## Make the list of build-j2ee.xml callbacks
  ## -------------------------------------------------------
  $callbacks.put( "$plugin", [ "preprocess-war", "postprocess-war", "preprocess-ear",  
"postprocess-ear" ] );
  
  
  
  1.1                  jakarta-turbine-maven/src/templates/build/plugins/j2ee/build.xml
  
  Index: build.xml
  ===================================================================
  <?xml version='1.0' encoding='UTF-8' ?>
  
  <project name="$project.id" default="war" basedir="$antBasedir">
  
  #parse("build.init.target")
  
      <!-- ================================================================== -->
      <!-- L O C A L   I N I T                                                -->
      <!-- ================================================================== -->
  
      <target name="local-init" depends="init">
          <!-- Pick up tool specific defaults -->
          <property file="${maven.home}/plugins/$plugin/default.properties"/>
          
          <!-- Check all requirements are available -->
          <condition property="maven.j2ee.war.ready">
              <and>
                  <not>
                      <equals arg1="${maven.j2ee.war.name}"
                              arg2="$${maven.j2ee.war.name}" />
                  </not>
                  <available file="${maven.j2ee.war.src}" type="dir"/>
                  <available file="${maven.j2ee.war.content}" type="dir"/>
                  <available file="${maven.j2ee.war.webxml}" type="file"/>
              </and>
          </condition>
          
          <condition property="maven.j2ee.ear.ready">
              <and>
                  <not>
                      <equals arg1="${maven.j2ee.ear.name}"
                              arg2="$${maven.j2ee.ear.name}" />
                  </not>
                  <available file="${maven.j2ee.ear.appxml}" type="file"/>
              </and>
          </condition>
      </target>
    
      <target name="war"
          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.j2ee.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.j2ee.war.name is defined:
      |
      |        maven.j2ee.war.name = ${maven.j2ee.war.name}
      |
      |        Please ensure that the following directories exist:
      |
      |        ${maven.j2ee.war.src}
      |        ${maven.j2ee.war.content}
      |
      |        and the following files:
      |
      |        ${maven.j2ee.war.webxml}
      +------------------------------------------------------------------------------
          </fail>
      </target>
        
      <target name="war-init" if="maven.j2ee.war.ready">
          <!-- nothing to do as of yet -->
      </target>    
      
      <target name="war-build" if="maven.j2ee.war.ready">
          <!-- make sure the source is compiled -->
          <ant antfile="${maven.home}/build-maven.xml" target="jar" />
  
          <echo>Building WAR ${maven.j2ee.war.name}</echo>
          
          <war warfile="${maven.build.dir}/${maven.j2ee.war.name}.war"
               webxml="${maven.j2ee.war.webxml}">
              <fileset dir="${maven.j2ee.war.content}"/>
              <lib dir="${lib.repo}">
                  <patternset refid="maven.dependency.set" />
                  <exclude name="servlet*.jar" />
              </lib>
              <classes dir="${maven.build.dest}">
                  <include name="${maven.j2ee.war.classes.includes}" />
                  <exclude name="${maven.j2ee.war.classes.excludes}" />
              </classes>
              <metainf dir="${basedir}">
                  <include name="LICENSE.txt"/>
              </metainf>
              <manifest>
                  <attribute name="Built-By" value="${user.name}" />
                  <section name="${maven.package}">
                      <attribute name="Specification-Title" value="${maven.id}" />
                      <attribute name="Specification-Version" 
value="${maven.currentVersion}" />
                      <attribute name="Specification-Vendor" 
value="${maven.organization}" />
                      <attribute name="Implementation-Title" value="${maven.package}" 
/>
                      <attribute name="Implementation-Version" 
value="${maven.currentVersion}" />
                      <attribute name="Implementation-Vendor" 
value="${maven.organization}" />
                  </section>
              </manifest>
           </war>
      </target>
  
      <target name="validate-war" depends="local-init">
          <taskdef
            name="warvalidator"
            classname="org.apache.maven.j2ee.WarValidator">
            <classpath refid="maven-classpath"/>
            <classpath refid="maven.dependency.classpath"/>
          </taskdef>
          
          <warvalidator
              warFileName="${maven.build.dir}/${maven.j2ee.war.name}.war"
              projectDescriptor="project.xml">
              <formatter type="plain" usefile="false"/>
          </warvalidator>
  
      </target>
      
      <!-- 
          EAR processing 
      -->
      <target name="ear"
          depends="local-init,
                   ear-error,
                   war,
                   ear-init,
                   #callback("preprocess-ear"),
                   ear-build,
                   #callback("postprocess-ear")"
          description="o Create an ear file" />
  
      <target name="ear-error" unless="maven.j2ee.ear.ready">
          <!-- extend this list with requirements as needed -->
          <fail>
      +------------------------------------------------------------------------------
      |
      | ERROR: One of the required properties for maven:ear was not provided.
      |
      |        Please ensure that the property maven.j2ee.ear.name is defined:
      |
      |        maven.j2ee.ear.name = ${maven.j2ee.ear.name}
      |
      |        and the following files:
      |
      |        ${maven.j2ee.ear.appxml}
      +------------------------------------------------------------------------------
          </fail>
      </target>
          
      <target name="ear-init" if="maven.j2ee.ear.ready">
          <!-- nothing to do as of yet -->
      </target>
  
      <target name="ear-build" if="maven.j2ee.ear.ready">
          <echo>Building EAR ${maven.j2ee.ear.name}</echo>
          
          <ear earfile="${maven.build.dir}/${maven.j2ee.ear.name}.ear"
               appxml="${maven.j2ee.ear.appxml}">
              <fileset dir="${maven.build.dir}" 
                  includes="${maven.j2ee.ear.includes}"
                  excludes="${maven.j2ee.ear.excludes}" />
              <metainf dir="${basedir}">
                  <include name="LICENSE.txt"/>
              </metainf>
              <manifest>
                  <attribute name="Built-By" value="${user.name}" />
                  <section name="${maven.package}">
                      <attribute name="Specification-Title" value="${maven.id}" />
                      <attribute name="Specification-Version" 
value="${maven.currentVersion}" />
                      <attribute name="Specification-Vendor" 
value="${maven.organization}" />
                      <attribute name="Implementation-Title" value="${maven.package}" 
/>
                      <attribute name="Implementation-Version" 
value="${maven.currentVersion}" />
                      <attribute name="Implementation-Vendor" 
value="${maven.organization}" />
                  </section>
              </manifest>
           </ear>
      </target>
      
  </project>
  
  
  
  1.1                  
jakarta-turbine-maven/src/templates/build/plugins/j2ee/default.properties
  
  Index: default.properties
  ===================================================================
  # properties file for build-j2ee.xml
  maven.j2ee.war.src=${maven.src.dir}/webapps
  maven.j2ee.war.content=${maven.j2ee.war.src}/${maven.j2ee.war.name}
  # classes are relative to build.dir
  maven.j2ee.war.classes.includes=**
  maven.j2ee.war.classes.excludes=**/package.html
  #jars are relative to lib.repo
  maven.j2ee.war.lib.includes=*.jar
  maven.j2ee.war.lib.excludes=
  # - not used any more. not sure if this is good/bad
  # maven.j2ee.war.manifest=${conf.dir}/${maven.j2ee.war.name}-MANIFEST.MF
  maven.j2ee.war.webxml=${maven.conf.dir}/${maven.j2ee.war.name}-web.xml
  
  ##
  # EAR Target properties
  ##
  # maven.j2ee.ear.name
  maven.j2ee.ear.appxml=${maven.conf.dir}/${maven.j2ee.ear.name}-application.xml
  maven.j2ee.ear.includes=*.jar, *.war
  maven.j2ee.ear.excludes=
  
  
  

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

Reply via email to