Author: jdcasey
Date: Mon Apr  3 15:49:47 2006
New Revision: 391163

URL: http://svn.apache.org/viewcvs?rev=391163&view=rev
Log:
[MNG-2196] Put back raw-project caching, to allow assemblyLineage(..) to use 
cached project data. Tests to follow...

Modified:
    
maven/components/branches/maven-2.0.x/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java
    
maven/components/branches/maven-2.0.x/maven-project/src/main/java/org/apache/maven/project/MavenProject.java

Modified: 
maven/components/branches/maven-2.0.x/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java
URL: 
http://svn.apache.org/viewcvs/maven/components/branches/maven-2.0.x/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java?rev=391163&r1=391162&r2=391163&view=diff
==============================================================================
--- 
maven/components/branches/maven-2.0.x/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java
 (original)
+++ 
maven/components/branches/maven-2.0.x/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java
 Mon Apr  3 15:49:47 2006
@@ -151,8 +151,10 @@
     private ProfileInjector profileInjector;
 
     private ModelValidator validator;
+    
+    private Map rawProjectCache = new HashMap();
 
-    private Map projectCache = new HashMap();
+    private Map processedProjectCache = new HashMap();
 
     // TODO: make it a component
     private MavenXpp3Reader modelReader;
@@ -213,7 +215,7 @@
     {
         String cacheKey = createCacheKey( artifact.getGroupId(), 
artifact.getArtifactId(), artifact.getVersion() );
 
-        MavenProject project = (MavenProject) projectCache.get( cacheKey );
+        MavenProject project = (MavenProject) processedProjectCache.get( 
cacheKey );
 
         if ( project != null )
         {
@@ -684,6 +686,8 @@
         }
 
         project.setOriginalModel( originalModel );
+        
+        rawProjectCache.put( createCacheKey( project.getGroupId(), 
project.getArtifactId(), project.getVersion() ), new MavenProject( project ) );
 
         // we don't have to force the collision exception for superModel here, 
it's already been done in getSuperModel()
         MavenProject previousProject = superProject;
@@ -741,7 +745,7 @@
             throw new InvalidProjectModelException( projectId, pomLocation, 
e.getMessage(), e );
         }
 
-        projectCache.put( createCacheKey( project.getGroupId(), 
project.getArtifactId(), project.getVersion() ), project );
+        processedProjectCache.put( createCacheKey( project.getGroupId(), 
project.getArtifactId(), project.getVersion() ), project );
 
         // jvz:note
         // this only happens if we are building from a source file
@@ -1009,7 +1013,17 @@
             File parentDescriptor = null;
 
             model = null;
-
+            
+            String parentKey = createCacheKey( parentModel.getGroupId(), 
parentModel.getArtifactId(), parentModel.getVersion() );
+            MavenProject parentProject = (MavenProject) rawProjectCache.get( 
parentKey );
+    
+            if ( parentProject != null )
+            {
+                model = ModelUtils.cloneModel( parentProject.getModel() );
+                
+                parentDescriptor = parentProject.getFile();
+            }
+            
             String parentRelativePath = parentModel.getRelativePath();
 
             // if we can't find a cached model matching the parent spec, then 
let's try to look on disk using

Modified: 
maven/components/branches/maven-2.0.x/maven-project/src/main/java/org/apache/maven/project/MavenProject.java
URL: 
http://svn.apache.org/viewcvs/maven/components/branches/maven-2.0.x/maven-project/src/main/java/org/apache/maven/project/MavenProject.java?rev=391163&r1=391162&r2=391163&view=diff
==============================================================================
--- 
maven/components/branches/maven-2.0.x/maven-project/src/main/java/org/apache/maven/project/MavenProject.java
 (original)
+++ 
maven/components/branches/maven-2.0.x/maven-project/src/main/java/org/apache/maven/project/MavenProject.java
 Mon Apr  3 15:49:47 2006
@@ -172,30 +172,71 @@
         {
             this.dependencyArtifacts = Collections.unmodifiableSet( 
project.dependencyArtifacts );
         }
+        
         if ( project.artifacts != null )
         {
             this.artifacts = Collections.unmodifiableSet( project.artifacts );
         }
