maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sisb...@apache.org
Subject svn commit: r768421 - in /maven/components/trunk: maven-mercury/src/main/java/org/apache/maven/mercury/ maven-model-builder/src/main/java/org/apache/maven/model/ maven-project/src/main/java/org/apache/maven/project/ maven-project/src/test/java/org/apac...
Date Fri, 24 Apr 2009 21:33:00 GMT
Author: sisbell
Date: Fri Apr 24 21:32:57 2009
New Revision: 768421

URL: http://svn.apache.org/viewvc?rev=768421&view=rev
Log:
Now we do interpolation before management processing. This allow depMng/pluginMng to have
interpolated values for group/artifact ids.

Added:
    maven/components/trunk/maven-project/src/test/resources-project-builder/dependency-management-with-interpolation/
    maven/components/trunk/maven-project/src/test/resources-project-builder/dependency-management-with-interpolation/pom.xml
    maven/components/trunk/maven-project/src/test/resources-project-builder/dependency-management-with-interpolation/sub/
    maven/components/trunk/maven-project/src/test/resources-project-builder/dependency-management-with-interpolation/sub/pom.xml
Modified:
    maven/components/trunk/maven-mercury/src/main/java/org/apache/maven/mercury/MavenDependencyProcessor.java
    maven/components/trunk/maven-mercury/src/main/java/org/apache/maven/mercury/MavenDomainModel.java
    maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/ProcessorContext.java
    maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java
    maven/components/trunk/maven-project/src/test/java/org/apache/maven/project/PomConstructionTest.java

Modified: maven/components/trunk/maven-mercury/src/main/java/org/apache/maven/mercury/MavenDependencyProcessor.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-mercury/src/main/java/org/apache/maven/mercury/MavenDependencyProcessor.java?rev=768421&r1=768420&r2=768421&view=diff
==============================================================================
--- maven/components/trunk/maven-mercury/src/main/java/org/apache/maven/mercury/MavenDependencyProcessor.java
(original)
+++ maven/components/trunk/maven-mercury/src/main/java/org/apache/maven/mercury/MavenDependencyProcessor.java
Fri Apr 24 21:32:57 2009
@@ -119,7 +119,7 @@
             }
             iModels.get(0).setMostSpecialized(true);
                 	
-			return new MavenDomainModel(ProcessorContext.build(iModels, null)).getDependencyMetadata();
+			return new MavenDomainModel( ProcessorContext.processManagementNodes(ProcessorContext.build(iModels,
null).getModel() )  ).getDependencyMetadata();
 		} catch (IOException e) {
 			throw new DependencyProcessorException(e);
 		}

Modified: maven/components/trunk/maven-mercury/src/main/java/org/apache/maven/mercury/MavenDomainModel.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-mercury/src/main/java/org/apache/maven/mercury/MavenDomainModel.java?rev=768421&r1=768420&r2=768421&view=diff
==============================================================================
--- maven/components/trunk/maven-mercury/src/main/java/org/apache/maven/mercury/MavenDomainModel.java
(original)
+++ maven/components/trunk/maven-mercury/src/main/java/org/apache/maven/mercury/MavenDomainModel.java
Fri Apr 24 21:32:57 2009
@@ -27,6 +27,7 @@
 import org.apache.maven.mercury.artifact.ArtifactMetadata;
 import org.apache.maven.model.Dependency;
 import org.apache.maven.model.Exclusion;
+import org.apache.maven.model.Model;
 import org.apache.maven.model.Parent;
 import org.apache.maven.model.PomClassicDomainModel;
 
@@ -54,6 +55,12 @@
     	super(model.getModel());
     }    
     
+    public MavenDomainModel(Model model) 
+		throws IOException
+	{
+		super(model);
+	}    
+  
     public boolean hasParent()
     {
         return getParentMetadata() != null;

Modified: maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/ProcessorContext.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/ProcessorContext.java?rev=768421&r1=768420&r2=768421&view=diff
==============================================================================
--- maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/ProcessorContext.java
(original)
+++ maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/ProcessorContext.java
Fri Apr 24 21:32:57 2009
@@ -251,6 +251,14 @@
                 }
             }           
         }
