Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ public static Test suite()
suite.addTestSuite( MavenITmng6255FixConcatLines.class );
suite.addTestSuite( MavenITmng6240PluginExtensionAetherProvider.class );
suite.addTestSuite( MavenITmng6223FindBasedir.class );
suite.addTestSuite( MavenITmng5600DependencyManagementImportExclusionsTest.class );
suite.addTestSuite( MavenITmng6210CoreExtensionsCustomScopesTest.class );
suite.addTestSuite( MavenITmng6189SiteReportPluginsWarningTest.class );
suite.addTestSuite( MavenITmng6173GetProjectsAndDependencyGraphTest.class );
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
package org.apache.maven.it;

/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import java.io.File;
import java.util.Arrays;
import java.util.Map;
import java.util.Properties;

import org.apache.maven.it.util.ResourceExtractor;

import static junit.framework.Assert.assertEquals;

/**
* [MNG-5600] Dependency management import should support exclusions.
*
* @author Christian Schulte
*/
public class MavenITmng5600DependencyManagementImportExclusionsTest
extends AbstractMavenIntegrationTestCase
{

public MavenITmng5600DependencyManagementImportExclusionsTest()
{
super( "[3.7.0,)" );
}

public void testCanExcludeDependenciesFromImport()
throws Exception
{
final File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-5600/exclusions" );

final Verifier verifier = newVerifier( testDir.getAbsolutePath() );
verifier.setAutoclean( false );
verifier.filterFile( "../settings-template.xml", "settings.xml", "UTF-8",
(Map) verifier.newDefaultFilterProperties() );

verifier.addCliOption( "-s" );
verifier.addCliOption( "settings.xml" );
verifier.executeGoals( Arrays.asList( new String[]
{
"clean", "verify"
} ) );
verifier.verifyErrorFreeLog();
verifier.resetStreams();

final Properties properties = verifier.loadProperties( "target/project.properties" );
assertEquals( "1", properties.getProperty( "project.dependencyManagement.dependencies" ) );
assertEquals( "commons-lang:commons-lang:jar",
properties.getProperty( "project.dependencyManagement.dependencies.0.managementKey" ) );

assertEquals( "2", properties.getProperty( "project.dependencyManagement.dependencies.0.exclusions" ) );
assertEquals( "commons-io",
properties.getProperty( "project.dependencyManagement.dependencies.0.exclusions.0.groupId" ) );

assertEquals( "commons-io",
properties.getProperty( "project.dependencyManagement.dependencies.0.exclusions.0.artifactId" ) );

assertEquals( "commons-logging",
properties.getProperty( "project.dependencyManagement.dependencies.0.exclusions.1.groupId" ) );

assertEquals( "commons-logging",
properties.getProperty( "project.dependencyManagement.dependencies.0.exclusions.1.artifactId" ) );
}

}
84 changes: 84 additions & 0 deletions core-it-suite/src/test/resources/mng-5600/exclusions/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
<?xml version="1.0" encoding="UTF-8"?>

<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->

<project>
<modelVersion>4.0.0</modelVersion>

<groupId>org.apache.maven.its.mng5600</groupId>
<artifactId>0</artifactId>
<version>20160619</version>
<packaging>pom</packaging>

<name>Maven Integration Test :: MNG-5600</name>

<description>
Tests that dependency management import exclusions are supported.
</description>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.apache.maven.its.mng5600</groupId>
<artifactId>bom</artifactId>
<version>0</version>
<type>pom</type>
<scope>import</scope>
<exclusions>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This IT doesn't reflect MNG-5600. The requests asks for exclusion of transitive dependencies, not direct dependencies.
To me excluding direct dependencies does not make sense.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't get you. If you exclude a dependency, then the actual excluded dependency and its all transitive dependencies are excluded. Maybe I misinterpret the change. Please clarify it

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rfscholte that is exactly the case. Sometimes you import another pom that is itself a dependencyManagement like spring-boot-dependencies

<exclusion>
<!-- Exclude commons-io from BOM and from all imported dependencies. -->
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
</exclusion>
<exclusion>
<!-- Exclude commons-logging from all imported dependencies. -->
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</dependencyManagement>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.its.plugins</groupId>
<artifactId>maven-it-plugin-expression</artifactId>
<version>2.1-SNAPSHOT</version>
<executions>
<execution>
<phase>verify</phase>
<goals>
<goal>eval</goal>
</goals>
<configuration>
<expressions>
<expression>project/dependencyManagement</expression>
</expressions>
<outputFile>${project.build.directory}/project.properties</outputFile>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?xml version="1.0" encoding="UTF-8"?>

<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->

<project>
<modelVersion>4.0.0</modelVersion>

<groupId>org.apache.maven.its.mng5600</groupId>
<artifactId>bom</artifactId>
<version>0</version>
<packaging>pom</packaging>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.5</version>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
</dependency>
</dependencies>
</dependencyManagement>
</project>
43 changes: 43 additions & 0 deletions core-it-suite/src/test/resources/mng-5600/settings-template.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?xml version="1.0" encoding="UTF-8"?>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand the need for this file

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The original author does not respond, so try to figure out. The repository contains 201 XML file with the same name but with different content. If you are familiar with IT tests in Maven you could tell is it needed or not. I guess the author wanted to follow convention.


<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->

<settings>
<profiles>
<profile>
<id>maven-core-it-repo</id>
<repositories>
<repository>
<id>maven-core-it</id>
<url>@baseurl@/../repo</url>
<releases>
<checksumPolicy>ignore</checksumPolicy>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>maven-core-it-repo</activeProfile>
</activeProfiles>
</settings>