You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by jv...@apache.org on 2003/01/01 16:21:37 UTC

cvs commit: jakarta-turbine-maven/src/java/org/apache/maven/jelly/tags/maven MavenTag.java ReactorTag.java

jvanzyl     2003/01/01 07:21:36

  Modified:    src/java/org/apache/maven/jelly/tags/maven MavenTag.java
                        ReactorTag.java
  Log:
  o The <maven:maven/> tag no long requires the basedir specified, we'll just
    take the parent directory of the specified descriptor. Deprecated the
    basedir attribute in the MavenTag and moved the attribute to the ReactorTag.
  
  Revision  Changes    Path
  1.2       +5 -22     jakarta-turbine-maven/src/java/org/apache/maven/jelly/tags/maven/MavenTag.java
  
  Index: MavenTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/jelly/tags/maven/MavenTag.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- MavenTag.java	31 Dec 2002 07:01:10 -0000	1.1
  +++ MavenTag.java	1 Jan 2003 15:21:36 -0000	1.2
  @@ -59,7 +59,6 @@
   import org.apache.commons.jelly.MissingAttributeException;
   import org.apache.commons.jelly.XMLOutput;
   import org.apache.maven.MavenUtils;
  -import org.apache.maven.MavenSession;
   import org.apache.maven.jelly.tags.BaseTagSupport;
   import org.apache.maven.project.Project;
   
  @@ -74,6 +73,8 @@
    * @version $Id$
    *
    * @todo get rid of 'throws Exception'
  + * @todo grab the default goal from the specified project if a goal is not provided.
  + * @todo we only need the full path to the descriptor, we don't need the basedir.
    */
   public class MavenTag
       extends BaseTagSupport
  @@ -81,9 +82,6 @@
       /** maven project descriptor */
       private File descriptor;
   
  -    /** project base directory */
  -    private File basedir;
  -
       /** goals to verify */
       private String goals;
   
  @@ -101,11 +99,6 @@
       public void doTag( XMLOutput output )
           throws Exception
       {
  -        if ( getBasedir() == null )
  -        {
  -            throw new MissingAttributeException( "basedir" );
  -        }
  -
           if ( getDescriptor() == null )
           {
               throw new MissingAttributeException( "descriptor" );
  @@ -114,7 +107,7 @@
           try
           {
               Project project = MavenUtils.getProject( getDescriptor(),
  -                                                          getMavenContext().getMavenSession().getRootContext() );
  +                                                     getMavenContext().getMavenSession().getRootContext() );
               project.setGoalNames( getGoals() );
               getMavenContext().getMavenSession().attainGoals( project );
           }
  @@ -164,17 +157,7 @@
        */
       public void setBasedir( File basedir )
       {
  -        this.basedir = basedir;
  -    }
  -
  -    /**
  -     * Getter for the basedir property
  -     *
  -     * @return the base directory for execution of the project
  -     */
  -    public File getBasedir()
  -    {
  -        return this.basedir;
  +        System.out.println("\nDEPRECATION WARNING: you no longer need to specify the basedir attribute.\n");
       }
   
       /**
  
  
  
  1.4       +109 -85   jakarta-turbine-maven/src/java/org/apache/maven/jelly/tags/maven/ReactorTag.java
  
  Index: ReactorTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/jelly/tags/maven/ReactorTag.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ReactorTag.java	1 Jan 2003 03:10:30 -0000	1.3
  +++ ReactorTag.java	1 Jan 2003 15:21:36 -0000	1.4
  @@ -66,6 +66,7 @@
   import java.util.ArrayList;
   import java.util.Iterator;
   import java.util.List;
  +import java.io.File;
   
   /**
    * Reactor tag that processes a set of project descriptors taking into
  @@ -106,6 +107,9 @@
       /** Banner to display when each project is processed. */
       private String banner;
   
  +    /** project base directory */
  +    private File basedir;
  +
       /**
        * Post processing flag. If this is set then we will hold on to the
        * processed projects, otherwise they will be dumped.
  @@ -115,97 +119,29 @@
       /** Storage for processed projects. */
       private ArrayList reactorProjects = new ArrayList();
   
  +    // ----------------------------------------------------------------------
  +    // A C C E S S O R S
  +    // ----------------------------------------------------------------------
  +
       /**
  -     *  Execute the body of the reactor tag.
  +     * Setter for the basedir property
        *
  -     * @param output The output sink.
  -     * @throws Exception If an error occurs while processing the tag.
  +     * @param basedir the base directory for execution of the project
        */
  -    public void doTag( XMLOutput output )
  -        throws Exception
  +    public void setBasedir( File basedir )
       {
  -        if ( getBasedir() == null )
  -        {
  -            throw new MissingAttributeException( "basedir" );
  -        }
  -
  -        if ( getGlob() == null && getIncludes() == null )
  -        {
  -            throw new MissingAttributeException( "glob|includes" );
  -        }
  -
  -        String projectIncludes;
  -        if ( getGlob() != null )
  -        {
  -            projectIncludes = getGlob();
  -        }
  -        else
  -        {
  -            projectIncludes = getIncludes();
  -        }
  -
  -        //!! Need to think about the root context for the reactor projects.
  -
  -        List projects = MavenUtils.getProjects( getBasedir(),
  -                                                projectIncludes,
  -                                                getExcludes(),
  -                                                getMavenContext().getMavenSession().getRootContext() );
  -
  -        DependencyResolver dr = new DependencyResolver();
  -        dr.setProjects( projects );
  -        List sortedProjects = dr.getSortedDependencies( false );
  -
  -        System.out.println( "Our processing order:" );
  -        for ( Iterator i = sortedProjects.iterator(); i.hasNext(); )
  -        {
  -            Project p = (Project) i.next();
  -            System.out.println( p.getName() );
  -        }
  -
  -        for ( Iterator i = sortedProjects.iterator(); i.hasNext(); )
  -        {
  -            try
  -            {
  -                // The basedir needs to be set for the project
  -                // We just need the descriptor.
  -
  -                Project project = (Project) i.next();
  -
  -                System.out.println( "+----------------------------------------" );
  -                System.out.println( "| " + getBanner() + " " + project.getName() );
  -                System.out.println( "+----------------------------------------" );
  -
  -                project.setGoalNames( getGoals() );
  -                getMavenContext().getMavenSession().attainGoals( project );
  -
  -                if ( getPostProcessing() )
  -                {
  -                    reactorProjects.add( project );
  -                }
  -                else
  -                {
  -                    project = null;
  -                }
  -            }
  -            catch ( Exception e )
  -            {
  -                if ( getIgnoreFailures() )
  -                {
  -                    continue;
  -                }
  -
  -                e.fillInStackTrace();
  -
  -                throw e;
  -            }
  -        }
  -
  -        getMavenContext().getMavenSession().getRootContext().setVariable("reactorProjects", reactorProjects);
  +        this.basedir = basedir;
       }
   
  -    // ------------------------------------------------------------
  -    // A C C E S S O R S
  -    // ------------------------------------------------------------
  +    /**
  +     * Getter for the basedir property
  +     *
  +     * @return the base directory for execution of the project
  +     */
  +    public File getBasedir()
  +    {
  +        return this.basedir;
  +    }
   
       /**
        * Set the postProcessing attribute.
  @@ -313,5 +249,93 @@
           }
   
           return banner;
  +    }
  +
  +    /**
  +     *  Execute the body of the reactor tag.
  +     *
  +     * @param output The output sink.
  +     * @throws Exception If an error occurs while processing the tag.
  +     */
  +    public void doTag( XMLOutput output )
  +        throws Exception
  +    {
  +        if ( getBasedir() == null )
  +        {
  +            throw new MissingAttributeException( "basedir" );
  +        }
  +
  +        if ( getGlob() == null && getIncludes() == null )
  +        {
  +            throw new MissingAttributeException( "glob|includes" );
  +        }
  +
  +        String projectIncludes;
  +        if ( getGlob() != null )
  +        {
  +            projectIncludes = getGlob();
  +        }
  +        else
  +        {
  +            projectIncludes = getIncludes();
  +        }
  +
  +        //!! Need to think about the root context for the reactor projects.
  +
  +        List projects = MavenUtils.getProjects( getBasedir(),
  +                                                projectIncludes,
  +                                                getExcludes(),
  +                                                getMavenContext().getMavenSession().getRootContext() );
  +
  +        DependencyResolver dr = new DependencyResolver();
  +        dr.setProjects( projects );
  +        List sortedProjects = dr.getSortedDependencies( false );
  +
  +        System.out.println( "Our processing order:" );
  +        for ( Iterator i = sortedProjects.iterator(); i.hasNext(); )
  +        {
  +            Project p = (Project) i.next();
  +            System.out.println( p.getName() );
  +        }
  +
  +        for ( Iterator i = sortedProjects.iterator(); i.hasNext(); )
  +        {
  +            try
  +            {
  +                // The basedir needs to be set for the project
  +                // We just need the descriptor.
  +
  +                Project project = (Project) i.next();
  +
  +                System.out.println( "+----------------------------------------" );
  +                System.out.println( "| " + getBanner() + " " + project.getName() );
  +                System.out.println( "+----------------------------------------" );
  +
  +                project.setGoalNames( getGoals() );
  +                getMavenContext().getMavenSession().attainGoals( project );
  +
  +                if ( getPostProcessing() )
  +                {
  +                    reactorProjects.add( project );
  +                }
  +                else
  +                {
  +                    project = null;
  +                }
  +            }
  +            catch ( Exception e )
  +            {
  +                if ( getIgnoreFailures() )
  +                {
  +                    continue;
  +                }
  +
  +                e.fillInStackTrace();
  +
  +                throw e;
  +            }
  +        }
  +
  +        getMavenContext().getMavenSession().getRootContext().setVariable("reactorProjects", reactorProjects);
       }
   }