+ 
+        return target;
+      
+    }
+    
+    public static Model processManagementNodes(Model target) 
+    	throws IOException
+    {
 
         // Dependency Management
         DependencyManagementProcessor depProc = new DependencyManagementProcessor();
@@ -261,16 +269,14 @@
         }
         
         // Plugin Management      
-
         PluginsManagementProcessor procMng = new PluginsManagementProcessor();
         if ( target.getBuild() != null && target.getBuild().getPluginManagement()
!= null)
         {
             procMng.process( null, new ArrayList<Plugin>( target.getBuild().getPluginManagement().getPlugins()
),
                               target.getBuild().getPlugins(), true );
         }
-        
-        return target;
-      
+
+        return target;    	
     }
 
     public static Profile copyOfProfile(Profile profile)

Modified: maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java?rev=768421&r1=768420&r2=768421&view=diff
==============================================================================
--- maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java
(original)
+++ maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java
Fri Apr 24 21:32:57 2009
@@ -160,14 +160,22 @@
     		}
     		        	
             domainModel = ProcessorContext.mergeProfilesIntoModel( externalProfiles, domainModel
);
+            
         }
         catch ( IOException e )
         {
             throw new ProjectBuildingException("", "");
         }
         
-		//Interpolation
-        MavenProject project = interpolateDomainModel( domainModel, configuration, pomFile
);
+        //Interpolation & Management
+        MavenProject project;
+		try {
+			Model model = ProcessorContext.processManagementNodes(interpolateDomainModel( domainModel,
configuration, pomFile ));
+			project = this.fromDomainModelToMavenProject(model, domainModel.getParentFile(), configuration,
pomFile);
+		} catch (IOException e) {
+			throw new ProjectBuildingException("", "");
+		}
+		
         project.setActiveProfiles( projectProfiles );
          
         Build build = project.getBuild();
@@ -269,7 +277,14 @@
         {
             throw new ProjectBuildingException("", "");
         }
-        project = interpolateDomainModel( domainModel, configuration, artifact.getFile()
);
+       
+    		try {
+    			Model model = ProcessorContext.processManagementNodes(interpolateDomainModel( domainModel,
configuration, artifact.getFile() ));
+    			project = this.fromDomainModelToMavenProject(model, domainModel.getParentFile(), configuration,
artifact.getFile());
+    		} catch (IOException e) {
+    			throw new ProjectBuildingException("", "");
+    		}
+
         project.setActiveProfiles( projectProfiles );
         artifact.setFile( artifact.getFile() );
         project.setVersion( artifact.getVersion() );
@@ -368,7 +383,7 @@
         return new MavenProjectBuildingResult( project, result );
     }
     
-    private MavenProject interpolateDomainModel( PomClassicDomainModel domainModel, ProjectBuilderConfiguration
config, File projectDescriptor )
+    private Model interpolateDomainModel( PomClassicDomainModel domainModel, ProjectBuilderConfiguration
config, File projectDescriptor )
         throws ProjectBuildingException
     {
     	Model model;
@@ -403,9 +418,15 @@
                 throw new ProjectBuildingException(projectId, "", projectDescriptor, e);
             }  
             
+       return model;
 
+    }
+    
+    private MavenProject fromDomainModelToMavenProject(Model model, File parentFile, ProjectBuilderConfiguration
config, File projectDescriptor)
+    	throws InvalidProjectModelException, IOException
+    {
         MavenProject project;
-
+        String projectId = safeVersionlessKey( model.getGroupId(), model.getArtifactId()
);
         try
         {
             project = new MavenProject( model, repositorySystem, this, config );
@@ -415,7 +436,7 @@
             Artifact projectArtifact = repositorySystem.createArtifact( project.getGroupId(),
project.getArtifactId(), project.getVersion(), null, project.getPackaging() );
             project.setArtifact( projectArtifact );
 
-            project.setParentFile( domainModel.getParentFile() );
+            project.setParentFile( parentFile );
 
         }
         catch ( InvalidRepositoryException e )
@@ -423,7 +444,7 @@
             throw new InvalidProjectModelException( projectId, e.getMessage(), projectDescriptor,
e );
         }
 
