jvanzyl     02/04/25 08:51:28

  Modified:    .        .cvsignore build-bootstrap.xml jars.list
                        project.xml
               src/java/org/apache/maven ProjectProperties.java
               src/java/org/apache/maven/ant AntUtils.java
               src/java/org/apache/maven/project Jar.java Project.java
               src/templates/build build-maven.xml default.properties
               src/test/org/apache/maven/project ProjectMapperTest.java
  Log:
  Added some preliminary support for a 'prepare source' process where a
  project needs to generate/preprocess sources before the compilation phase.
  
  This is what project.properties looks like in fulcrum to accommodate
  this feature:
  
  # ------------------------------------------------------------------------
  # P R E P A R E  S O U R C E S
  # ------------------------------------------------------------------------
  maven.delegatorBuildFile = build.xml
  maven.prepareSourceDirectory = target/src
  maven.prepareSourceTarget = om
  
  It is assumed that the target called takes care of knowing when and
  when not to regenerate, if you don't add any logic the source preparation
  will happen repeatedly because of the dependencies among the maven
  targets (which is currently a result of ant deficiencies is passing
  around references).
  
  There is also the start of my work on a safe distribution target which
  is coming in now because I'm checking in the source preparation changes.
  
  Revision  Changes    Path
  1.7       +4 -12     jakarta-turbine-maven/.cvsignore
  
  Index: .cvsignore
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-maven/.cvsignore,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- .cvsignore        18 Apr 2002 13:03:39 -0000      1.6
  +++ .cvsignore        25 Apr 2002 15:51:27 -0000      1.7
  @@ -1,14 +1,6 @@
  -*~
  -.nbattrs
  -bootstrap.report
  -docs
  -LICENSE.txt
  -maven
  -maven-install*.jar
  -maven.log
  -README.txt
   target
  -test-reports
  -velocity.log*
   work
  -
  +velocity.log
  +maven.log
  +*~
  +docs
  
  
  
  1.78      +6 -6      jakarta-turbine-maven/build-bootstrap.xml
  
  Index: build-bootstrap.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-maven/build-bootstrap.xml,v
  retrieving revision 1.77
  retrieving revision 1.78
  diff -u -r1.77 -r1.78
  --- build-bootstrap.xml       22 Apr 2002 14:43:38 -0000      1.77
  +++ build-bootstrap.xml       25 Apr 2002 15:51:27 -0000      1.78
  @@ -180,9 +180,9 @@
   
       <javac
         destdir="${basedir}/bootstrap"
  -      debug="${debug}"
  -      deprecation="${deprecation}"
  -      optimize="${optimize}">
  +      debug="on"
  +      deprecation="off"
  +      optimize="off">
         <src>
           <path location="src/java"/>
         </src>
  @@ -218,9 +218,9 @@
       
       <javac
         destdir="${basedir}/bootstrap"
  -      debug="${debug}"
  -      deprecation="${deprecation}"
  -      optimize="${optimize}">
  +      debug="on"
  +      deprecation="off"
  +      optimize="off">
         <classpath refid="bootstrap-classpath"/>
         <src>
           <path location="src/java"/>
  
  
  
  1.6       +1 -0      jakarta-turbine-maven/jars.list
  
  Index: jars.list
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-maven/jars.list,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- jars.list 16 Apr 2002 21:15:19 -0000      1.5
  +++ jars.list 25 Apr 2002 15:51:27 -0000      1.6
  @@ -29,6 +29,7 @@
   commons-graph.jar
   commons-io.jar
   commons-lang-0.1-dev.jar
  +commons-logging-1.0.jar
   commons-util-1.0-rc2-dev.jar
   commons-xo-1.0-dev.jar
   dom4j-1.3.jar
  
  
  
  1.67      +8 -0      jakarta-turbine-maven/project.xml
  
  Index: project.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-maven/project.xml,v
  retrieving revision 1.66
  retrieving revision 1.67
  diff -u -r1.66 -r1.67
  --- project.xml       23 Apr 2002 13:35:07 -0000      1.66
  +++ project.xml       25 Apr 2002 15:51:27 -0000      1.67
  @@ -33,6 +33,9 @@
     <siteDirectory>/www/jakarta.apache.org/turbine/maven/</siteDirectory>
     
