Fixed a number of element ordering problems. Matches up with latest model-builder. Suppoert for tagging elements with orginal pom id.

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@750701 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Britton Isbell 2009-03-06 00:23:35 +00:00
parent 5a35fc9aee
commit 3a2c55315c
10 changed files with 58 additions and 70 deletions

View File

@ -322,6 +322,27 @@ public class PomClassicDomainModel implements InputStreamDomainModel
modelProperties = ModelMarshaller.marshallXmlToModelProperties( modelProperties = ModelMarshaller.marshallXmlToModelProperties(
getInputStream(), ProjectUri.baseUri, s ); getInputStream(), ProjectUri.baseUri, s );
String artifactId = null, groupId = null, version = null;//TODO Expand to full projectId
for(ModelProperty mp : modelProperties)
{
if( mp.getUri().equals(ProjectUri.artifactId))
{
artifactId = mp.getResolvedValue();
}
else if( mp.getUri().equals(ProjectUri.groupId))
{
groupId = mp.getResolvedValue();
}
else if (mp.getUri().equals(ProjectUri.version))
{
version = mp.getResolvedValue();
}
}
for(ModelProperty mp : modelProperties)
{
mp.setTag(groupId + ":" + artifactId + ":" + version);
}
} }
return new ArrayList<ModelProperty>(modelProperties); return new ArrayList<ModelProperty>(modelProperties);
} }

View File

@ -269,7 +269,7 @@ public class PomTransformer
if(b.containerAction(c).equals(ModelContainerAction.JOIN)) if(b.containerAction(c).equals(ModelContainerAction.JOIN))
{ {
//MNG-3995 - property lost here //MNG-3995 - property lost here
joinedContainers.addAll(source.join(b, c).getProperties()); joinedContainers.addAll(source.joinWithOriginalOrder(b, c).getProperties());
joinedExecutionContainers.add(a); joinedExecutionContainers.add(a);
} }
} }
@ -361,10 +361,9 @@ public class PomTransformer
new AlwaysJoinModelContainerFactory())); new AlwaysJoinModelContainerFactory()));
for(ModelContainer es : executionSource.queryFor( ProjectUri.Build.Plugins.Plugin.Executions.Execution.xUri )) { for(ModelContainer es : executionSource.queryFor( ProjectUri.Build.Plugins.Plugin.Executions.Execution.xUri )) {
ExecutionRule rule = new ExecutionRule(); ExecutionRule rule = new ExecutionRule();
// List<ModelProperty> x = rule.execute(es.getProperties()); System.out.println("----");
List<ModelProperty> x = !aContainsAnyOfB(es.getProperties(), joinedContainers) ? rule.execute(es.getProperties()) : List<ModelProperty> x = !aContainsAnyOfB(es.getProperties(), joinedContainers) ? es.getProperties() :
ModelTransformerContext.sort(rule.execute(es.getProperties()), rule.execute(es.getProperties());
ProjectUri.Build.Plugins.Plugin.Executions.Execution.xUri);
dataSource.replace(es, es.createNewInstance(x)); dataSource.replace(es, es.createNewInstance(x));
} }
@ -411,7 +410,6 @@ public class PomTransformer
p.add(mp); p.add(mp);
} }
} }
return factory.createDomainModel( p ); return factory.createDomainModel( p );
} }

View File

@ -150,6 +150,10 @@ public final class ArtifactModelContainerFactory
} }
else else
{ {
for(ModelProperty mp1 : properties)
{
System.out.println("----" + mp1);
}
throw new IllegalArgumentException( "Properties do not contain group id. Artifact ID = " throw new IllegalArgumentException( "Properties do not contain group id. Artifact ID = "
+ artifactId + ", Version = " + version ); + artifactId + ", Version = " + version );
} }

View File

@ -31,11 +31,11 @@ public class DependencyManagementDataSourceRule implements DataSourceRule
for(ModelContainer mc : exclusionContainers) for(ModelContainer mc : exclusionContainers)
{ {
for(ModelContainer mc1 : exclusionContainers) for(ModelContainer mc1 : exclusionContainers.subList(exclusionContainers.indexOf(mc) + 1, exclusionContainers.size()))
{ {
if(!mc.equals(mc1) && mc.containerAction(mc1).equals(ModelContainerAction.JOIN)) if(!mc.equals(mc1) && mc.containerAction(mc1).equals(ModelContainerAction.JOIN))
{ {
exclusionSource.joinWithOriginalOrder(mc1, mc); exclusionSource.join(mc1, mc);
} }
} }
} }

View File

