[MNG-2174] Profile bug dealing with dependencies : [MNG-3877] Reporting directory base aligned.

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@742594 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Britton Isbell 2009-02-09 16:10:48 +00:00
parent 2f8742ae19
commit 778f044ed9
7 changed files with 113 additions and 11 deletions

View File

@ -306,6 +306,7 @@ public final class PomClassicDomainModel
s.add(ProjectUri.Reporting.Plugins.Plugin.ReportSets.xUri);
s.add(ProjectUri.Reporting.Plugins.Plugin.ReportSets.ReportSet.configuration);
s.add(ProjectUri.Build.Plugins.Plugin.Executions.Execution.configuration);
s.add(ProjectUri.Profiles.Profile.Build.Plugins.Plugin.configuration);//TODO: More profile info
modelProperties = ModelMarshaller.marshallXmlToModelProperties(
getInputStream(), ProjectUri.baseUri, s );
}

View File

@ -213,14 +213,29 @@ public class DefaultProjectBuilder
PomClassicDomainModel domainModel = new PomClassicDomainModel( pom );
domainModel.setProjectDirectory( pom.getParentFile() );
List<DomainModel> domainModels = new ArrayList<DomainModel>();
domainModels.add( domainModel );
ProfileContext profileContext = new ProfileContext(new DefaultModelDataSource(domainModel.getModelProperties(),
PomTransformer.MODEL_CONTAINER_FACTORIES), activeProfileIds, properties);
Collection<ModelContainer> profileContainers = profileContext.getActiveProfiles();
//get mixin
List<DomainModel> domainModels = new ArrayList<DomainModel>();
domainModels.add( domainModel );
Collection<ModelContainer> profileContainers = profileContext.getActiveProfiles();
for(ModelContainer mc : profileContainers)
{
List<ModelProperty> transformed = new ArrayList<ModelProperty>();
transformed.add(new ModelProperty(ProjectUri.xUri, null));
for(ModelProperty mp : mc.getProperties())
{
if(mp.getUri().startsWith(ProjectUri.Profiles.Profile.xUri) && !mp.getUri().equals(ProjectUri.Profiles.Profile.id)
&& !mp.getUri().startsWith(ProjectUri.Profiles.Profile.Activation.xUri) )
{
transformed.add(new ModelProperty(mp.getUri().replace(ProjectUri.Profiles.Profile.xUri, ProjectUri.xUri),
mp.getResolvedValue()));
}
}
domainModels.add(new PomClassicDomainModel(transformed));
}
File parentFile = null;
int lineageCount = 0;

View File

@ -22,10 +22,7 @@ package org.apache.maven.project.builder;
import java.io.File;
import java.io.IOException;
import java.io.FileInputStream;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Arrays;
import java.util.*;
import org.apache.maven.MavenTools;
import org.apache.maven.profiles.DefaultProfileManager;
@ -186,7 +183,7 @@ public class PomConstructionTest
public void testParentInterpolation()
throws Exception
{
PomTestWrapper pom = buildPomFromMavenProject( "parent-interpolation/sub" );
PomTestWrapper pom = buildPomFromMavenProject( "parent-interpolation/sub", null );
pom = new PomTestWrapper(pom.getMavenProject().getParent());
assertEquals( "1.3.0-SNAPSHOT", pom.getValue( "build/plugins[1]/version" ) );
}
@ -200,6 +197,27 @@ public class PomConstructionTest
assertEquals( "1.0-alpha-21", pom.getValue( "build/plugins[1]/version" ) );
}
/* MNG-2174*/
public void testPluginManagementDependencies()
throws Exception
{
PomTestWrapper pom = buildPomFromMavenProject( "plugin-management-dependencies/sub", "test" );
assertEquals( "1.0-alpha-21", pom.getValue( "build/plugins[1]/version" ) );
assertEquals( "1.0", pom.getValue( "build/plugins[1]/dependencies[1]/version" ) );
}
/* MNG-3877*/
public void testReportingInterpolation()
throws Exception
{
PomTestWrapper pom = buildPomFromMavenProject( "reporting-interpolation", null );
pom = new PomTestWrapper(pom.getMavenProject());
assertEquals( System.getProperty("user.dir")
+ "/src/test/resources-project-builder/reporting-interpolation/target/site",
pom.getValue( "reporting/outputDirectory" ) );
}
public void testPluginOrder()
throws Exception
{
@ -824,7 +842,7 @@ public class PomConstructionTest
return new PomTestWrapper( pomFile, projectBuilder.buildModel( pomFile, null, pomArtifactResolver ) );
}
private PomTestWrapper buildPomFromMavenProject( String pomPath )
private PomTestWrapper buildPomFromMavenProject( String pomPath, String profileId )
throws IOException
{
File pomFile = new File( testDirectory , pomPath );
@ -835,7 +853,11 @@ public class PomConstructionTest
ProjectBuilderConfiguration config = new DefaultProjectBuilderConfiguration();
config.setLocalRepository(new DefaultArtifactRepository("default", "", new DefaultRepositoryLayout()));
ProfileActivationContext pCtx = new DefaultProfileActivationContext(null, true);
pCtx.setExplicitlyActiveProfileIds(Arrays.asList("release"));
if(profileId != null)
{
pCtx.setExplicitlyActiveProfileIds(Arrays.asList(profileId));
}
config.setGlobalProfileManager(new DefaultProfileManager(this.getContainer(), pCtx));
return new PomTestWrapper( pomFile, projectBuilder.buildFromLocalPath( pomFile, null, null, pomArtifactResolver,
config, mavenProjectBuilder ) );

View File

@ -121,6 +121,15 @@ public class PomTestWrapper
public PomClassicDomainModel getDomainModel()
{
if(domainModel == null && mavenProject != null)
{
try {
return new PomClassicDomainModel(mavenProject.getModel());
} catch (IOException e) {
}
}
return this.domainModel;
}

View File

@ -0,0 +1,24 @@
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>gid</groupId>
<artifactId>aid</artifactId>
<version>1.0</version>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.codehaus.modello</groupId>
<artifactId>modello-maven-plugin</artifactId>
<version>1.0-alpha-21</version>
<dependencies>
<dependency>
<groupId>a</groupId>
<artifactId>b</artifactId>
<version>1.0</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>

View File

@ -0,0 +1,25 @@
<project>
<parent>
<groupId>gid</groupId>
<artifactId>aid</artifactId>
<version>1.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>org.sonatype.nexus</groupId>
<artifactId>nexus</artifactId>
<version>1.3.0-SNAPSHOT</version>
<profiles>
<profile>
<id>test</id>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.modello</groupId>
<artifactId>modello-maven-plugin</artifactId>
<version>1.0-alpha-21</version>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>

View File

@ -0,0 +1,6 @@
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>gid</groupId>
<artifactId>aid</artifactId>
<version>1.0</version>
</project>