<distributionDirectory>/www/jakarta.apache.org/builds/jakarta-turbine-maven/</distributionDirectory>
   
  +  <cvsRoot>:pserver:[EMAIL PROTECTED]:/home/cvspublic</cvsRoot>
  +  <cvsModule>jakarta-turbine-maven</cvsModule>
  +
     <distributions>
       <distribution>
         <id>b1</id>
  @@ -48,6 +51,11 @@
         <id>b3</id>
         <version>1.0-b3</version>
         <tag>MAVEN_1_0_B3</tag>
  +    </distribution>
  +    <distribution>
  +      <id>b4</id>
  +      <version>1.0-b4</version>
  +      <tag>HEAD</tag>
       </distribution>
     </distributions>
   
  
  
  
  1.29      +43 -4     
jakarta-turbine-maven/src/java/org/apache/maven/ProjectProperties.java
  
  Index: ProjectProperties.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/ProjectProperties.java,v
  retrieving revision 1.28
  retrieving revision 1.29
  diff -u -r1.28 -r1.29
  --- ProjectProperties.java    23 Apr 2002 01:52:50 -0000      1.28
  +++ ProjectProperties.java    25 Apr 2002 15:51:27 -0000      1.29
  @@ -68,6 +68,7 @@
   import org.apache.maven.ant.AntUtils;
   import org.apache.maven.executor.ProjectExecutor;
   import org.apache.maven.project.Dependency;
  +import org.apache.maven.project.Distribution;
   
   import org.apache.tools.ant.BuildException;
   import org.apache.tools.ant.types.Path;
  @@ -79,7 +80,7 @@
    * paths required to build the project.
    *
    * @author <a href="[EMAIL PROTECTED]">Jason van Zyl</a>
  - * @version $Id: ProjectProperties.java,v 1.28 2002/04/23 01:52:50 kaz Exp $
  + * @version $Id: ProjectProperties.java,v 1.29 2002/04/25 15:51:27 jvanzyl Exp $
    */
   public class ProjectProperties
       extends ProjectExecutor
  @@ -113,7 +114,9 @@
               "package",
               "url",
               "siteAddress",
  -            "siteDirectory"
  +            "siteDirectory",
  +            "cvsRoot",
  +            "cvsModule"
           };
           
           for (int i = 0; i < properties.length; i++)
  @@ -122,7 +125,8 @@
           } 
   
           createOrganizationProperties();
  -                
  +        createDistProperties();
  +        
           // Let the build process know that the POM has
           // been loaded.
           getProject().setProperty("pomLoaded","true");
  @@ -148,9 +152,32 @@
           }
   
           log("Creating source set reference ...");
  +                        
           createPathReference("src.set",
               getMavenProject().getBuild().getSourceDirectories());
   
  +        String mavenPrepareSourceDirectory = 
  +            getProject().getProperty("maven.prepareSourceDirectory");
  +        
  +        System.out.println("mpsd => " + mavenPrepareSourceDirectory);
  +        
  +        if (mavenPrepareSourceDirectory != null)
  +        {
  +            
AntUtils.createPatternSetReferenceFromPaths(getProject(),"src.set.patternset",
  +                getMavenProject().getBuild().getSourceDirectories());
  +
  +            Path srcSet = new Path(getProject());
  +            Path p = new Path(getProject());
  +            p.setPath(mavenPrepareSourceDirectory);
  +            srcSet.append(p);
  +            getProject().addReference("compile.src.set", srcSet);
  +        }
  +        else
  +        {
  +            createPathReference("compile.src.set",
  +                getMavenProject().getBuild().getSourceDirectories());
  +        }
  +        
           if 
