Merged back changes dealing with element ordering.

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@750756 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Britton Isbell 2009-03-06 02:41:18 +00:00
parent 8138048fcf
commit 98891350b8
10 changed files with 70 additions and 57 deletions

View File

@ -322,27 +322,6 @@ 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.joinWithOriginalOrder(b, c).getProperties()); joinedContainers.addAll(source.join(b, c).getProperties());
joinedExecutionContainers.add(a); joinedExecutionContainers.add(a);
} }
} }
@ -361,9 +361,10 @@ 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();
System.out.println("----"); // List<ModelProperty> x = rule.execute(es.getProperties());
List<ModelProperty> x = !aContainsAnyOfB(es.getProperties(), joinedContainers) ? es.getProperties() : List<ModelProperty> x = !aContainsAnyOfB(es.getProperties(), joinedContainers) ? rule.execute(es.getProperties()) :
rule.execute(es.getProperties()); ModelTransformerContext.sort(rule.execute(es.getProperties()),
ProjectUri.Build.Plugins.Plugin.Executions.Execution.xUri);
dataSource.replace(es, es.createNewInstance(x)); dataSource.replace(es, es.createNewInstance(x));
} }
@ -410,6 +411,7 @@ public class PomTransformer
p.add(mp); p.add(mp);
} }
} }
return factory.createDomainModel( p ); return factory.createDomainModel( p );
} }

View File

@ -150,10 +150,6 @@ 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.subList(exclusionContainers.indexOf(mc) + 1, exclusionContainers.size())) for(ModelContainer mc1 : exclusionContainers)
{ {
if(!mc.equals(mc1) && mc.containerAction(mc1).equals(ModelContainerAction.JOIN)) if(!mc.equals(mc1) && mc.containerAction(mc1).equals(ModelContainerAction.JOIN))
{ {
exclusionSource.join(mc1, mc); exclusionSource.joinWithOriginalOrder(mc1, mc);
} }
} }
} }

View File

@ -36,18 +36,22 @@ 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);
@ -61,13 +65,14 @@ 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) && mp.getResolvedValue() == null) { if(mp.getUri().equals(uri)) {
return modelProperties.indexOf(mp); return modelProperties.indexOf(mp);
} }
} }
@ -80,6 +85,11 @@ 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( reportContainer, transformedReportContainer ); source.join( transformedReportContainer, reportContainer );
break; break;
} }
} }

View File

@ -91,21 +91,6 @@ public class PomConstructionTest
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
* *
@ -130,7 +115,6 @@ 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" ) );
} }
@ -293,7 +277,6 @@ 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,7 +71,6 @@ 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,7 +20,51 @@ under the License.
--> -->
<project> <project>
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.maven.its.mng4053</groupId>
<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"> <copy todir="src" overwrite="true">
<fileset dir="target"/> <fileset dir="target"/>
</copy> </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.7-SNAPSHOT</modelBuilderVersion> <modelBuilderVersion>1.5</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>