-        return project;
+        return project;   	
     }
     
     private PomClassicDomainModel build( String projectId, File pomFile, ProjectBuilderConfiguration
projectBuilderConfiguration )

Modified: maven/components/trunk/maven-project/src/test/java/org/apache/maven/project/PomConstructionTest.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-project/src/test/java/org/apache/maven/project/PomConstructionTest.java?rev=768421&r1=768420&r2=768421&view=diff
==============================================================================
--- maven/components/trunk/maven-project/src/test/java/org/apache/maven/project/PomConstructionTest.java
(original)
+++ maven/components/trunk/maven-project/src/test/java/org/apache/maven/project/PomConstructionTest.java
Fri Apr 24 21:32:57 2009
@@ -1419,13 +1419,23 @@
 	    assertNull("Scope not null: " + scope, scope);
 	    System.out.println(pom.getDomainModel().asString());
 	
-	}    
+	}   
+    
     public void testDependencyScope()
 	    throws Exception
 	{
 	    PomTestWrapper pom = buildPom( "dependency-scope/sub" );
-	    System.out.println(pom.getDomainModel().asString());	
-	}      
+	 //   System.out.println(pom.getDomainModel().asString());	
+	}   
+ 
+    //This will fail on a validation error if incorrect
+    public void testDependencyManagementWithInterpolation()
+	    throws Exception
+	{
+	    PomTestWrapper pom = buildPom( "dependency-management-with-interpolation/sub" );
+	}   
+    
+    
     private void assertPathSuffixEquals( String expected, Object actual )
     {
         String a = actual.toString();

Added: maven/components/trunk/maven-project/src/test/resources-project-builder/dependency-management-with-interpolation/pom.xml
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-project/src/test/resources-project-builder/dependency-management-with-interpolation/pom.xml?rev=768421&view=auto
==============================================================================
--- maven/components/trunk/maven-project/src/test/resources-project-builder/dependency-management-with-interpolation/pom.xml
(added)
+++ maven/components/trunk/maven-project/src/test/resources-project-builder/dependency-management-with-interpolation/pom.xml
Fri Apr 24 21:32:57 2009
@@ -0,0 +1,19 @@
+<project>
+  <modelVersion>4.0.0</modelVersion>
+
+  <artifactId>asm-parent</artifactId>
+  <groupId>asm</groupId>
+  <version>3.0</version>
+  <packaging>pom</packaging>
+
+  <dependencyManagement>
+    <dependencies>
+      <dependency>
+        <artifactId>asm-util</artifactId>
+        <groupId>${project.groupId}</groupId>
+        <version>${project.version}</version>
+      </dependency>
+    </dependencies>
+  </dependencyManagement>
+
+</project>

Added: maven/components/trunk/maven-project/src/test/resources-project-builder/dependency-management-with-interpolation/sub/pom.xml
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-project/src/test/resources-project-builder/dependency-management-with-interpolation/sub/pom.xml?rev=768421&view=auto
==============================================================================
--- maven/components/trunk/maven-project/src/test/resources-project-builder/dependency-management-with-interpolation/sub/pom.xml
(added)
+++ maven/components/trunk/maven-project/src/test/resources-project-builder/dependency-management-with-interpolation/sub/pom.xml
Fri Apr 24 21:32:57 2009
@@ -0,0 +1,17 @@
+<?xml version="1.0"?><project>
+  <parent>
+    <artifactId>asm-parent</artifactId>
+    <groupId>asm</groupId>
+    <version>3.0</version>
+  </parent>
+  <modelVersion>4.0.0</modelVersion>
+
+  <artifactId>asm-xml</artifactId>
+  <version>3.0</version>
+  <dependencies>
+    <dependency>
+      <groupId>asm</groupId>
+      <artifactId>asm-util</artifactId>
+    </dependency>
+  </dependencies>
+</project>
\ No newline at end of file



Mime
View raw message