(!Strings.isEmpty(getMavenProject().getBuild().getUnitTestSourceDirectory()))
           {
               File utdir = new File(getProject().getProperty("basedir"),
  @@ -162,7 +189,7 @@
   
                   log("Creating unit test class entries reference ...");
                   AntUtils.createPatternSetReference(getProject(),"unit.test.set",
  -                                          
getMavenProject().getBuild().getUnitTestPatterns());
  +                    getMavenProject().getBuild().getUnitTestPatterns());
               }
           }
   
  @@ -277,6 +304,18 @@
   
               getProject().setProperty( "maven.organization.url", 
                   getMavenProject().getOrganization().getUrl() );
  +        }
  +    }
  +
  +    private void createDistProperties()
  +    {
  +        String id = getProject().getProperty("distid");
  +        if (id != null)
  +        {
  +            Distribution d = (Distribution) 
  +                getMavenProject().getDistributionsMap().get(id);
  +            
  +            getProject().setProperty("tag", d.getTag());
           }
       }
   }
  
  
  
  1.3       +30 -1     
jakarta-turbine-maven/src/java/org/apache/maven/ant/AntUtils.java
  
  Index: AntUtils.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/ant/AntUtils.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- AntUtils.java     22 Apr 2002 00:15:04 -0000      1.2
  +++ AntUtils.java     25 Apr 2002 15:51:27 -0000      1.3
  @@ -67,7 +67,7 @@
    * sets of values.
    *
    * @author <a href="[EMAIL PROTECTED]">Jason van Zyl</a>
  - * @version $Id: AntUtils.java,v 1.2 2002/04/22 00:15:04 dion Exp $
  + * @version $Id: AntUtils.java,v 1.3 2002/04/25 15:51:27 jvanzyl Exp $
    */
   public class AntUtils
   {
  @@ -162,4 +162,33 @@
   
           project.addReference(reference, patternSet);
       }
  +
  +    /**
  +     * Create a file set reference in <code>project</code>, named
  +     * <code>reference</code> from the <code>list</code> of includes/excludes/
  +     * file names
  +     * @param project the Ant project to create the reference in
  +     * @param reference the name of the reference to create
  +     * @param list the list of paths
  +     *  a file name
  +     */
  +    public static void createFileSetReference(Project project, 
  +                                              String reference, 
  +                                              List list)
  +    {
  +        StringBuffer includesSb = new StringBuffer();
  +        PatternSet patternSet = new PatternSet();
  +
  +        for (Iterator i = list.iterator(); i.hasNext(); )
  +        {
  +            String line = (String) i.next();
  +            line = line.trim();
  +
  +            // We have a jar descriptor file
  +            includesSb.append(line).append("/**,");
  +        }
  +
  +        project.addReference(reference, patternSet);
  +    }
  +
   }
  
  
  
  1.4       +2 -1      jakarta-turbine-maven/src/java/org/apache/maven/project/Jar.java
  
  Index: Jar.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/project/Jar.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- Jar.java  24 Feb 2002 17:33:44 -0000      1.3
  +++ Jar.java  25 Apr 2002 15:51:28 -0000      1.4
  @@ -1,4 +1,5 @@
   package org.apache.maven.project;
  +
   /* ====================================================================
    * The Apache Software License, Version 1.1
    *
  @@ -55,7 +56,7 @@
   
   /**
    * @author <a href="mailto:[EMAIL PROTECTED]";>Jason van Zyl</a>
  - * @version $Id: Jar.java,v 1.3 2002/02/24 17:33:44 jvanzyl Exp $
  + * @version $Id: Jar.java,v 1.4 2002/04/25 15:51:28 jvanzyl Exp $
    */
   public class Jar
       extends BaseObject
  
  
  
  1.17      +24 -1     
