mirror of https://github.com/apache/maven.git
Various bug fixes to model building.
git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@756975 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
cdf874b056
commit
609077e2b4
|
@ -26,6 +26,9 @@ import org.apache.maven.model.Model;
|
|||
public class ModuleProcessor
|
||||
extends BaseProcessor
|
||||
{
|
||||
/**
|
||||
* No parent
|
||||
*/
|
||||
public void process( Object parent, Object child, Object target, boolean isChildMostSpecialized )
|
||||
{
|
||||
super.process( parent, child, target, isChildMostSpecialized );
|
||||
|
|
|
@ -40,7 +40,7 @@ public class PluginProcessor
|
|||
return;
|
||||
}
|
||||
else if ( parent == null && child != null )
|
||||
{//Plugin targetPlugin = new Plugin();
|
||||
{
|
||||
|
||||
boolean isAdd = true;
|
||||
Plugin targetPlugin = find((Plugin) child, t);
|
||||
|
@ -58,8 +58,6 @@ public class PluginProcessor
|
|||
}
|
||||
else if ( parent != null && child == null )
|
||||
{
|
||||
//Plugin targetPlugin = new Plugin();
|
||||
|
||||
boolean isAdd = true;
|
||||
Plugin targetPlugin = find((Plugin) parent, t);
|
||||
if(targetPlugin == null)
|
||||
|
@ -231,16 +229,18 @@ public class PluginProcessor
|
|||
target.setPhase( source.getPhase() );
|
||||
}
|
||||
|
||||
List<String> goals = new ArrayList<String>(target.getGoals());
|
||||
List<String> targetGoals = new ArrayList<String>(target.getGoals());
|
||||
List<String> setGoals = new ArrayList<String>();
|
||||
for(String goal : source.getGoals())
|
||||
{
|
||||
if(!goals.contains( goal ))
|
||||
if(targetGoals.contains( goal ))
|
||||
{
|
||||
goals.add( goal );
|
||||
targetGoals.remove( goal );
|
||||
}
|
||||
|
||||
}
|
||||
target.setGoals( goals );
|
||||
setGoals.addAll( source.getGoals() );
|
||||
setGoals.addAll( targetGoals );
|
||||
target.setGoals( setGoals );
|
||||
|
||||
if(source.getConfiguration() != null)
|
||||
{
|
||||
|
|
|
@ -43,7 +43,7 @@ public class PluginsManagementProcessor extends BaseProcessor
|
|||
for(Plugin depMng : pluginManagement)
|
||||
{
|
||||
for(Plugin targetDep : targetPlugin)
|
||||
{
|
||||
{ //PluginManagement is first in ordering
|
||||
if(match(depMng, targetDep))
|
||||
{
|
||||
copy(depMng, targetDep );
|
||||
|
@ -83,22 +83,26 @@ public class PluginsManagementProcessor extends BaseProcessor
|
|||
target.setVersion( source.getVersion() );
|
||||
}
|
||||
|
||||
|
||||
List<PluginExecution> executions = new ArrayList<PluginExecution>();
|
||||
for( PluginExecution pe : source.getExecutions())
|
||||
{
|
||||
PluginExecution idMatch = contains(pe, target.getExecutions());
|
||||
if(idMatch != null)//Join
|
||||
{
|
||||
copyPluginExecution(pe, idMatch);
|
||||
target.getExecutions().remove( idMatch );
|
||||
executions.add( idMatch );
|
||||
}
|
||||
else
|
||||
{
|
||||
PluginExecution targetPe = new PluginExecution();
|
||||
copyPluginExecution(pe, targetPe);
|
||||
target.addExecution( targetPe );
|
||||
executions.add( targetPe );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
executions.addAll( target.getExecutions() );
|
||||
target.setExecutions( executions );
|
||||
|
||||
DependenciesProcessor proc = new DependenciesProcessor();
|
||||
if(target.getDependencies().isEmpty())
|
||||
|
@ -116,17 +120,14 @@ public class PluginsManagementProcessor extends BaseProcessor
|
|||
//TODO: Not copying
|
||||
if(target.getConfiguration() != null)
|
||||
{
|
||||
target.setConfiguration( Xpp3Dom.mergeXpp3Dom( (Xpp3Dom) source.getConfiguration(), (Xpp3Dom) target.getConfiguration() ));
|
||||
target.setConfiguration( Xpp3Dom.mergeXpp3Dom( (Xpp3Dom) target.getConfiguration(), (Xpp3Dom) source.getConfiguration() ));
|
||||
}
|
||||
else
|
||||
{
|
||||
target.setConfiguration( source.getConfiguration() );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// p2.setConfiguration( configuration ) merge nodes
|
||||
//Goals
|
||||
target.setExtensions(source.isExtensions());
|
||||
|
||||
}
|
||||
|
@ -172,76 +173,17 @@ public class PluginsManagementProcessor extends BaseProcessor
|
|||
|
||||
}
|
||||
target.setGoals( goals );
|
||||
if(source.getConfiguration() != null)
|
||||
{
|
||||
if(target.getConfiguration() != null)
|
||||
{
|
||||
target.setConfiguration( Xpp3Dom.mergeXpp3Dom( (Xpp3Dom) source.getConfiguration(), (Xpp3Dom) target.getConfiguration() ));
|
||||
//Target is dominant
|
||||
target.setConfiguration( Xpp3Dom.mergeXpp3Dom( (Xpp3Dom) target.getConfiguration(), (Xpp3Dom) source.getConfiguration() ));
|
||||
}
|
||||
else
|
||||
{
|
||||
target.setConfiguration( source.getConfiguration() );
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
private static void copy(Plugin p1, Plugin p2)
|
||||
{
|
||||
if(p2.getArtifactId() == null)
|
||||
{
|
||||
p2.setArtifactId( p1.getArtifactId() );
|
||||
}
|
||||
|
||||
if(p2.getGroupId() == null)
|
||||
{
|
||||
p2.setGroupId( p1.getGroupId() );
|
||||
}
|
||||
|
||||
if(p2.getInherited() == null)
|
||||
{
|
||||
p2.setInherited( p1.getInherited() );
|
||||
}
|
||||
|
||||
if(p2.getVersion() == null)
|
||||
{
|
||||
p2.setVersion( p1.getVersion() );
|
||||
}
|
||||
|
||||
for( PluginExecution pe : p1.getExecutions())
|
||||
{
|
||||
PluginExecution p = new PluginExecution();
|
||||
p.setId( pe.getId() );
|
||||
p.setInherited( pe.getInherited() );
|
||||
p.setPhase( pe.getPhase() );
|
||||
p.setGoals( new ArrayList<String>(pe.getGoals()) );
|
||||
p2.addExecution( p );
|
||||
}
|
||||
|
||||
// if(p2.getDependencies().isEmpty())
|
||||
// {
|
||||
DependenciesProcessor proc = new DependenciesProcessor();
|
||||
proc.process( new ArrayList<Dependency>(), new ArrayList<Dependency>(p1.getDependencies()), p2.getDependencies(), false );
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// DependenciesProcessor proc = new DependenciesProcessor();
|
||||
// proc.process( new ArrayList<Dependency>(p1.getDependencies()), new ArrayList<Dependency>(), p2.getDependencies(), false );
|
||||
// }
|
||||
|
||||
if(p1.getConfiguration() != null)
|
||||
{
|
||||
//TODO: Not copying
|
||||
if(p2.getConfiguration() != null)
|
||||
{
|
||||
p2.setConfiguration( Xpp3Dom.mergeXpp3Dom( (Xpp3Dom) p1.getConfiguration(), (Xpp3Dom) p2.getConfiguration() ));
|
||||
}
|
||||
else
|
||||
{
|
||||
p2.setConfiguration( p1.getConfiguration() );
|
||||
}
|
||||
}
|
||||
|
||||
// p2.setConfiguration( configuration ) merge nodes
|
||||
//Goals
|
||||
p2.setExtensions(p1.isExtensions());
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
|
|
@ -40,7 +40,6 @@ public class PluginsProcessor
|
|||
p = (List<Plugin>) parent;
|
||||
}
|
||||
|
||||
// Model t = (Model) target;
|
||||
List<Plugin> plugins = (List<Plugin>) target;
|
||||
|
||||
PluginProcessor processor = new PluginProcessor();
|
||||
|
@ -92,18 +91,6 @@ public class PluginsProcessor
|
|||
private static boolean match( Plugin d1, Plugin d2 )
|
||||
{
|
||||
return getId( d1 ).equals( getId( d2 ));
|
||||
/*
|
||||
if ( getId( d1 ).equals( getId( d2 ) ) )
|
||||
{
|
||||
if(d1.getVersion() == null || d2.getVersion() == null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return ( d1.getVersion() == null ? "" : d1.getVersion() ).equals( d2.getVersion() == null ? ""
|
||||
: d2.getVersion() );
|
||||
}
|
||||
return false;
|
||||
*/
|
||||
}
|
||||
|
||||
private static String getId( Plugin d )
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package org.apache.maven.project.processor;
|
||||
package org.apache.maven.project.processor;
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
|
@ -35,8 +35,6 @@ public class ProfilesModuleProcessor
|
|||
Model p = (Model) parent;
|
||||
List<String> modules = new ArrayList<String>();
|
||||
|
||||
|
||||
|
||||
for ( String module : c.getModules() )
|
||||
{
|
||||
if(!modules.contains( module ))
|
||||
|
|
|
@ -32,16 +32,18 @@ public class PropertiesProcessor
|
|||
Model t = (Model) target, c = (Model) child, p = (Model) parent;
|
||||
|
||||
Properties properties = new Properties();
|
||||
if ( p != null && p.getProperties() != null )
|
||||
{
|
||||
properties.putAll( p.getProperties() );
|
||||
}
|
||||
|
||||
|
||||
if ( c.getProperties() != null )
|
||||
{
|
||||
properties.putAll( c.getProperties() );
|
||||
}
|
||||
|
||||
if ( p != null && p.getProperties() != null )
|
||||
{
|
||||
properties.putAll( p.getProperties() );
|
||||
}
|
||||
|
||||
if ( !properties.isEmpty() )
|
||||
{
|
||||
t.setProperties( properties );
|
||||
|
|
|
@ -122,7 +122,6 @@ public class PomConstructionTest
|
|||
}
|
||||
|
||||
/*MNG-3900*/
|
||||
/*F:
|
||||
public void testProfilePropertiesInterpolation()
|
||||
throws Exception
|
||||
{
|
||||
|
@ -131,7 +130,7 @@ public class PomConstructionTest
|
|||
assertEquals("PASSED", pom.getValue("properties[1]/test"));
|
||||
assertEquals("PASSED", pom.getValue("properties[1]/property"));
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
// Some better conventions for the test poms needs to be created and each of these tests
|
||||
// that represent a verification of a specification item needs to be a couple lines at most.
|
||||
|
@ -303,6 +302,7 @@ public class PomConstructionTest
|
|||
throws Exception
|
||||
{
|
||||
PomTestWrapper pom = buildPom( "single-configuration-inheritance" );
|
||||
System.out.println(pom.getDomainModel().asString());
|
||||
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[2]/requireMavenVersion[1]/version" ) );
|
||||
|
@ -325,15 +325,6 @@ public class PomConstructionTest
|
|||
assertEquals( 2, ( (List<?>) pom.getValue( "build/plugins[1]/executions[1]/configuration[1]/rules[1]/bannedDependencies" ) ).size() );
|
||||
}
|
||||
|
||||
/** MNG-
|
||||
public void testFoo()
|
||||
throws Exception
|
||||
{
|
||||
PomTestWrapper pom = buildPom( "foo/sub" );
|
||||
//System.out.println(pom.getDomainModel().asString());
|
||||
}
|
||||
*/
|
||||
|
||||
/** MNG-3985 */
|
||||
public void testMultipleRepositories()
|
||||
throws Exception
|
||||
|
@ -434,7 +425,7 @@ public class PomConstructionTest
|
|||
assertEquals( "<?xml version='1.0'?>Tom&Jerry", pom.getValue( "properties/xmlTest" ) );
|
||||
}
|
||||
|
||||
/* FIXME: cf. MNG-3925
|
||||
/* FIXME: cf. MNG-3925 */
|
||||
public void testOrderOfMergedPluginExecutionsWithoutPluginManagement()
|
||||
throws Exception
|
||||
{
|
||||
|
@ -452,6 +443,7 @@ public class PomConstructionTest
|
|||
throws Exception
|
||||
{
|
||||
PomTestWrapper pom = buildPom( "merged-plugin-exec-order/w-plugin-mngt/sub" );
|
||||
System.out.println(pom.getDomainModel().asString());
|
||||
assertEquals( 5, ( (List<?>) pom.getValue( "build/plugins[1]/executions" ) ).size() );
|
||||
assertEquals( "parent-1", pom.getValue( "build/plugins[1]/executions[1]/goals[1]" ) );
|
||||
assertEquals( "parent-2", pom.getValue( "build/plugins[1]/executions[2]/goals[1]" ) );
|
||||
|
@ -471,12 +463,11 @@ public class PomConstructionTest
|
|||
}
|
||||
|
||||
/* MNG-3937*/
|
||||
/* FIX - REGRESSION*/
|
||||
/*
|
||||
public void testOrderOfMergedPluginExecutionGoalsWithoutPluginManagement()
|
||||
throws Exception
|
||||
{
|
||||
PomTestWrapper pom = buildPom( "merged-plugin-exec-goals-order/wo-plugin-mngt/sub" );
|
||||
System.out.println(pom.getDomainModel().asString());
|
||||
assertEquals( 5, ( (List<?>) pom.getValue( "build/plugins[1]/executions[1]/goals" ) ).size() );
|
||||
assertEquals( "child-a", pom.getValue( "build/plugins[1]/executions[1]/goals[1]" ) );
|
||||
assertEquals( "merged", pom.getValue( "build/plugins[1]/executions[1]/goals[2]" ) );
|
||||
|
@ -484,7 +475,7 @@ public class PomConstructionTest
|
|||
assertEquals( "parent-b", pom.getValue( "build/plugins[1]/executions[1]/goals[4]" ) );
|
||||
assertEquals( "parent-a", pom.getValue( "build/plugins[1]/executions[1]/goals[5]" ) );
|
||||
}
|
||||
*/
|
||||
|
||||
public void testOrderOfMergedPluginExecutionGoalsWithPluginManagement()
|
||||
throws Exception
|
||||
{
|
||||
|
@ -497,7 +488,7 @@ public class PomConstructionTest
|
|||
assertEquals( "parent-a", pom.getValue( "build/plugins[1]/executions[1]/goals[5]" ) );
|
||||
}
|
||||
//*/
|
||||
/* FIX - REGRESSION*/
|
||||
|
||||
public void testOverridingOfInheritedPluginExecutionsWithoutPluginManagement()
|
||||
throws Exception
|
||||
{
|
||||
|
@ -629,7 +620,7 @@ public class PomConstructionTest
|
|||
assertEquals( "PASSED", pom.getValue( "properties/property" + index ) );
|
||||
}
|
||||
}
|
||||
/*F:
|
||||
/*
|
||||
public void testInterpolationOfLegacyExpressionsThatDontIncludeTheProjectPrefix()
|
||||
throws Exception
|
||||
{
|
||||
|
@ -751,26 +742,27 @@ public class PomConstructionTest
|
|||
}
|
||||
//*/
|
||||
|
||||
/* FIXME: cf. MNG-3836
|
||||
/* FIXME: cf. MNG-3836*/
|
||||
public void testMergeOfInheritedPluginConfiguration()
|
||||
throws Exception
|
||||
{
|
||||
PomTestWrapper pom = buildPom( "plugin-config-merging/child" );
|
||||
System.out.println(pom.getDomainModel().asString());
|
||||
String prefix = "build/plugins[1]/configuration/";
|
||||
assertEquals( "PASSED", pom.getValue( prefix + "propertiesFile" ) );
|
||||
assertEquals( "PASSED", pom.getValue( prefix + "parent" ) );
|
||||
assertEquals( "PASSED-1", pom.getValue( prefix + "stringParams/stringParam[1]" ) );
|
||||
assertEquals( "PASSED-2", pom.getValue( prefix + "stringParams/stringParam[2]" ) );
|
||||
assertEquals( "PASSED-3", pom.getValue( prefix + "stringParams/stringParam[3]" ) );
|
||||
assertEquals( "PASSED-3", pom.getValue( prefix + "stringParams/stringParam[2]" ) );
|
||||
assertEquals( "PASSED-2", pom.getValue( prefix + "stringParams/stringParam[3]" ) );
|
||||
assertEquals( "PASSED-4", pom.getValue( prefix + "stringParams/stringParam[4]" ) );
|
||||
assertEquals( "PASSED-1", pom.getValue( prefix + "listParam/listParam[1]" ) );
|
||||
assertEquals( "PASSED-2", pom.getValue( prefix + "listParam/listParam[2]" ) );
|
||||
assertEquals( "PASSED-3", pom.getValue( prefix + "listParam/listParam[3]" ) );
|
||||
assertEquals( "PASSED-3", pom.getValue( prefix + "listParam/listParam[2]" ) );
|
||||
assertEquals( "PASSED-2", pom.getValue( prefix + "listParam/listParam[3]" ) );
|
||||
assertEquals( "PASSED-4", pom.getValue( prefix + "listParam/listParam[4]" ) );
|
||||
}
|
||||
//*/
|
||||
|
||||
/* FIXME: cf. MNG-2591
|
||||
/* FIXME: cf. MNG-2591*/
|
||||
public void testAppendOfInheritedPluginConfiguration()
|
||||
throws Exception
|
||||
{
|
||||
|
|
|
@ -19,8 +19,7 @@
|
|||
<project>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>org.apache.maven.its.mng3900
|
||||
</groupId>
|
||||
<groupId>org.apache.maven.its.mng3900 </groupId>
|
||||
<artifactId>test</artifactId>
|
||||
<version>0.1</version>
|
||||
<packaging>jar</packaging>
|
||||
|
|
Loading…
Reference in New Issue