maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sisb...@apache.org
Subject svn commit: r766833 - in /maven/components/trunk: maven-core/src/main/java/org/apache/maven/ maven-project/src/main/java/org/apache/maven/project/
Date Mon, 20 Apr 2009 19:51:57 GMT
Author: sisbell
Date: Mon Apr 20 19:51:57 2009
New Revision: 766833

URL: http://svn.apache.org/viewvc?rev=766833&view=rev
Log:
Support for specifying pom file on command line. The builder now checks (in order): 1) top-level
maven project from config matches build pom parent; 2) relative path pom; 2) repository pom.

Modified:
    maven/components/trunk/maven-core/src/main/java/org/apache/maven/DefaultMaven.java
    maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java
    maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/DefaultProjectBuilderConfiguration.java
    maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/ProjectBuilderConfiguration.java

Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/DefaultMaven.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/java/org/apache/maven/DefaultMaven.java?rev=766833&r1=766832&r2=766833&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/DefaultMaven.java (original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/DefaultMaven.java Mon
Apr 20 19:51:57 2009
@@ -282,6 +282,7 @@
                 if ( isRoot )
                 {
                     project.setExecutionRoot( true );
+                    request.getProjectBuildingConfiguration().setTopLevelProjectForReactor(project);
                 }
 
                 if ( ( project.getPrerequisites() != null ) && ( project.getPrerequisites().getMaven()
!= null ) )

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=766833&r1=766832&r2=766833&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
Mon Apr 20 19:51:57 2009
@@ -42,7 +42,6 @@
 import org.apache.maven.model.PomClassicDomainModel;
 import org.apache.maven.model.ProcessorContext;
 import org.apache.maven.model.Profile;
-import org.apache.maven.model.interpolator.DefaultInterpolator;
 import org.apache.maven.model.interpolator.Interpolator;
 import org.apache.maven.model.interpolator.InterpolatorProperty;
 import org.apache.maven.model.interpolator.PomInterpolatorTag;
@@ -81,9 +80,6 @@
     private RepositorySystem repositorySystem;
 
     @Requirement
-    private PlexusContainer container;
-
-    @Requirement
     List<ModelEventListener> listeners;
     
     @Requirement
@@ -460,9 +456,14 @@
             if ( domainModel.getParentId() != null )
             {
             	List<DomainModel> mavenParents;
-            	if ( isParentLocal( domainModel.getRelativePathOfParent(), pomFile.getParentFile()
) )
+            	MavenProject topProject = projectBuilderConfiguration.getTopLevelProjectFromReactor();
+            	if(useTopLevelProjectForParent(domainModel, topProject) )
+            	{
+            		mavenParents = getDomainModelParentsFromLocalPath( domainModel, localRepository,
remoteRepositories, topProject.getFile(), projectBuilderConfiguration );
+            	}
+            	else if ( isParentLocal( domainModel.getRelativePathOfParent(), pomFile.getParentFile()
) )
             	{
-            		mavenParents = getDomainModelParentsFromLocalPath( domainModel, localRepository,
remoteRepositories, pomFile.getParentFile() );
+            		mavenParents = getDomainModelParentsFromLocalPath( domainModel, localRepository,
remoteRepositories, pomFile.getParentFile(), projectBuilderConfiguration );
             	}
             	else
             	{
@@ -513,11 +514,23 @@
 
             // Lineage count is inclusive to add the POM read in itself.
             transformedDomainModel.setLineageCount( lineageCount + 1 );
-            Model m = transformedDomainModel.getModel();
             transformedDomainModel.setParentFile( parentFile );
 
             return transformedDomainModel;
     }
+    
+    private static boolean useTopLevelProjectForParent(PomClassicDomainModel currentModel,
MavenProject topProject) throws IOException
+    {
+    	if(topProject == null || currentModel.getModel().getParent() == null)
+    	{
+    		return false;
+    	}
+
+    	return topProject.getGroupId().equals(currentModel.getParentGroupId()) 
+    	&& topProject.getArtifactId().equals(currentModel.getParentArtifactId()) 
+    	&& topProject.getVersion().equals(currentModel.getParentVersion());
+    	
+    }
 
     private void validateModel( Model model, File pomFile )
         throws InvalidProjectModelException
@@ -646,7 +659,7 @@
      * @throws IOException
      */
     private List<DomainModel> getDomainModelParentsFromLocalPath( PomClassicDomainModel
domainModel, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories,
-                                                                  File projectDirectory )
+                                                                  File projectDirectory,
ProjectBuilderConfiguration projectBuilderConfiguration )
         throws IOException
     {
         List<DomainModel> domainModels = new ArrayList<DomainModel>();
@@ -663,15 +676,23 @@
         {
             parentFile = new File( parentFile.getAbsolutePath(), "pom.xml" );
         }
-
-        if ( !parentFile.isFile() )
+    	MavenProject topProject = projectBuilderConfiguration.getTopLevelProjectFromReactor();
+    	boolean isTop = useTopLevelProjectForParent(domainModel, topProject);
+    	PomClassicDomainModel parentDomainModel = null;
+        if ( !isTop  )
+        {
+        	if(!parentFile.isFile())
+        	{
+        		throw new IOException( "File does not exist: File = " + parentFile.getAbsolutePath()
);	
+        	}     
+        	parentDomainModel = new PomClassicDomainModel( parentFile );
+        	parentDomainModel.setProjectDirectory( parentFile.getParentFile() );
+        }
+        else
         {
-            throw new IOException( "File does not exist: File = " + parentFile.getAbsolutePath()
);
+        	parentDomainModel = new PomClassicDomainModel(projectBuilderConfiguration.getTopLevelProjectFromReactor().getFile());
         }
 
-        PomClassicDomainModel parentDomainModel = new PomClassicDomainModel( parentFile );
-        parentDomainModel.setProjectDirectory( parentFile.getParentFile() );
-
         if ( !parentDomainModel.matchesParentOf( domainModel ) )
         {
             logger.info( "Parent pom ids do not match: Parent File = " + parentFile.getAbsolutePath()
+ ", Parent ID = " + parentDomainModel.getId() + ", Child ID = " + domainModel.getId()
@@ -691,9 +712,20 @@
         domainModels.add( parentDomainModel );
         if ( domainModel.getParentId() != null )
         {
-            if ( isParentLocal( parentDomainModel.getRelativePathOfParent(), parentFile.getParentFile()
) )
+        	if(isTop)
+        	{
+        		 if ( isParentLocal( parentDomainModel.getRelativePathOfParent(), parentFile.getParentFile()
) )
+                 {
+        			 domainModels.addAll( getDomainModelParentsFromLocalPath( parentDomainModel, localRepository,
remoteRepositories, topProject.getFile(), projectBuilderConfiguration ) );
+                 }
+                 else
+                 {
+                     domainModels.addAll( getDomainModelParentsFromRepository( parentDomainModel,
localRepository, remoteRepositories ) );
+                 }       		
+        	}
+        	else if ( isParentLocal( parentDomainModel.getRelativePathOfParent(), parentFile.getParentFile()
) )
             {
-                domainModels.addAll( getDomainModelParentsFromLocalPath( parentDomainModel,
localRepository, remoteRepositories, parentFile.getParentFile() ) );
+                domainModels.addAll( getDomainModelParentsFromLocalPath( parentDomainModel,
localRepository, remoteRepositories, parentFile.getParentFile(), projectBuilderConfiguration
) );
             }
             else
             {

Modified: maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/DefaultProjectBuilderConfiguration.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/DefaultProjectBuilderConfiguration.java?rev=766833&r1=766832&r2=766833&view=diff
==============================================================================
--- maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/DefaultProjectBuilderConfiguration.java
(original)
+++ maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/DefaultProjectBuilderConfiguration.java
Mon Apr 20 19:51:57 2009
@@ -44,6 +44,18 @@
     private Date buildStartTime;
 
     private List<ModelEventListener> listeners;
+    
+    private MavenProject topProject;
+    
+    public MavenProject getTopLevelProjectFromReactor()
+    {
+    	return topProject;
+    }
+    
+    public void setTopLevelProjectForReactor(MavenProject mavenProject)
+    {
+    	this.topProject = mavenProject;
+    }
         
     public ProjectBuilderConfiguration setGlobalProfileManager( ProfileManager globalProfileManager
)
     {

Modified: maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/ProjectBuilderConfiguration.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/ProjectBuilderConfiguration.java?rev=766833&r1=766832&r2=766833&view=diff
==============================================================================
--- maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/ProjectBuilderConfiguration.java
(original)
+++ maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/ProjectBuilderConfiguration.java
Mon Apr 20 19:51:57 2009
@@ -32,4 +32,8 @@
     Date getBuildStartTime();
 
     ProjectBuilderConfiguration setBuildStartTime( Date buildStartTime );    
+    
+    MavenProject getTopLevelProjectFromReactor();
+    
+    void setTopLevelProjectForReactor(MavenProject mavenProject);
 }



Mime
View raw message