mirror of https://github.com/apache/maven.git
[MNG-2145] Adding some more unit tests to protect against these problems in future.
git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@617330 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
5e8a0a0906
commit
ebf314c5a3
|
@ -22,6 +22,7 @@ package org.apache.maven.project;
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||||
import org.apache.maven.artifact.repository.DefaultArtifactRepository;
|
import org.apache.maven.artifact.repository.DefaultArtifactRepository;
|
||||||
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
|
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
|
||||||
|
import org.apache.maven.model.Plugin;
|
||||||
import org.codehaus.plexus.util.FileUtils;
|
import org.codehaus.plexus.util.FileUtils;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
@ -94,6 +95,16 @@ public class DefaultMavenProjectBuilderTest
|
||||||
getProject( f2 );
|
getProject( f2 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testDuplicatePluginDefinitionsMerged()
|
||||||
|
throws Exception
|
||||||
|
{
|
||||||
|
File f1 = getTestFile( "src/test/resources/projects/duplicate-plugins-merged-pom.xml" );
|
||||||
|
|
||||||
|
MavenProject project = getProject( f1 );
|
||||||
|
|
||||||
|
assertEquals( 2, ( (Plugin) project.getBuildPlugins().get( 0 ) ).getDependencies().size() );
|
||||||
|
}
|
||||||
|
|
||||||
protected ArtifactRepository getLocalRepository()
|
protected ArtifactRepository getLocalRepository()
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
|
|
|
@ -489,4 +489,29 @@ public class ModelUtilsTest
|
||||||
assertEquals( "two", item[1].getValue() );
|
assertEquals( "two", item[1].getValue() );
|
||||||
assertEquals( "three", item[2].getValue() );
|
assertEquals( "three", item[2].getValue() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testShouldMergeTwoPluginDependenciesOnMergeDupePluginDefs()
|
||||||
|
{
|
||||||
|
PluginContainer first = new PluginContainer();
|
||||||
|
Plugin fPlugin = createPlugin( "g", "a", "1", Collections.EMPTY_MAP );
|
||||||
|
Dependency fDep = new Dependency();
|
||||||
|
fDep.setGroupId( "group" );
|
||||||
|
fDep.setArtifactId( "artifact" );
|
||||||
|
fDep.setVersion( "1" );
|
||||||
|
|
||||||
|
first.addPlugin( fPlugin );
|
||||||
|
fPlugin.addDependency( fDep );
|
||||||
|
|
||||||
|
Plugin sPlugin = createPlugin( "g", "a", "1", Collections.EMPTY_MAP );
|
||||||
|
Dependency sDep = new Dependency();
|
||||||
|
sDep.setGroupId( "group" );
|
||||||
|
sDep.setArtifactId( "artifact2" );
|
||||||
|
sDep.setVersion( "1" );
|
||||||
|
first.addPlugin( sPlugin );
|
||||||
|
sPlugin.addDependency( sDep );
|
||||||
|
|
||||||
|
ModelUtils.mergeDuplicatePluginDefinitions( first );
|
||||||
|
|
||||||
|
assertEquals( 2, ((Plugin)first.getPlugins().get( 0 ) ).getDependencies().size() );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
<project>
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<groupId>tests.project</groupId>
|
||||||
|
<artifactId>duplicate-plugin-defs-merged</artifactId>
|
||||||
|
<version>1</version>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>group</groupId>
|
||||||
|
<artifactId>first</artifactId>
|
||||||
|
<version>1</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>group</groupId>
|
||||||
|
<artifactId>second</artifactId>
|
||||||
|
<version>1</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
</project>
|
Loading…
Reference in New Issue