jakarta-turbine-maven/src/java/org/apache/maven/project/Project.java
  
  Index: Project.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/project/Project.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- Project.java      23 Apr 2002 11:26:18 -0000      1.16
  +++ Project.java      25 Apr 2002 15:51:28 -0000      1.17
  @@ -55,11 +55,13 @@
    */
   
   import java.util.ArrayList;
  +import java.util.HashMap;
   import java.util.List;
  +import java.util.Map;
   
   /**
    * @author <a href="mailto:[EMAIL PROTECTED]";>Jason van Zyl</a>
  - * @version $Id: Project.java,v 1.16 2002/04/23 11:26:18 jvanzyl Exp $
  + * @version $Id: Project.java,v 1.17 2002/04/25 15:51:28 jvanzyl Exp $
    */
   public class Project
        extends BaseObject
  @@ -172,6 +174,12 @@
       private List distributions;
   
       /**
  +     * Distributions map that associates the distribution ids
  +     * with the distribution objects.
  +     */
  +    private HashMap distributionsMap;
  +
  +    /**
        * Default constructor.
        */
       public Project()
  @@ -180,6 +188,7 @@
           mailingLists = new ArrayList();
           developers = new ArrayList();
           distributions = new ArrayList();
  +        distributionsMap = new HashMap();
       }
   
       /**
  @@ -540,6 +549,10 @@
       public void addDistribution(Distribution distribution)
       {
           distributions.add(distribution);
  +        
  +        //System.out.println("!!!!!!!!!!!!!!! " + distribution.getId());
  +        
  +        //distributionsMap.put(distribution.getId(), distribution);
       }
   
       /**
  @@ -550,6 +563,16 @@
       public List getDistributions()
       {
           return distributions;
  +    }
  +
  +    /**
  +     * Return the distributions for this project.
  +     *
  +     * @return List of distributions.
  +     */
  +    public Map getDistributionsMap()
  +    {
  +        return distributionsMap;
       }
   
   }
  
  
  
  1.36      +138 -15   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.35
  retrieving revision 1.36
  diff -u -r1.35 -r1.36
  --- build-maven.xml   22 Apr 2002 20:25:06 -0000      1.35
  +++ build-maven.xml   25 Apr 2002 15:51:28 -0000      1.36
  @@ -14,8 +14,6 @@
   
       <mkdir dir="${build.dest}"/>
       <mkdir dir="${docs.dest}"/>
  -    <property name="distDir" value="${build.dir}/${final.name}"/>
  -    <mkdir dir="${distDir}"/>
   
     </target>
   
  @@ -147,12 +145,47 @@
     </target>
   
     <!-- ================================================================== -->
  +  <!-- P R E P A R E  S O U R C E S                                       -->
  +  <!-- ================================================================== -->
  +  
  +  <target
  +    name="prepare-sources"
  +    if="maven.prepareSourceDirectory">
  +    
  +    <echo>
  +      maven.prepareSourceDirectory = ${maven.prepareSourceDirectory}
  +    </echo>
  +    
  +    <mkdir dir="${maven.prepareSourceDirectory}"/>
  +    
  +    <!-- We need to do this here but we need to make a
  +         fileset reference to make this easier.
  +    -->
  +    
  +    <!--
  +    <copy todir="${build.dir}">
  +      <fileset dir=".">
  +        <patternset refid="src.set.patternset"/>
  +      </fileset>
  +    </copy>
  +    -->
  +    
  +    <ant 
  +      antfile="${maven.delegatorBuildFile}"
  +      target="${maven.prepareSourceTarget}"
  +    />
  +
  +    <touch file="${maven.prepareSourceDirectory}/PREPARED"/>
  +
  +  </target>
  +
  +  <!-- ================================================================== -->
     <!-- C O M P I L E                                                      -->
     <!-- ================================================================== -->
   
     <target
       name="compile"
  -    depends="javac.compile,aspectj.compile"
  +    depends="env,prepare-sources,javac.compile,aspectj.compile"
       description="o Compile project source code"/>
   
     <!-- ================================================================== -->
  @@ -162,7 +195,6 @@
     <target
       name="javac.compile"
       unless="build.includes.aspects"
  -    depends="env"
       description="o Compile project source code with javac">
   
       <javac
  @@ -172,7 +204,7 @@
         deprecation="${compile.deprecation}"
         optimize="${compile.optimize}">
         <src>
  -        <path refid="src.set"/>
  +        <path refid="compile.src.set"/>
         </src>
         <classpath>
           <path refid="classpath"/>
  @@ -188,7 +220,6 @@
     <target
       name="aspectj.compile"
       if="build.includes.aspects"
  -    depends="env"
       description="o Compile project source code with AspectJ compiler">
   
       <taskdef
  @@ -332,12 +363,12 @@
           <attribute name="Built-By" value="${user.name}"/>
           <!-- name should be '/' separated, not '.' -->
           <section name="${package}">
  -            <attribute name="Specification-Title" value="${id}"/>
  -            <attribute name="Specification-Version" value="${currentVersion}"/>
  -            <attribute name="Specification-Vendor" value="${organization}"/>
  -            <attribute name="Implementation-Title" value="${package}"/>
  -            <attribute name="Implementation-Version" value="${currentVersion}"/>
  -            <attribute name="Implementation-Vendor" value="${organization}"/>
  +          <attribute name="Specification-Title" value="${id}"/>
  +          <attribute name="Specification-Version" value="${currentVersion}"/>
  +          <attribute name="Specification-Vendor" value="${organization}"/>
  +          <attribute name="Implementation-Title" value="${package}"/>
  +          <attribute name="Implementation-Version" value="${currentVersion}"/>
  +          <attribute name="Implementation-Vendor" value="${organization}"/>
           </section>
         </manifest>
       </jar>
  @@ -347,12 +378,100 @@
     <!-- ================================================================== -->
     <!-- D I S T R I B U T I O N S                                          -->
     <!-- ================================================================== -->
  +  <!-- We want to be able to create distributions accurately by using     -->
  +  <!-- a repository identifier to extract a known set of sources from     -->
  +  <!-- the project's repository with which to create the distribution.    -->
  +  <!--                                                                    -->
  +  <!-- We use the ${maven.distBuildDirectory} to checkout a clean set     -->
  +  <!-- of sources denoted by ${tag} which must be specified on the        -->
  +  <!-- command line. After the sources have been checked out we proceed   -->
  +  <!-- to run the 'dist' target which will produce our distribution       -->
  +  <!-- deliverables with our fresh sources.                               -->
  +  <!--                                                                    -->
  +  <!-- You would use a command like the following to build a distribution -->
  +  <!-- for your project:                                                  -->
  +  <!--                                                                    -->   
  +  <!-- ant maven:dist -Dtag=MAVEN_B4                                      -->      
  +  <!-- ================================================================== -->
   
     <target
       name="dist"
  -    depends="jar,javadocs"
  +    if="distid">
  +    
  +    <antcall target="dist-checkout-sources"/>
  +    
  +  </target>
  +
  +  <target
  +    name="dist-checkout-sources"
  +    depends="local-init">
  +    
  +    <!-- 
  +    
  +    Make sure the dist directory is remove so that we know
  +    we are starting with a clean slate. We will also place a
  +    file in ${maven.distBuildDirectory} which indicates that
  +    it is ok to build a distribution within that directory.
  +    
  +    -->
  +    
  +    <delete dir="${maven.distBuildDirectory}"/>
  +    <mkdir dir="${maven.distBuildDirectory}/${cvsModule}"/>
  +    <touch 