-        this.pluginArtifacts = Collections.unmodifiableSet( 
project.pluginArtifacts );
-        this.reportArtifacts = Collections.unmodifiableSet( 
project.reportArtifacts );
-        this.extensionArtifacts = Collections.unmodifiableSet( 
project.extensionArtifacts );
+        
+        if ( project.pluginArtifacts != null )
+        {
+            this.pluginArtifacts = Collections.unmodifiableSet( 
project.pluginArtifacts );
+        }
+        
+        if ( project.reportArtifacts != null )
+        {
+            this.reportArtifacts = Collections.unmodifiableSet( 
project.reportArtifacts );
+        }        
+        
+        if ( project.extensionArtifacts != null )
+        {
+            this.extensionArtifacts = Collections.unmodifiableSet( 
project.extensionArtifacts );
+        }        
+        
         this.parentArtifact = project.parentArtifact;
 
-        this.remoteArtifactRepositories = Collections.unmodifiableList( 
project.remoteArtifactRepositories );
-        this.pluginArtifactRepositories = Collections.unmodifiableList( 
project.pluginArtifactRepositories );
-        this.collectedProjects = Collections.unmodifiableList( 
project.collectedProjects );
-        this.activeProfiles = Collections.unmodifiableList( 
project.activeProfiles );
-
-        // clone properties modifyable by plugins in a forked lifecycle
-        this.attachedArtifacts = new ArrayList( project.getAttachedArtifacts() 
);
-
-        // no need for execution project
-
-        // clone source roots
-        this.compileSourceRoots = new ArrayList( project.compileSourceRoots );
-        this.testCompileSourceRoots = new ArrayList( 
project.testCompileSourceRoots );
-        this.scriptSourceRoots = new ArrayList( project.scriptSourceRoots );
-
+        if ( project.remoteArtifactRepositories != null )
+        {
+            this.remoteArtifactRepositories = Collections.unmodifiableList( 
project.remoteArtifactRepositories );
+        }        
+        
+        if ( project.pluginArtifactRepositories != null )
+        {
+            this.pluginArtifactRepositories = Collections.unmodifiableList( 
project.pluginArtifactRepositories );
+        }        
+        
+        if ( project.collectedProjects != null )
+        {
+            this.collectedProjects = Collections.unmodifiableList( 
project.collectedProjects );
+        }        
+        
+        if ( project.activeProfiles != null )
+        {
+            this.activeProfiles = Collections.unmodifiableList( 
project.activeProfiles );
+        }        
+        
+        if ( project.getAttachedArtifacts() != null )
+        {
+            // clone properties modifyable by plugins in a forked lifecycle
+            this.attachedArtifacts = new ArrayList( 
project.getAttachedArtifacts() );
+        }        
+        
+        if ( project.compileSourceRoots != null )
+        {
+            // clone source roots
+            this.compileSourceRoots = new ArrayList( 
project.compileSourceRoots );
+        }        
+        
+        if ( project.testCompileSourceRoots != null )
+        {
+            this.testCompileSourceRoots = new ArrayList( 
project.testCompileSourceRoots );
+        }        
+        
+        if ( project.scriptSourceRoots != null )
+        {
+            this.scriptSourceRoots = new ArrayList( project.scriptSourceRoots 
);
+        }        
+        
         this.model = ModelUtils.cloneModel( project.model );
 
         if ( project.originalModel != null )
@@ -205,7 +246,10 @@
 
         this.executionRoot = project.executionRoot;
 
-        this.artifact = ArtifactUtils.copyArtifact( project.artifact );
+        if ( project.artifact != null )
+        {
+            this.artifact = ArtifactUtils.copyArtifact( project.artifact );
+        }        
     }
     
     public String getModulePathAdjustment( MavenProject moduleProject ) throws 
IOException
@@ -799,7 +843,14 @@
 
     public String getGroupId()
     {
-        return model.getGroupId();
+        String groupId = model.getGroupId();
+        
+        if ( groupId == null && model.getParent() != null )
+        {
+            groupId = model.getParent().getGroupId();
+        }
+        
+        return groupId;
     }
 
     public void setArtifactId( String artifactId )
@@ -837,7 +888,14 @@
 
     public String getVersion()
     {
-        return model.getVersion();
+        String version = model.getVersion();
+        
+        if ( version == null && model.getParent() != null )
+        {
+            version = model.getParent().getVersion();
+        }
+        
+        return version;
     }
 
     public String getPackaging()


Reply via email to