mirror of https://github.com/apache/maven.git
MNG-4010: Remove duplicate dependency exclusions.
git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@738256 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
3850e36381
commit
93ec09c8a5
|
@ -35,20 +35,27 @@ public final class ArtifactModelContainerFactory
|
|||
{
|
||||
|
||||
private static final Collection<String> uris = Collections.unmodifiableList( Arrays.asList(
|
||||
ProjectUri.DependencyManagement.Dependencies.Dependency.xUri, ProjectUri.Dependencies.Dependency.xUri,
|
||||
ProjectUri.DependencyManagement.Dependencies.Dependency.xUri,
|
||||
ProjectUri.Dependencies.Dependency.xUri,
|
||||
ProjectUri.Reporting.Plugins.Plugin.xUri,
|
||||
ProjectUri.Build.PluginManagement.Plugins.Plugin.xUri,
|
||||
//ProjectUri.Build.PluginManagement.Plugins.Plugin.Dependencies.Dependency.xUri,
|
||||
|
||||
ProjectUri.Build.Plugins.Plugin.xUri,
|
||||
//ProjectUri.Build.Plugins.Plugin.Dependencies.Dependency.xUri,
|
||||
// ProjectUri.Build.Plugins.Plugin.Dependencies.Dependency.Exclusions.Exclusion.xUri,
|
||||
ProjectUri.Build.Extensions.Extension.xUri
|
||||
) );
|
||||
|
||||
private final Collection<String> u;
|
||||
|
||||
public Collection<String> getUris()
|
||||
{
|
||||
return uris;
|
||||
return u;
|
||||
}
|
||||
|
||||
public ArtifactModelContainerFactory() {
|
||||
u = uris;
|
||||
}
|
||||
|
||||
public ArtifactModelContainerFactory(String uri) {
|
||||
u = Collections.unmodifiableList( Arrays.asList(uri) );
|
||||
}
|
||||
|
||||
public ModelContainer create( List<ModelProperty> modelProperties )
|
||||
|
|
|
@ -26,6 +26,7 @@ import java.util.*;
|
|||
import org.apache.maven.shared.model.*;
|
||||
import org.apache.maven.shared.model.impl.DefaultModelDataSource;
|
||||
import org.apache.maven.project.builder.rules.ExecutionRule;
|
||||
import org.apache.maven.project.builder.rules.DependencyRule;
|
||||
|
||||
/**
|
||||
* Provides methods for transforming model properties into a domain model for the pom classic format and vice versa.
|
||||
|
@ -60,6 +61,12 @@ public class PomTransformer
|
|||
null, goals_infos)
|
||||
);
|
||||
|
||||
private static Collection<ModelContainerInfo> dependency_exclusions = Arrays.asList(
|
||||
ModelContainerInfo.Factory.createModelContainerInfo(
|
||||
new IdModelContainerFactory(ProjectUri.DependencyManagement.Dependencies.Dependency.Exclusions.Exclusion.xUri),
|
||||
new DependencyRule(), null)
|
||||
);
|
||||
|
||||
//Don't add subcontainers here, breaks MNG-3821
|
||||
public static final Collection<ModelContainerInfo> MODEL_CONTAINER_INFOS = Arrays.asList(
|
||||
ModelContainerInfo.Factory.createModelContainerInfo(
|
||||
|
@ -68,8 +75,8 @@ public class PomTransformer
|
|||
new IdModelContainerFactory(ProjectUri.PluginRepositories.PluginRepository.xUri), null, null),
|
||||
ModelContainerInfo.Factory.createModelContainerInfo(
|
||||
new IdModelContainerFactory(ProjectUri.Repositories.Repository.xUri), null, null),
|
||||
// ModelContainerInfo.Factory.createModelContainerInfo(
|
||||
// new IdModelContainerFactory(ProjectUri.Reporting.Plugins.Plugin.ReportSets.ReportSet.xUri), null, null),
|
||||
ModelContainerInfo.Factory.createModelContainerInfo(
|
||||
new ArtifactModelContainerFactory(), null, dependency_exclusions),
|
||||
ModelContainerInfo.Factory.createModelContainerInfo(
|
||||
new IdModelContainerFactory(ProjectUri.Profiles.Profile.xUri), null, null)
|
||||
);
|
||||
|
@ -102,10 +109,10 @@ public class PomTransformer
|
|||
ProjectUri.Contributors.xUri,
|
||||
|
||||
ProjectUri.Dependencies.xUri,
|
||||
ProjectUri.Dependencies.Dependency.Exclusions.xUri,
|
||||
// ProjectUri.Dependencies.Dependency.Exclusions.xUri,
|
||||
|
||||
ProjectUri.DependencyManagement.Dependencies.xUri,
|
||||
ProjectUri.DependencyManagement.Dependencies.Dependency.Exclusions.xUri,
|
||||
// ProjectUri.DependencyManagement.Dependencies.Dependency.Exclusions.xUri,
|
||||
|
||||
ProjectUri.Developers.xUri,
|
||||
ProjectUri.Developers.Developer.roles,
|
||||
|
@ -121,9 +128,9 @@ public class PomTransformer
|
|||
ProjectUri.Profiles.Profile.Build.Resources.xUri,
|
||||
ProjectUri.Profiles.Profile.Build.TestResources.xUri,
|
||||
ProjectUri.Profiles.Profile.Dependencies.xUri,
|
||||
ProjectUri.Profiles.Profile.Dependencies.Dependency.Exclusions.xUri,
|
||||
// ProjectUri.Profiles.Profile.Dependencies.Dependency.Exclusions.xUri,
|
||||
ProjectUri.Profiles.Profile.DependencyManagement.Dependencies.xUri,
|
||||
ProjectUri.Profiles.Profile.DependencyManagement.Dependencies.Dependency.Exclusions.xUri,
|
||||
// ProjectUri.Profiles.Profile.DependencyManagement.Dependencies.Dependency.Exclusions.xUri,
|
||||
ProjectUri.Profiles.Profile.PluginRepositories.xUri,
|
||||
ProjectUri.Profiles.Profile.Reporting.Plugins.xUri,
|
||||
//ProjectUri.Profiles.Profile.Reporting.Plugins.Plugin.ReportSets.xUri,
|
||||
|
@ -133,7 +140,7 @@ public class PomTransformer
|
|||
// ProjectUri.Profiles.Profile.Build.PluginManagement.Plugins.Plugin.Executions.xUri,
|
||||
// ProjectUri.Profiles.Profile.Build.PluginManagement.Plugins.Plugin.Executions.Execution.Goals.xURI,
|
||||
ProjectUri.Profiles.Profile.Build.PluginManagement.Plugins.Plugin.Dependencies.xUri,
|
||||
ProjectUri.Profiles.Profile.Build.PluginManagement.Plugins.Plugin.Dependencies.Dependency.Exclusions.xUri,
|
||||
// ProjectUri.Profiles.Profile.Build.PluginManagement.Plugins.Plugin.Dependencies.Dependency.Exclusions.xUri,
|
||||
|
||||
ProjectUri.Reporting.Plugins.xUri,
|
||||
//ProjectUri.Reporting.Plugins.Plugin.ReportSets.xUri,
|
||||
|
@ -187,8 +194,25 @@ public class PomTransformer
|
|||
for ( ModelContainer managementContainer : source.queryFor(
|
||||
ProjectUri.DependencyManagement.Dependencies.Dependency.xUri ) )
|
||||
{
|
||||
//Join Duplicate Exclusions Rule (MNG-4010)
|
||||
ModelDataSource exclusionSource = new DefaultModelDataSource(managementContainer.getProperties(),
|
||||
Collections.unmodifiableList(Arrays.asList(new ArtifactModelContainerFactory(ProjectUri.DependencyManagement.Dependencies.Dependency.Exclusions.Exclusion.xUri))));
|
||||
List<ModelContainer> exclusionContainers =
|
||||
exclusionSource.queryFor(ProjectUri.DependencyManagement.Dependencies.Dependency.Exclusions.Exclusion.xUri);
|
||||
|
||||
for(ModelContainer mc : exclusionContainers)
|
||||
{
|
||||
for(ModelContainer mc1 : exclusionContainers)
|
||||
{
|
||||
if(!mc.equals(mc1) && mc.containerAction(mc1).equals(ModelContainerAction.JOIN))
|
||||
{
|
||||
exclusionSource.joinWithOriginalOrder(mc, mc1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
managementContainer = new ArtifactModelContainerFactory().create(
|
||||
transformDependencyManagement( managementContainer.getProperties() ) );
|
||||
transformDependencyManagement( exclusionSource.getModelProperties() ) );
|
||||
ModelContainerAction action = dependencyContainer.containerAction( managementContainer );
|
||||
if ( action.equals( ModelContainerAction.JOIN ) || action.equals( ModelContainerAction.DELETE ) )
|
||||
{
|
||||
|
@ -259,7 +283,7 @@ public class PomTransformer
|
|||
{
|
||||
managementPropertiesWithoutExecutions.removeAll(a.getProperties());
|
||||
}
|
||||
//THIS JOIN REVERSES ORDER
|
||||
|
||||
source.joinWithOriginalOrder( pluginContainer, new ArtifactModelContainerFactory().create(managementPropertiesWithoutExecutions) );
|
||||
|
||||
List<ModelContainer> pluginExecutionContainers = pluginDatasource.queryFor(ProjectUri.Build.Plugins.Plugin.Executions.Execution.xUri);
|
||||
|
@ -289,14 +313,6 @@ public class PomTransformer
|
|||
{
|
||||
//MNG-3995 - property lost here
|
||||
joinedContainers.addAll(source.join(b, c).getProperties());
|
||||
// ExecutionRule rule = new ExecutionRule();
|
||||
// List<ModelProperty> x = rule.execute(d.getProperties());
|
||||
// List<ModelProperty> x = (!joinedContainer) ? rule.execute(es.getProperties()) :
|
||||
// ModelTransformerContext.sort(rule.execute(es.getProperties()),
|
||||
// ProjectUri.Build.Plugins.Plugin.Executions.Execution.xUri);
|
||||
|
||||
// source.replace(d, d.createNewInstance(x));
|
||||
//REVERSE ORDER HERE
|
||||
joinedExecutionContainers.add(a);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
package org.apache.maven.project.builder.rules;
|
||||
|
||||
import org.apache.maven.shared.model.ModelContainerRule;
|
||||
import org.apache.maven.shared.model.ModelProperty;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class DependencyRule implements ModelContainerRule {
|
||||
public List<ModelProperty> execute(List<ModelProperty> modelProperties) {
|
||||
System.out.println("EXECUTE------------------");
|
||||
List<ModelProperty> properties = new ArrayList<ModelProperty>(modelProperties);
|
||||
List<ModelProperty> goalProperties = new ArrayList<ModelProperty>();
|
||||
List<ModelProperty> processedProperties = new ArrayList<ModelProperty>();
|
||||
|
||||
return processedProperties;
|
||||
|
||||
}
|
||||
}
|
|
@ -81,6 +81,34 @@ public class PomConstructionTest
|
|||
assertModelEquals( tester, "child-descriptor", "build/plugins[1]/executions[1]/goals[1]" );
|
||||
}
|
||||
|
||||
/*MNG-
|
||||
public void testDependencyScope()
|
||||
throws Exception
|
||||
{
|
||||
PomTestWrapper pom = buildPom( "dependency-scope/sub" );
|
||||
System.out.println(pom.getDomainModel().asString());
|
||||
|
||||
}
|
||||
*/
|
||||
/*MNG- 4010*/
|
||||
public void testDuplicateExclusionsDependency()
|
||||
throws Exception
|
||||
{
|
||||
PomTestWrapper pom = buildPom( "duplicate-exclusions-dependency/sub" );
|
||||
assertEquals( 1, ( (List<?>) pom.getValue( "dependencies[1]/exclusions" ) ).size() );
|
||||
System.out.println(pom.getDomainModel().asString());
|
||||
|
||||
}
|
||||
|
||||
/*MNG-4005 - not implemented
|
||||
public void testDependenciesDifferentVersions()
|
||||
throws Exception
|
||||
{
|
||||
PomTestWrapper pom = buildPom( "dependencies-different-versions" );
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
public void testPluginOrder()
|
||||
throws Exception
|
||||
{
|
||||
|
@ -150,13 +178,14 @@ public class PomConstructionTest
|
|||
assertEquals( 2, ( (List<?>) pom.getValue( "build/plugins[1]/executions[1]/configuration[1]/rules[1]/bannedDependencies" ) ).size() );
|
||||
}
|
||||
|
||||
/** MNG- */
|
||||
/** MNG-
|
||||
public void testFoo()
|
||||
throws Exception
|
||||
{
|
||||
PomTestWrapper pom = buildPom( "foo/sub" );
|
||||
//System.out.println(pom.getDomainModel().asString());
|
||||
}
|
||||
*/
|
||||
|
||||
/** MNG-3985 */
|
||||
public void testMultipleRepositories()
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
<project>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org</groupId>
|
||||
<artifactId>org-artifact</artifactId>
|
||||
<version>1.0</version>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>test</groupId>
|
||||
<artifactId>test-artifact</artifactId>
|
||||
<version>1.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>test</groupId>
|
||||
<artifactId>test-artifact</artifactId>
|
||||
<version>1.1</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
|
@ -0,0 +1,36 @@
|
|||
<project>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>maven-t10</groupId>
|
||||
<artifactId>p0</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<name>p0</name>
|
||||
<version>1.0</version>
|
||||
|
||||
<dependencyManagement>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>maven-test</groupId>
|
||||
<artifactId>t10-a</artifactId>
|
||||
<version>1.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>maven-test</groupId>
|
||||
<artifactId>t10-b</artifactId>
|
||||
<version>1.0</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>maven-test</groupId>
|
||||
<artifactId>t10-c</artifactId>
|
||||
<version>1.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,31 @@
|
|||
<project>
|
||||
<parent>
|
||||
<artifactId>p0</artifactId>
|
||||
<groupId>maven-t10</groupId>
|
||||
<version>1.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>maven-t10</groupId>
|
||||
<artifactId>p1</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<name>p1</name>
|
||||
<version>1.0</version>
|
||||
<scm>
|
||||
<url>scm-url</url>
|
||||
</scm>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>maven-test</groupId>
|
||||
<artifactId>t10-a</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>maven-test</groupId>
|
||||
<artifactId>t10-c</artifactId>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
</project>
|
|
@ -0,0 +1,34 @@
|
|||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<!--
|
||||
<parent>
|
||||
<groupId>org.sonatype.forge</groupId>
|
||||
<artifactId>forge-parent</artifactId>
|
||||
<version>3</version>
|
||||
</parent>
|
||||
-->
|
||||
<groupId>org.sonatype.nexus</groupId>
|
||||
<artifactId>nexus-parent</artifactId>
|
||||
<version>8-SNAPSHOT</version>
|
||||
|
||||
<properties>
|
||||
<plexus.version>1.0-beta-3.0.5-SNAPSHOT</plexus.version>
|
||||
</properties>
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.codehaus.plexus</groupId>
|
||||
<artifactId>plexus-container-default</artifactId>
|
||||
<version>${plexus.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>commons-logging</groupId>
|
||||
<artifactId>commons-logging-api</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,33 @@
|
|||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>org.sonatype.nexus</groupId>
|
||||
<artifactId>nexus-parent</artifactId>
|
||||
<version>8-SNAPSHOT</version>
|
||||
<relativePath>nexus-parent.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<groupId>org.sonatype.nexus</groupId>
|
||||
<artifactId>nexus</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<name>Nexus Repository Manager</name>
|
||||
<version>1.3.0-SNAPSHOT</version>
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.codehaus.plexus</groupId>
|
||||
<artifactId>plexus-container-default</artifactId>
|
||||
<scope>provided</scope>
|
||||
<version>${plexus.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>commons-logging</groupId>
|
||||
<artifactId>commons-logging-api</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
</project>
|
|
@ -0,0 +1,16 @@
|
|||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<parent>
|
||||
<groupId>org.sonatype.nexus</groupId>
|
||||
<artifactId>nexus</artifactId>
|
||||
<version>1.3.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>nexus-proxy</artifactId>
|
||||
<dependencies>
|
||||
<!-- For App basic -->
|
||||
<dependency>
|
||||
<groupId>org.codehaus.plexus</groupId>
|
||||
<artifactId>plexus-container-default</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
Loading…
Reference in New Issue