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/05/23 04:09:30 UTC

cvs commit: maven-new/core/src/java/org/apache/maven/project/builder DefaultProjectBuilder.java DefaultProjectUnmarshaller.java DependencyClasspathBuilder.java

jvanzyl     2003/05/22 19:09:30

  Modified:    core/src/java/org/apache/maven/project/builder
                        DefaultProjectBuilder.java
                        DefaultProjectUnmarshaller.java
                        DependencyClasspathBuilder.java
  Log:
  o removing the use of the old artifact factory and using michal's new one.
  
  Revision  Changes    Path
  1.7       +32 -55    maven-new/core/src/java/org/apache/maven/project/builder/DefaultProjectBuilder.java
  
  Index: DefaultProjectBuilder.java
  ===================================================================
  RCS file: /home/cvs/maven-new/core/src/java/org/apache/maven/project/builder/DefaultProjectBuilder.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- DefaultProjectBuilder.java	20 May 2003 14:24:50 -0000	1.6
  +++ DefaultProjectBuilder.java	23 May 2003 02:09:30 -0000	1.7
  @@ -1,8 +1,13 @@
   package org.apache.maven.project.builder;
   
  +import org.apache.avalon.framework.service.ServiceException;
  +import org.apache.avalon.framework.service.ServiceManager;
  +import org.apache.avalon.framework.service.Serviceable;
   import org.apache.maven.MavenConstants;
  +import org.apache.maven.artifact.factory.ArtifactFactory;
   import org.apache.maven.project.Project;
   import org.apache.maven.util.CollectionUtils;
  +import org.apache.plexus.logging.AbstractLogEnabled;
   import org.apache.plexus.util.DirectoryScanner;
   import org.apache.plexus.util.StringUtils;
   
  @@ -21,14 +26,16 @@
   import java.util.Set;
   
   public class DefaultProjectBuilder
  -    implements ProjectBuilder
  +    extends AbstractLogEnabled
  +    implements Serviceable, ProjectBuilder
   {
       /** POM Unmarshaller */
       private ProjectUnmarshaller projectUnmarshaller;
  +    /** Artifact Factory. */
  +    private ArtifactFactory artifactFactory;
   
       public DefaultProjectBuilder()
       {
  -        projectUnmarshaller = new DefaultProjectUnmarshaller();
       }
   
       public Project build( File projectDescriptor )
  @@ -43,40 +50,15 @@
           return build( projectDescriptor, parent, true );
       }
   
  -    /**
  -     * Create a Project object given a file descriptor and optionally a parent Jelly
  -     * context. We are doing several things when creating a POM object, the phases
  -     * are outlined here:
  -     *
  -     * 1) The project.xml file is read in using betwixt which creates for us a
  -     *    Project object that, at this point, has not been run through Jelly i.e.
  -     *    no interpolation has occured yet.
  -     *
  -     * 2) The context for the project is created and set. So each project manages its
  -     *    own context. See the createContext() method for the details context creation
  -     *    process.
  -     *
  -     * 3) We check to see if the <extend> tag is being employed. If so, the parent
  -     *    project.xml file is read in. At this point we have a child and parent POM
  -     *    and the values are merged where the child's values override those of the
  -     *    parent.
  -     *
  -     * 4) The POM we have at this point is then processed through Jelly.
  -     *
  -     * 5) The project is handed the reference to the File that was used to create
  -     *    the project itself.
  -     *
  -     * @param projectDescriptor a maven project.xml {@link java.io.File}
  -     * @return the MavenSession project object for the given project descriptor
  -     * @throws java.lang.Exception when any errors occur
  -     */
       public Project build( File projectDescriptor,
                             Project rootProject,
                             boolean useParentPom )
           throws Exception
       {
  -        // Need to state the difference between the root project and the
  -        // parent project.
  +        if ( projectDescriptor == null )
  +        {
  +            throw new IllegalStateException( "The projectDescriptor cannot be null: " + projectDescriptor );
  +        }
   
           // 1)
           Project project = projectUnmarshaller.parse( new FileReader( projectDescriptor ) );
  @@ -95,7 +77,7 @@
               // <extend>${basedir}/../project.xml</extend>
               pomToExtend = StringUtils.interpolate( pomToExtend, propertiesMap );
   
  -            File parentPom = findParentPom( pomToExtend );
  +            File parentPom = new File( pomToExtend );
   
               if ( parentPom.exists() )
               {
  @@ -126,28 +108,6 @@
           return project;
       }
   
  -    // Now there is a mismatch between how POMs are laid out of parent->child projects
  -    // where they are developed and how the POMs are laid out in the local repository.
  -    // I believe this is indicitive of a very large oversight in that this mismatch makes
  -    // it very difficult to actually find anything in a known manner.
  -    //
  -    // In my particular case I am traversing a set of POMs to build a plexus runtime
  -    // and the POMs as they are deployed make reference to a parent POM in a directory
  -    // above using the standard .. notation. Once all the POMs are deployed they are in
  -    // the same directory and thus the mismatch bites you in the ass.
  -    //
  -    // So we either:
  -    // 1) push the info about the mismatch into the system
  -    // 2) allow a search when retrieving the child POM so that we can bounce up a directory
  -    // 3) completely align the repo hiearchy with the development hiearchy.
  -    //
  -    // In the long-term 3) is probably the best option, but for now I will probably implement 2).
  -    //
  -    File findParentPom( String parentPom )
  -    {
  -        return new File( parentPom );
  -    }
  -
       /**
        * This is currently used for the reactor but may be generally useful.
        *
  @@ -211,8 +171,10 @@
        * Build the artifact list.
        */
       public void buildArtifactList( Project project )
  +        throws Exception
       {
  -        project.setArtifacts( ArtifactListBuilder.build( project ) );
  +        //project.setArtifacts( ArtifactListBuilder.build( project ) );
  +        project.setArtifacts( artifactFactory.createArtifacts(project) );
       }
   
       /**
  @@ -434,6 +396,8 @@
           // Set the basedir value in the context.
           result.put( "basedir", descriptorDirectory.getPath() );
   
  +        System.out.println( "maven.repo.local = " + result.get( "maven.repo.local" ) );
  +
           return result;
       }
   
  @@ -492,4 +456,17 @@
   
           return null;
       }
  +
  +    // ----------------------------------------------------------------------
  +    // Lifecylce Management
  +    // ----------------------------------------------------------------------
  +
  +    /** @see Serviceable#service */
  +    public void service( ServiceManager serviceManager )
  +        throws ServiceException
  +    {
  +        projectUnmarshaller = (ProjectUnmarshaller) serviceManager.lookup( ProjectUnmarshaller.ROLE );
  +        artifactFactory = (ArtifactFactory) serviceManager.lookup( ArtifactFactory.ROLE );
  +    }
   }
  +
  
  
  
  1.6       +3 -2      maven-new/core/src/java/org/apache/maven/project/builder/DefaultProjectUnmarshaller.java
  
  Index: DefaultProjectUnmarshaller.java
  ===================================================================
  RCS file: /home/cvs/maven-new/core/src/java/org/apache/maven/project/builder/DefaultProjectUnmarshaller.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- DefaultProjectUnmarshaller.java	20 May 2003 13:57:32 -0000	1.5
  +++ DefaultProjectUnmarshaller.java	23 May 2003 02:09:30 -0000	1.6
  @@ -26,7 +26,8 @@
   public class DefaultProjectUnmarshaller
       implements ProjectUnmarshaller
   {
  -    public Project parse( Reader reader ) throws Exception
  +    public Project parse( Reader reader )
  +        throws Exception
       {
           Project project = new Project();
   
  
  
  
  1.5       +2 -2      maven-new/core/src/java/org/apache/maven/project/builder/DependencyClasspathBuilder.java
  
  Index: DependencyClasspathBuilder.java
  ===================================================================
  RCS file: /home/cvs/maven-new/core/src/java/org/apache/maven/project/builder/DependencyClasspathBuilder.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- DependencyClasspathBuilder.java	20 May 2003 13:56:52 -0000	1.4
  +++ DependencyClasspathBuilder.java	23 May 2003 02:09:30 -0000	1.5
  @@ -58,7 +58,7 @@
   
   import org.apache.maven.project.Dependency;
   import org.apache.maven.project.Project;
  -import org.apache.maven.repository.Artifact;
  +import org.apache.maven.artifact.Artifact;
   
   import java.util.Iterator;
   
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org