mirror of https://github.com/apache/maven.git
Resolving: MNG-815. Added unit test to guard against regressions.
git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@280616 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
4bbf7a627c
commit
159b48c4e7
|
@ -154,7 +154,7 @@ public class DefaultProfileInjector
|
||||||
|
|
||||||
if ( profilePlugin != null )
|
if ( profilePlugin != null )
|
||||||
{
|
{
|
||||||
mergedPlugin = profilePlugin;
|
mergedPlugin = modelPlugin;
|
||||||
|
|
||||||
injectPluginDefinition( profilePlugin, modelPlugin );
|
injectPluginDefinition( profilePlugin, modelPlugin );
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ import org.apache.maven.model.Build;
|
||||||
import org.apache.maven.model.BuildBase;
|
import org.apache.maven.model.BuildBase;
|
||||||
import org.apache.maven.model.Model;
|
import org.apache.maven.model.Model;
|
||||||
import org.apache.maven.model.Plugin;
|
import org.apache.maven.model.Plugin;
|
||||||
|
import org.apache.maven.model.PluginExecution;
|
||||||
import org.apache.maven.model.Profile;
|
import org.apache.maven.model.Profile;
|
||||||
import org.apache.maven.model.Repository;
|
import org.apache.maven.model.Repository;
|
||||||
import org.codehaus.plexus.util.xml.Xpp3Dom;
|
import org.codehaus.plexus.util.xml.Xpp3Dom;
|
||||||
|
@ -15,7 +16,7 @@ public class DefaultProfileInjectorTest
|
||||||
extends TestCase
|
extends TestCase
|
||||||
{
|
{
|
||||||
|
|
||||||
public void testProfilePluginConfigurationShouldOverrideModelPluginConfiguration()
|
public void testProfilePluginConfigurationShouldOverrideCollidingModelPluginConfiguration()
|
||||||
{
|
{
|
||||||
Plugin mPlugin = new Plugin();
|
Plugin mPlugin = new Plugin();
|
||||||
mPlugin.setGroupId( "test" );
|
mPlugin.setGroupId( "test" );
|
||||||
|
@ -25,8 +26,12 @@ public class DefaultProfileInjectorTest
|
||||||
Xpp3Dom mConfigChild = new Xpp3Dom( "test" );
|
Xpp3Dom mConfigChild = new Xpp3Dom( "test" );
|
||||||
mConfigChild.setValue( "value" );
|
mConfigChild.setValue( "value" );
|
||||||
|
|
||||||
|
Xpp3Dom mConfigChild2 = new Xpp3Dom( "test2" );
|
||||||
|
mConfigChild2.setValue( "value2" );
|
||||||
|
|
||||||
Xpp3Dom mConfig = new Xpp3Dom( "configuration" );
|
Xpp3Dom mConfig = new Xpp3Dom( "configuration" );
|
||||||
mConfig.addChild( mConfigChild );
|
mConfig.addChild( mConfigChild );
|
||||||
|
mConfig.addChild( mConfigChild2 );
|
||||||
|
|
||||||
mPlugin.setConfiguration( mConfig );
|
mPlugin.setConfiguration( mConfig );
|
||||||
|
|
||||||
|
@ -66,6 +71,85 @@ public class DefaultProfileInjectorTest
|
||||||
Xpp3Dom rChild = rConfig.getChild( "test" );
|
Xpp3Dom rChild = rConfig.getChild( "test" );
|
||||||
|
|
||||||
assertEquals( "replacedValue", rChild.getValue() );
|
assertEquals( "replacedValue", rChild.getValue() );
|
||||||
|
|
||||||
|
Xpp3Dom rChild2 = rConfig.getChild( "test2" );
|
||||||
|
|
||||||
|
assertEquals( "value2", rChild2.getValue() );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testModelConfigShouldPersistWhenPluginHasExecConfigs()
|
||||||
|
{
|
||||||
|
Plugin mPlugin = new Plugin();
|
||||||
|
mPlugin.setGroupId( "test" );
|
||||||
|
mPlugin.setArtifactId( "test-artifact" );
|
||||||
|
mPlugin.setVersion( "1.0-SNAPSHOT" );
|
||||||
|
|
||||||
|
Xpp3Dom mConfigChild = new Xpp3Dom( "test" );
|
||||||
|
mConfigChild.setValue( "value" );
|
||||||
|
|
||||||
|
Xpp3Dom mConfigChild2 = new Xpp3Dom( "test2" );
|
||||||
|
mConfigChild2.setValue( "value2" );
|
||||||
|
|
||||||
|
Xpp3Dom mConfig = new Xpp3Dom( "configuration" );
|
||||||
|
mConfig.addChild( mConfigChild );
|
||||||
|
mConfig.addChild( mConfigChild2 );
|
||||||
|
|
||||||
|
mPlugin.setConfiguration( mConfig );
|
||||||
|
|
||||||
|
Build mBuild = new Build();
|
||||||
|
mBuild.addPlugin( mPlugin );
|
||||||
|
|
||||||
|
Model model = new Model();
|
||||||
|
model.setBuild( mBuild );
|
||||||
|
|
||||||
|
Plugin pPlugin = new Plugin();
|
||||||
|
pPlugin.setGroupId( "test" );
|
||||||
|
pPlugin.setArtifactId( "test-artifact" );
|
||||||
|
pPlugin.setVersion( "1.0-SNAPSHOT" );
|
||||||
|
|
||||||
|
PluginExecution pExec = new PluginExecution();
|
||||||
|
pExec.setId("profile-injected");
|
||||||
|
|
||||||
|
Xpp3Dom pConfigChild = new Xpp3Dom( "test" );
|
||||||
|
pConfigChild.setValue( "replacedValue" );
|
||||||
|
|
||||||
|
Xpp3Dom pConfig = new Xpp3Dom( "configuration" );
|
||||||
|
pConfig.addChild( pConfigChild );
|
||||||
|
|
||||||
|
pExec.setConfiguration( pConfig );
|
||||||
|
|
||||||
|
pPlugin.addExecution( pExec );
|
||||||
|
|
||||||
|
BuildBase pBuild = new BuildBase();
|
||||||
|
pBuild.addPlugin( pPlugin );
|
||||||
|
|
||||||
|
Profile profile = new Profile();
|
||||||
|
profile.setId( "testId" );
|
||||||
|
|
||||||
|
profile.setBuild( pBuild );
|
||||||
|
|
||||||
|
new DefaultProfileInjector().inject( profile, model );
|
||||||
|
|
||||||
|
Build rBuild = model.getBuild();
|
||||||
|
Plugin rPlugin = (Plugin) rBuild.getPlugins().get( 0 );
|
||||||
|
|
||||||
|
PluginExecution rExec = (PluginExecution) rPlugin.getExecutionsAsMap().get( "profile-injected" );
|
||||||
|
|
||||||
|
assertNotNull( rExec );
|
||||||
|
|
||||||
|
Xpp3Dom rExecConfig = (Xpp3Dom) rExec.getConfiguration();
|
||||||
|
|
||||||
|
Xpp3Dom rChild = rExecConfig.getChild( "test" );
|
||||||
|
|
||||||
|
assertEquals( "replacedValue", rChild.getValue() );
|
||||||
|
|
||||||
|
Xpp3Dom rConfig = (Xpp3Dom) rPlugin.getConfiguration();
|
||||||
|
|
||||||
|
assertNotNull( rConfig );
|
||||||
|
|
||||||
|
Xpp3Dom rChild2 = rConfig.getChild( "test2" );
|
||||||
|
|
||||||
|
assertEquals( "value2", rChild2.getValue() );
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testProfileRepositoryShouldOverrideModelRepository()
|
public void testProfileRepositoryShouldOverrideModelRepository()
|
||||||
|
|
Loading…
Reference in New Issue