diff --git a/its/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java b/its/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java index d4195b5968..e9a8d41211 100644 --- a/its/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java +++ b/its/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java @@ -281,6 +281,7 @@ public class IntegrationTestSuite suite.addTestSuite( MavenITmng1021EqualAttachmentBuildNumberTest.class ); suite.addTestSuite( MavenITmng0985NonExecutedPluginMngtGoalsTest.class ); suite.addTestSuite( MavenITmng0956ComponentInjectionViaProjectLevelPluginDepTest.class ); + suite.addTestSuite( MavenITmng0947OptionalDependencyTest.class ); suite.addTestSuite( MavenITmng0870ReactorAwarePluginDiscoveryTest.class ); suite.addTestSuite( MavenITmng0866EvaluateDefaultValueTest.class ); suite.addTestSuite( MavenITmng0848SystemPropOverridesDefaultValueTest.class ); diff --git a/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng0947OptionalDependencyTest.java b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng0947OptionalDependencyTest.java new file mode 100644 index 0000000000..40b072eb69 --- /dev/null +++ b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng0947OptionalDependencyTest.java @@ -0,0 +1,70 @@ +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 org.apache.maven.it.Verifier; +import org.apache.maven.it.util.ResourceExtractor; + +import java.io.File; +import java.util.List; + +/** + * This is a test set for MNG-947. + * + * @author Benjamin Bentmann + */ +public class MavenITmng0947OptionalDependencyTest + extends AbstractMavenIntegrationTestCase +{ + + public MavenITmng0947OptionalDependencyTest() + { + super( ALL_MAVEN_VERSIONS ); + } + + /** + * Verify that optional dependencies of a project's direct dependencies are excluded from the project class path. + */ + public void testit() + throws Exception + { + File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-0947" ); + + Verifier verifier = new Verifier( testDir.getAbsolutePath() ); + verifier.setAutoclean( false ); + verifier.deleteDirectory( "target" ); + verifier.deleteArtifacts( "org.apache.maven.its.mng0947" ); + verifier.executeGoal( "validate" ); + verifier.verifyErrorFreeLog(); + verifier.resetStreams(); + + List compile = verifier.loadLines( "target/compile.txt", "UTF-8" ); + assertEquals( 0, compile.size() ); + + List runtime = verifier.loadLines( "target/runtime.txt", "UTF-8" ); + assertTrue( runtime.toString(), runtime.contains( "org.apache.maven.its.mng0947:c:jar:0.1" ) ); + assertEquals( 1, runtime.size() ); + + List test = verifier.loadLines( "target/test.txt", "UTF-8" ); + assertTrue( test.toString(), test.contains( "org.apache.maven.its.mng0947:c:jar:0.1" ) ); + assertEquals( 1, test.size() ); + } + +} diff --git a/its/core-it-suite/src/test/resources/mng-0947/pom.xml b/its/core-it-suite/src/test/resources/mng-0947/pom.xml new file mode 100644 index 0000000000..880fac3545 --- /dev/null +++ b/its/core-it-suite/src/test/resources/mng-0947/pom.xml @@ -0,0 +1,82 @@ + + + + + + 4.0.0 + + org.apache.maven.its.mng0947 + consumer + 0.1 + + Maven Integration Test :: MNG-947 + + Verify that optional dependencies of a project's direct dependencies are excluded from the project class path. + + + + + org.apache.maven.its.mng0947 + c + 0.1 + runtime + + + + + + maven-core-it + file:///${basedir}/repo + + ignore + + + false + + + + + + + + org.apache.maven.its.plugins + maven-it-plugin-dependency-resolution + 2.1-SNAPSHOT + + + test + validate + + target/compile.txt + target/runtime.txt + target/test.txt + 1 + + + compile + runtime + test + + + + + + + diff --git a/its/core-it-suite/src/test/resources/mng-0947/repo/org/apache/maven/its/mng0947/a/0.1/a-0.1.jar b/its/core-it-suite/src/test/resources/mng-0947/repo/org/apache/maven/its/mng0947/a/0.1/a-0.1.jar new file mode 100644 index 0000000000..f8a411b7d4 Binary files /dev/null and b/its/core-it-suite/src/test/resources/mng-0947/repo/org/apache/maven/its/mng0947/a/0.1/a-0.1.jar differ diff --git a/its/core-it-suite/src/test/resources/mng-0947/repo/org/apache/maven/its/mng0947/a/0.1/a-0.1.pom b/its/core-it-suite/src/test/resources/mng-0947/repo/org/apache/maven/its/mng0947/a/0.1/a-0.1.pom new file mode 100644 index 0000000000..bfbc7ef586 --- /dev/null +++ b/its/core-it-suite/src/test/resources/mng-0947/repo/org/apache/maven/its/mng0947/a/0.1/a-0.1.pom @@ -0,0 +1,36 @@ + + + + + + 4.0.0 + + org.apache.maven.its.mng0947 + a + 0.1 + jar + + + + maven-core-it + file:///${basedir}/repo + + + diff --git a/its/core-it-suite/src/test/resources/mng-0947/repo/org/apache/maven/its/mng0947/a/maven-metadata.xml b/its/core-it-suite/src/test/resources/mng-0947/repo/org/apache/maven/its/mng0947/a/maven-metadata.xml new file mode 100644 index 0000000000..4c8e77020b --- /dev/null +++ b/its/core-it-suite/src/test/resources/mng-0947/repo/org/apache/maven/its/mng0947/a/maven-metadata.xml @@ -0,0 +1,13 @@ + + + org.apache.maven.its.mng0947 + a + 0.1 + + 0.1 + + 0.1 + + 20090222220838 + + diff --git a/its/core-it-suite/src/test/resources/mng-0947/repo/org/apache/maven/its/mng0947/b/0.1/b-0.1.jar b/its/core-it-suite/src/test/resources/mng-0947/repo/org/apache/maven/its/mng0947/b/0.1/b-0.1.jar new file mode 100644 index 0000000000..f9fe8977c7 Binary files /dev/null and b/its/core-it-suite/src/test/resources/mng-0947/repo/org/apache/maven/its/mng0947/b/0.1/b-0.1.jar differ diff --git a/its/core-it-suite/src/test/resources/mng-0947/repo/org/apache/maven/its/mng0947/b/0.1/b-0.1.pom b/its/core-it-suite/src/test/resources/mng-0947/repo/org/apache/maven/its/mng0947/b/0.1/b-0.1.pom new file mode 100644 index 0000000000..b537189e08 --- /dev/null +++ b/its/core-it-suite/src/test/resources/mng-0947/repo/org/apache/maven/its/mng0947/b/0.1/b-0.1.pom @@ -0,0 +1,36 @@ + + + + + + 4.0.0 + + org.apache.maven.its.mng0947 + b + 0.1 + jar + + + + maven-core-it + file:///${basedir}/repo + + + diff --git a/its/core-it-suite/src/test/resources/mng-0947/repo/org/apache/maven/its/mng0947/b/maven-metadata.xml b/its/core-it-suite/src/test/resources/mng-0947/repo/org/apache/maven/its/mng0947/b/maven-metadata.xml new file mode 100644 index 0000000000..11707941da --- /dev/null +++ b/its/core-it-suite/src/test/resources/mng-0947/repo/org/apache/maven/its/mng0947/b/maven-metadata.xml @@ -0,0 +1,13 @@ + + + org.apache.maven.its.mng0947 + b + 0.1 + + 0.1 + + 0.1 + + 20090222220853 + + diff --git a/its/core-it-suite/src/test/resources/mng-0947/repo/org/apache/maven/its/mng0947/c/0.1/c-0.1.jar b/its/core-it-suite/src/test/resources/mng-0947/repo/org/apache/maven/its/mng0947/c/0.1/c-0.1.jar new file mode 100644 index 0000000000..1957dae785 Binary files /dev/null and b/its/core-it-suite/src/test/resources/mng-0947/repo/org/apache/maven/its/mng0947/c/0.1/c-0.1.jar differ diff --git a/its/core-it-suite/src/test/resources/mng-0947/repo/org/apache/maven/its/mng0947/c/0.1/c-0.1.pom b/its/core-it-suite/src/test/resources/mng-0947/repo/org/apache/maven/its/mng0947/c/0.1/c-0.1.pom new file mode 100644 index 0000000000..8ee149fb72 --- /dev/null +++ b/its/core-it-suite/src/test/resources/mng-0947/repo/org/apache/maven/its/mng0947/c/0.1/c-0.1.pom @@ -0,0 +1,53 @@ + + + + + + 4.0.0 + + org.apache.maven.its.mng0947 + c + 0.1 + jar + + + + maven-core-it + file:///${basedir}/repo + + + + + + org.apache.maven.its.mng0947 + a + 0.1 + compile + true + + + org.apache.maven.its.mng0947 + b + 0.1 + runtime + true + + + diff --git a/its/core-it-suite/src/test/resources/mng-0947/repo/org/apache/maven/its/mng0947/c/maven-metadata.xml b/its/core-it-suite/src/test/resources/mng-0947/repo/org/apache/maven/its/mng0947/c/maven-metadata.xml new file mode 100644 index 0000000000..589fea4329 --- /dev/null +++ b/its/core-it-suite/src/test/resources/mng-0947/repo/org/apache/maven/its/mng0947/c/maven-metadata.xml @@ -0,0 +1,13 @@ + + + org.apache.maven.its.mng0947 + c + 0.1 + + 0.1 + + 0.1 + + 20090222221044 + +