diff --git a/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java b/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java index 326dfb3b61..5fe8971e44 100644 --- a/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java +++ b/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java @@ -257,20 +257,7 @@ public class DefaultMavenProjectBuilder { request.setRemoteRepostories( new ArrayList() ); } - /* - if(project.getRemoteArtifactRepositories() == null) - { - try - { - System.out.println(convertToDomainModel(project.getModel(), true).asString()); - } - catch ( IOException e ) - { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - */ + ArtifactResolutionResult result = repositorySystem.resolve( request ); if ( result.hasExceptions() ) @@ -323,19 +310,21 @@ public class DefaultMavenProjectBuilder throw new ProjectBuildingException( projectId, "Failed to activate external profiles.", projectDescriptor, e ); } } - - try - { - PomClassicDomainModel dm = ProcessorContext.mergeProfilesIntoModel( projectProfiles, model, false ); - ProcessorContext.interpolateModelProperties( dm.getModelProperties(), - new ArrayList(), dm ); - dm = new PomClassicDomainModel( dm.getModelProperties(), false ); - model = dm.getModel(); - } - catch ( IOException e ) + if(!projectProfiles.isEmpty()) { + try + { + PomClassicDomainModel dm = ProcessorContext.mergeProfilesIntoModel( projectProfiles, model, false ); + ProcessorContext.interpolateModelProperties( dm.getModelProperties(), + new ArrayList(), dm ); + dm = new PomClassicDomainModel( dm.getModelProperties(), false ); + model = dm.getModel(); + } + catch ( IOException e ) + { - throw new ProjectBuildingException(projectId, "", projectDescriptor, e); + throw new ProjectBuildingException(projectId, "", projectDescriptor, e); + } } MavenProject project; diff --git a/maven-project/src/main/java/org/apache/maven/project/processor/ModelProcessor.java b/maven-project/src/main/java/org/apache/maven/project/processor/ModelProcessor.java index 9e3347fc15..53b1ef642c 100644 --- a/maven-project/src/main/java/org/apache/maven/project/processor/ModelProcessor.java +++ b/maven-project/src/main/java/org/apache/maven/project/processor/ModelProcessor.java @@ -21,7 +21,9 @@ package org.apache.maven.project.processor; import java.util.ArrayList; import java.util.Collection; +import java.util.HashMap; import java.util.List; +import java.util.Map; import org.apache.maven.model.Dependency; import org.apache.maven.model.DependencyManagement; @@ -43,7 +45,7 @@ public class ModelProcessor public void process( Object parent, Object child, Object target, boolean isChildMostSpecialized ) { super.process( parent, child, target, isChildMostSpecialized ); - + Model c = (Model) child; Model t = (Model) target; Model p = null; @@ -151,6 +153,5 @@ public class ModelProcessor } t.getDependencyManagement().getDependencies().addAll( mngDeps ); } - } } diff --git a/maven-project/src/main/java/org/apache/maven/project/processor/PluginProcessor.java b/maven-project/src/main/java/org/apache/maven/project/processor/PluginProcessor.java index 333dc64c4a..b4f8562404 100644 --- a/maven-project/src/main/java/org/apache/maven/project/processor/PluginProcessor.java +++ b/maven-project/src/main/java/org/apache/maven/project/processor/PluginProcessor.java @@ -189,7 +189,7 @@ public class PluginProcessor //TODO: Not copying if(target.getConfiguration() != null) { - target.setConfiguration( Xpp3Dom.mergeXpp3Dom( (Xpp3Dom) source.getConfiguration(), (Xpp3Dom) target.getConfiguration() )); + target.setConfiguration( Xpp3Dom.mergeXpp3Dom( (Xpp3Dom) source.getConfiguration(), (Xpp3Dom) target.getConfiguration() )); } else { diff --git a/maven-project/src/main/java/org/apache/maven/project/processor/PluginsManagementProcessor.java b/maven-project/src/main/java/org/apache/maven/project/processor/PluginsManagementProcessor.java index 4749cb53ab..54933be710 100644 --- a/maven-project/src/main/java/org/apache/maven/project/processor/PluginsManagementProcessor.java +++ b/maven-project/src/main/java/org/apache/maven/project/processor/PluginsManagementProcessor.java @@ -44,7 +44,7 @@ public class PluginsManagementProcessor extends BaseProcessor { for(Plugin targetDep : targetPlugin) { //PluginManagement is first in ordering - if(match(depMng, targetDep)) + if(match(depMng, targetDep) ) { copy(depMng, targetDep ); } diff --git a/maven-project/src/main/java/org/apache/maven/project/processor/ProcessorContext.java b/maven-project/src/main/java/org/apache/maven/project/processor/ProcessorContext.java index d1239d2ed0..e6eb0fa9cb 100644 --- a/maven-project/src/main/java/org/apache/maven/project/processor/ProcessorContext.java +++ b/maven-project/src/main/java/org/apache/maven/project/processor/ProcessorContext.java @@ -251,12 +251,14 @@ public class ProcessorContext } // Plugin Management + PluginsManagementProcessor procMng = new PluginsManagementProcessor(); if ( target.getBuild() != null && target.getBuild().getPluginManagement() != null) { procMng.process( null, new ArrayList( target.getBuild().getPluginManagement().getPlugins() ), target.getBuild().getPlugins(), true ); } + return target; } diff --git a/maven-project/src/test/java/org/apache/maven/project/PomConstructionTest.java b/maven-project/src/test/java/org/apache/maven/project/PomConstructionTest.java index d0ba3d5eff..86901baa3c 100644 --- a/maven-project/src/test/java/org/apache/maven/project/PomConstructionTest.java +++ b/maven-project/src/test/java/org/apache/maven/project/PomConstructionTest.java @@ -258,7 +258,6 @@ public class PomConstructionTest throws Exception { PomTestWrapper pom = buildPom( "equal-plugin-exec-ids" ); - System.out.println(pom.getDomainModel().asString()); assertEquals( "maven-it-plugin-a", pom.getValue( "build/plugins[1]/artifactId" ) ); assertEquals( 1, ( (List) pom.getValue( "build/plugins[1]/executions" ) ).size() ); assertEquals( "maven-it-plugin-b", pom.getValue( "build/plugins[2]/artifactId" ) ); @@ -498,7 +497,7 @@ public class PomConstructionTest throws Exception { PomTestWrapper pom = buildPom( "merged-plugin-class-path-order/wo-plugin-mngt/sub" ); - System.out.println(pom.getDomainModel().asString()); + assertEquals( 5, ( (List) pom.getValue( "build/plugins[1]/dependencies" ) ).size() ); assertNotNull( pom.getValue( "build/plugins[1]/dependencies[1]" )); assertEquals( "c", pom.getValue( "build/plugins[1]/dependencies[1]/artifactId" ) ); @@ -627,7 +626,7 @@ public class PomConstructionTest throws Exception { PomTestWrapper pom = buildPom( "unprefixed-expression-interpolation/child" ); - System.out.println(pom.getDomainModel().asString()); + assertEquals( pom.getBasedir(), new File( pom.getValue( "properties/projectDir" ).toString() ) ); assertEquals( "org.apache.maven.its.mng3831.child", pom.getValue( "properties/projectGroupId" ) ); @@ -761,11 +760,12 @@ public class PomConstructionTest assertEquals( "PASSED-4", pom.getValue( prefix + "listParam/listParam[4]" ) ); } - /* FIXME: MNG-2591 + /* FIXME: MNG-2591*/ public void testAppendOfInheritedPluginConfiguration() throws Exception { PomTestWrapper pom = buildPom( "plugin-config-append/subproject" ); + String prefix = "build/plugins[1]/configuration/"; assertEquals( "PARENT-1", pom.getValue( prefix + "stringParams/stringParam[1]" ) ); assertEquals( "PARENT-3", pom.getValue( prefix + "stringParams/stringParam[2]" ) );