maven-m2-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject cvs commit: maven-components/maven-core/src/main/java/org/apache/maven/project DefaultMavenProjectBuilder.java MavenProjectBuilder.java
Date Wed, 16 Mar 2005 06:56:03 GMT
brett       2005/03/15 22:56:03

  Modified:    maven-core/src/main/java/org/apache/maven/artifact
                        MavenMetadataSource.java
               maven-core/src/main/java/org/apache/maven/project
                        DefaultMavenProjectBuilder.java
                        MavenProjectBuilder.java
  Log:
  project cache repairs - must not cache models that are already interpolated, translated,
etc.
  
  Revision  Changes    Path
  1.22      +5 -6      maven-components/maven-core/src/main/java/org/apache/maven/artifact/MavenMetadataSource.java
  
  Index: MavenMetadataSource.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/artifact/MavenMetadataSource.java,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- MavenMetadataSource.java	16 Mar 2005 05:08:50 -0000	1.21
  +++ MavenMetadataSource.java	16 Mar 2005 06:56:03 -0000	1.22
  @@ -75,12 +75,11 @@
   
               if ( mavenProjectBuilder != null )
               {
  -                MavenProject project = mavenProjectBuilder.getCachedProject( artifact.getGroupId(),
  -                                                                             artifact.getArtifactId(),
  -                                                                             artifact.getVersion()
);
  -                if ( project != null )
  +                Model model = mavenProjectBuilder.getCachedModel( artifact.getGroupId(),
artifact.getArtifactId(),
  +                                                                  artifact.getVersion()
);
  +                if ( model != null )
                   {
  -                    dependencies = project.getDependencies();
  +                    dependencies = model.getDependencies();
                   }
               }
   
  
  
  
  1.52      +34 -19    maven-components/maven-core/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java
  
  Index: DefaultMavenProjectBuilder.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java,v
  retrieving revision 1.51
  retrieving revision 1.52
  diff -u -r1.51 -r1.52
  --- DefaultMavenProjectBuilder.java	16 Mar 2005 06:29:35 -0000	1.51
  +++ DefaultMavenProjectBuilder.java	16 Mar 2005 06:56:03 -0000	1.52
  @@ -83,7 +83,7 @@
   
       private ArtifactRepositoryFactory artifactRepositoryFactory;
   
  -    private final Map projectCache = new HashMap();
  +    private final Map modelCache = new HashMap();
   
       public void initialize()
       {
  @@ -151,7 +151,15 @@
                                                 boolean resolveDependencies, boolean sourceProject
)
           throws ProjectBuildingException, ModelInterpolationException, ArtifactResolutionException
       {
  -        Model model = modelInterpolator.interpolate( project.getModel() );
  +        Model model = project.getModel();
  +        String key = createCacheKey( model.getGroupId(), model.getArtifactId(), model.getVersion()
);
  +        Model cachedModel = (Model) modelCache.get( key );
  +        if ( cachedModel == null || sourceProject )
  +        {
  +            modelCache.put( key, model );
  +        }
  +
  +        model = modelInterpolator.interpolate( model );
   
           // interpolation is before injection, because interpolation is off-limits in the
injected variables
           modelDefaultsInjector.injectDefaults( model );
  @@ -169,13 +177,6 @@
           project.setParent( parentProject );
           project.setArtifacts( artifactFactory.createArtifacts( project.getDependencies(),
localRepository, null ) );
   
  -        String key = createCacheKey( project.getGroupId(), project.getArtifactId(), project.getVersion()
);
  -        MavenProject cachedProject = (MavenProject) projectCache.get( key );
  -        if ( cachedProject == null || sourceProject )
  -        {
  -            projectCache.put( key, project );
  -        }
  -
           // ----------------------------------------------------------------------
           // Typically when the project builder is being used from maven proper
           // the transitive dependencies will not be resolved here because this
  @@ -200,7 +201,7 @@
               project.getArtifacts().addAll( result.getArtifacts().values() );
           }
   
  -        ModelValidationResult validationResult = validator.validate( project.getModel()
);
  +        ModelValidationResult validationResult = validator.validate( model );
   
           if ( validationResult.getMessageCount() > 0 )
           {
  @@ -219,14 +220,22 @@
           throws ProjectBuildingException
       {
           Model model = readModel( projectDescriptor );
  +        MavenProject project = assembleLineage( model, localRepository, lineage, aggregatedRemoteWagonRepositories
);
  +        project.setFile( projectDescriptor );
  +
  +        return project;
   
  +    }
  +
  +    private MavenProject assembleLineage( Model model, ArtifactRepository localRepository,
LinkedList lineage,
  +                                          List aggregatedRemoteWagonRepositories )
  +        throws ProjectBuildingException
  +    {
           MavenProject project = new MavenProject( model );
   
           lineage.addFirst( project );
   
  -        project.setFile( projectDescriptor );
  -
  -        Parent parentModel = model.getParent();
  +        Parent parentModel = project.getModel().getParent();
   
           if ( parentModel != null )
           {
  @@ -252,16 +261,22 @@
               // as we go in order to do this.
               // ----------------------------------------------------------------------
   
  -            aggregatedRemoteWagonRepositories.addAll( buildArtifactRepositories( model.getRepositories()
) );
  +            aggregatedRemoteWagonRepositories.addAll(
  +                buildArtifactRepositories( project.getModel().getRepositories() ) );
   
  -            MavenProject parent = getCachedProject( parentModel.getGroupId(), parentModel.getArtifactId(),
  -                                                    parentModel.getVersion() );
  -            if ( parent == null )
  +            MavenProject parent;
  +            Model cachedModel = getCachedModel( parentModel.getGroupId(), parentModel.getArtifactId(),
  +                                                parentModel.getVersion() );
  +            if ( cachedModel == null )
               {
                   File parentPom = findParentModel( parentModel, aggregatedRemoteWagonRepositories,
localRepository );
   
                   parent = assembleLineage( parentPom, localRepository, lineage, aggregatedRemoteWagonRepositories
);
               }
  +            else
  +            {
  +                parent = assembleLineage( cachedModel, localRepository, lineage, aggregatedRemoteWagonRepositories
);
  +            }
               project.setParent( parent );
           }
   
  @@ -352,9 +367,9 @@
           return artifact.getFile();
       }
   
  -    public MavenProject getCachedProject( String groupId, String artifactId, String version
)
  +    public Model getCachedModel( String groupId, String artifactId, String version )
       {
  -        return (MavenProject) projectCache.get( createCacheKey( groupId, artifactId, version
) );
  +        return (Model) modelCache.get( createCacheKey( groupId, artifactId, version ) );
       }
   
       private static String createCacheKey( String groupId, String artifactId, String version
)
  
  
  
  1.14      +2 -1      maven-components/maven-core/src/main/java/org/apache/maven/project/MavenProjectBuilder.java
  
  Index: MavenProjectBuilder.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/project/MavenProjectBuilder.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- MavenProjectBuilder.java	16 Mar 2005 05:08:50 -0000	1.13
  +++ MavenProjectBuilder.java	16 Mar 2005 06:56:03 -0000	1.14
  @@ -19,6 +19,7 @@
   
   import org.apache.maven.artifact.Artifact;
   import org.apache.maven.artifact.repository.ArtifactRepository;
  +import org.apache.maven.model.Model;
   
   import java.io.File;
   
  @@ -38,5 +39,5 @@
       MavenProject buildSuperProject( ArtifactRepository localRepository )
           throws ProjectBuildingException;
   
  -    MavenProject getCachedProject( String groupId, String artifactId, String version );
  +    Model getCachedModel( String groupId, String artifactId, String version );
   }
  
  
  

Mime
View raw message