@ -15,6 +15,7 @@ public class ExecutionRule implements ModelContainerRule {
List<ModelProperty> processedProperties = new ArrayList<ModelProperty>(); List<ModelProperty> processedProperties = new ArrayList<ModelProperty>();
for(ModelProperty mp : properties) { for(ModelProperty mp : properties) {
System.out.println("1 - " + mp);
if(mp.getUri().equals(ProjectUri.Build.Plugins.Plugin.Executions.Execution.Goals.goal)) { if(mp.getUri().equals(ProjectUri.Build.Plugins.Plugin.Executions.Execution.Goals.goal)) {
goalProperties.add(mp); goalProperties.add(mp);
} else if(mp.getUri().equals(ProjectUri.Build.Plugins.Plugin.Executions.Execution.Goals.xURI)) { } else if(mp.getUri().equals(ProjectUri.Build.Plugins.Plugin.Executions.Execution.Goals.xURI)) {
@ -36,25 +37,21 @@ public class ExecutionRule implements ModelContainerRule {
} else { } else {
x = true; x = true;
} }
} }
} }
processedProperties.removeAll(c); processedProperties.removeAll(c);
if(!goalProperties.isEmpty()) { if(!goalProperties.isEmpty()) {
Collections.reverse(goalProperties);
List<ModelProperty> uniqueGoals = new ArrayList<ModelProperty>(); List<ModelProperty> uniqueGoals = new ArrayList<ModelProperty>();
for(ModelProperty mp : goalProperties) { for(ModelProperty mp : goalProperties) {
if(!containsProperty(mp, uniqueGoals)) { if(!containsProperty(mp, uniqueGoals)) {
uniqueGoals.add(mp); uniqueGoals.add(mp);
} }
} }
Collections.reverse(uniqueGoals); // Collections.reverse(uniqueGoals);
processedProperties.addAll( processedProperties.addAll(
findIndexOf(ProjectUri.Build.Plugins.Plugin.Executions.Execution.Goals.xURI, processedProperties) + 1, findIndexOf(ProjectUri.Build.Plugins.Plugin.Executions.Execution.Goals.xURI, processedProperties) + 1,
uniqueGoals); uniqueGoals);
} }
List<ModelProperty> emptyTags = new ArrayList<ModelProperty>(); List<ModelProperty> emptyTags = new ArrayList<ModelProperty>();
@ -65,14 +62,13 @@ public class ExecutionRule implements ModelContainerRule {
} }
} }
processedProperties.removeAll(emptyTags); processedProperties.removeAll(emptyTags);
return processedProperties; return processedProperties;
} }
private static int findIndexOf(String uri, List<ModelProperty> modelProperties) { private static int findIndexOf(String uri, List<ModelProperty> modelProperties) {
for(ModelProperty mp : modelProperties) { for(ModelProperty mp : modelProperties) {
if(mp.getUri().equals(uri)) { if(mp.getUri().equals(uri) && mp.getResolvedValue() == null) {
return modelProperties.indexOf(mp); return modelProperties.indexOf(mp);
} }
} }
@ -85,11 +81,6 @@ public class ExecutionRule implements ModelContainerRule {
boolean b = (mp.getResolvedValue() == null && modelProperty.getResolvedValue() == null) || boolean b = (mp.getResolvedValue() == null && modelProperty.getResolvedValue() == null) ||
(mp.getResolvedValue() != null && !mp.getResolvedValue().trim().equals("") (mp.getResolvedValue() != null && !mp.getResolvedValue().trim().equals("")
&& mp.getResolvedValue().equals(modelProperty.getResolvedValue())); && mp.getResolvedValue().equals(modelProperty.getResolvedValue()));
/*
boolean b = (mp.getResolvedValue() == null && modelProperty.getResolvedValue() == null) ||
(mp.getResolvedValue() != null && modelProperty.getResolvedValue() != null
&& mp.getResolvedValue().equals(modelProperty.getResolvedValue()));
*/
if(b) { if(b) {
return true; return true;
} }

View File

@ -28,7 +28,7 @@ public class OverideConfigTransformerRule implements JoinRule
ModelContainerAction action = transformedReportContainer.containerAction( reportContainer ); ModelContainerAction action = transformedReportContainer.containerAction( reportContainer );
if ( action.equals( ModelContainerAction.JOIN ) ) if ( action.equals( ModelContainerAction.JOIN ) )
{ {
source.join( transformedReportContainer, reportContainer ); source.join( reportContainer, transformedReportContainer );
break; break;
} }
} }

View File

@ -90,6 +90,21 @@ public class PomConstructionTest
assertEquals( "test-prop", pom.getValue( "properties[1]/b" ) );//verifies profile applied assertEquals( "test-prop", pom.getValue( "properties[1]/b" ) );//verifies profile applied
assertEquals( "test-module", pom.getValue( "modules[1]" ) ); assertEquals( "test-module", pom.getValue( "modules[1]" ) );
} }
/**
* Tests that modules is not overriden by profile
*
* @throws Exception
*/
/*
public void testPluginManagementDuplicate()
throws Exception
{
PomTestWrapper pom = buildPom( "plugin-management-duplicate");
// assertEquals("target", pom.getValue("build/plugins[1]/configuration/domParam/copy/fileset@dir"));
System.out.println(pom.getDomainModel().asString());
}
*/
/** /**
* Will throw exception if doesn't find parent(s) in build * Will throw exception if doesn't find parent(s) in build
@ -115,6 +130,7 @@ public class PomConstructionTest
throws Exception throws Exception
{ {
PomTestWrapper pom = buildPom( "plugin-config-properties" ); PomTestWrapper pom = buildPom( "plugin-config-properties" );
System.out.println(pom.getDomainModel().asString());
assertEquals( "my.property", pom.getValue( "build/plugins[1]/configuration[1]/systemProperties[1]/property[1]/name" ) ); assertEquals( "my.property", pom.getValue( "build/plugins[1]/configuration[1]/systemProperties[1]/property[1]/name" ) );
} }
@ -277,6 +293,7 @@ public class PomConstructionTest
throws Exception throws Exception
{ {
PomTestWrapper pom = buildPom( "single-configuration-inheritance" ); PomTestWrapper pom = buildPom( "single-configuration-inheritance" );
assertEquals( 2, ( (List<?>) pom.getValue( "build/plugins[1]/executions[1]/configuration[1]/rules" ) ).size() ); assertEquals( 2, ( (List<?>) pom.getValue( "build/plugins[1]/executions[1]/configuration[1]/rules" ) ).size() );
assertEquals("2.0.6", pom.getValue( "build/plugins[1]/executions[1]/configuration[1]/rules[1]/requireMavenVersion[1]/version" ) ); assertEquals("2.0.6", pom.getValue( "build/plugins[1]/executions[1]/configuration[1]/rules[1]/requireMavenVersion[1]/version" ) );
assertEquals("[2.0.6,)", pom.getValue( "build/plugins[1]/executions[1]/configuration[1]/rules[2]/requireMavenVersion[1]/version" ) ); assertEquals("[2.0.6,)", pom.getValue( "build/plugins[1]/executions[1]/configuration[1]/rules[2]/requireMavenVersion[1]/version" ) );

View File

@ -71,6 +71,7 @@ public class PomTestWrapper
try { try {
context = JXPathContext.newContext( new MavenXpp3Reader().read(domainModel.getInputStream())); context = JXPathContext.newContext( new MavenXpp3Reader().read(domainModel.getInputStream()));
} catch (XmlPullParserException e) { } catch (XmlPullParserException e) {
e.printStackTrace();
throw new IOException(e.getMessage()); throw new IOException(e.getMessage());
} }
} }

View File

@ -20,51 +20,7 @@ under the License.
--> -->
<project> <project>
<modelVersion>4.0.0</modelVersion> <copy todir="src" overwrite="true">
<fileset dir="target" />
<groupId>org.apache.maven.its.mng4053</groupId> </copy>
<artifactId>test2</artifactId>
<version>1.0-SNAPSHOT</version>
<name>Maven Integration Test :: MNG-4053</name>
<description>
Verify that attributes in plugin configuration elements are not erroneously duplicated to other elements when
plugin management is used.
</description>
<build>
<!-- NOTE: This test used plugin management for the IT plugin -->
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.its.plugins</groupId>
<artifactId>maven-it-plugin-configuration</artifactId>
<version>2.1-SNAPSHOT</version>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.its.plugins</groupId>
<artifactId>maven-it-plugin-configuration</artifactId>
<version>2.1-SNAPSHOT</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>config</goal>
</goals>
<configuration>
<propertiesFile>target/config.properties</propertiesFile>
<domParam>
<copy todir="src" overwrite="true">
<fileset dir="target"/>
</copy>
</domParam>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project> </project>

View File

@ -62,7 +62,7 @@ under the License.
<plexusJetty6Version>1.6</plexusJetty6Version> <plexusJetty6Version>1.6</plexusJetty6Version>
<plexusWebdavVersion>1.0</plexusWebdavVersion> <plexusWebdavVersion>1.0</plexusWebdavVersion>
<wagonVersion>1.0-beta-4</wagonVersion> <wagonVersion>1.0-beta-4</wagonVersion>
<modelBuilderVersion>1.5</modelBuilderVersion> <modelBuilderVersion>1.7-SNAPSHOT</modelBuilderVersion>
<mercuryVersion>1.0.0-alpha-4</mercuryVersion> <mercuryVersion>1.0.0-alpha-4</mercuryVersion>
<mercuryMp3Version>1.0-alpha-1</mercuryMp3Version> <mercuryMp3Version>1.0-alpha-1</mercuryMp3Version>
<securityDispatcherVersion>1.0</securityDispatcherVersion> <securityDispatcherVersion>1.0</securityDispatcherVersion>