file="${maven.distBuildDirectory}/${cvsModule}/${maven.distBuildIndicator}"/>
  +    
  +    <cvs
  +      cvsRoot="${cvsRoot}"
  +      package="${cvsModule}"
  +      dest="${maven.distBuildDirectory}"
  +      tag="${tag}"
  +    />
  +
  +    <!--
  +    
  +    Now that we have our freshly checked out sources we can use
  +    those sources to create our distribution.
  +    
  +    -->
  +    
  +    <ant 
  +      dir="${maven.distBuildDirectory}/${cvsModule}"
  +      target="maven:dist-build"
  +      inheritAll="false"
  +    />
  +    
  +    <!--
  +    
  +    The distributions have been created with fresh sources so
  +    lets move the distributions into a visible location and
  +    remove everything used to create the distributions so that
  +    no mistakes can be made unintentionally.
  +    
  +    -->
  +    
  +    <mkdir dir="${maven.distDirectory}"/>
  +    
  +    <copy todir="${maven.distDirectory}">
  +      <fileset dir="${maven.distBuildDirectory}/${cvsModule}/target">
  +        <include name="**/*.tar.gz"/>
  +        <include name="**/*.zip"/>
  +      </fileset>
  +    </copy>
  +
  +    <delete dir="${maven.distBuildDirectory}"/>
  +
  +  </target>
  +
  +  <target
  +    name="dist-build"
  +    depends="init"
       description="o Create source and binary distributions">
   
  +    <property name="distDir" value="${maven.distBuildDirectory}/${final.name}"/>
  +    <mkdir dir="${distDir}"/>
  +
  +    <antcall target="jar"/>
  +    <antcall target="javadocs"/>
  +
       <!-- B I N A R Y  D I S T R I B U T I O N -->
   
       <echo>
  @@ -365,7 +484,7 @@
       <copy todir="${distDir}" file="project.xml"/>
   
       <copy todir="${distDir}">
  -      <fileset dir=".">
  +      <fileset dir="${build.dir}">
           <include name="build-maven.xml"/>
           <include name="README.txt"/>
           <include name="LICENSE*.txt"/>
  @@ -393,7 +512,11 @@
         </tarfileset>
       </tar>
   
  -    <gzip zipfile="${build.dir}/${final.name}.tar.gz" 
src="${build.dir}/${final.name}.tar"/>
  +    <gzip 
  +      zipfile="${build.dir}/${final.name}.tar.gz" 
  +      src="${build.dir}/${final.name}.tar"
  +    />
  +    
       <delete file="${build.dir}/${final.name}.tar"/>
   
       <!-- Create a zip file -->
  
  
  
  1.25      +7 -0      jakarta-turbine-maven/src/templates/build/default.properties
  
  Index: default.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-maven/src/templates/build/default.properties,v
  retrieving revision 1.24
  retrieving revision 1.25
  diff -u -r1.24 -r1.25
  --- default.properties        22 Apr 2002 15:01:53 -0000      1.24
  +++ default.properties        25 Apr 2002 15:51:28 -0000      1.25
  @@ -111,3 +111,10 @@
   # -------------------------------------------------------------------
   # This needs to be changed before prime time.
   maven.updateSite = http://www.apache.org/~jvanzyl/maven/update
  +
  +# -------------------------------------------------------------------
  +# M A V E N  D I S T R I B U T I O N S
  +# -------------------------------------------------------------------
  +maven.distBuildDirectory = ${basedir}/target
  +maven.distBuildIndicator = DIST_BUILD_DIRECTORY
  +maven.distDirectory = ${basedir}/dist
  
  
  
  1.13      +5 -0      
jakarta-turbine-maven/src/test/org/apache/maven/project/ProjectMapperTest.java
  
  Index: ProjectMapperTest.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine-maven/src/test/org/apache/maven/project/ProjectMapperTest.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- ProjectMapperTest.java    23 Apr 2002 11:27:06 -0000      1.12
  +++ ProjectMapperTest.java    25 Apr 2002 15:51:28 -0000      1.13
  @@ -145,5 +145,10 @@
           assertEquals("b1", d0.getId());
           assertEquals("1.0-b1", d0.getVersion());
           assertEquals("MAVEN_1_0_B1", d0.getTag());
  +    
  +        Distribution d3 = (Distribution) p.getDistributionsMap().get("b4");
  +        //assertEquals("b4", d3.getId());
  +        //assertEquals("1.0-b4", d3.getVersion());
  +        //assertEquals("HEAD", d3.getTag());
       }
   }
  
  
  


Reply via email to