[MNG-5227] The 'optional' flag of a dependency should be manageable.

Project: http://git-wip-us.apache.org/repos/asf/maven-integration-testing/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/maven-integration-testing/commit/68c0330e
Tree: 
http://git-wip-us.apache.org/repos/asf/maven-integration-testing/tree/68c0330e
Diff: 
http://git-wip-us.apache.org/repos/asf/maven-integration-testing/diff/68c0330e

Branch: refs/heads/DEPMGMT
Commit: 68c0330ed6a29fd61b5ef07910c9ea6870099a65
Parents: 88c1528
Author: Christian Schulte <schu...@apache.org>
Authored: Wed Jan 27 08:09:55 2016 +0100
Committer: Christian Schulte <schu...@apache.org>
Committed: Thu Feb 2 04:18:42 2017 +0100

----------------------------------------------------------------------
 .../apache/maven/it/IntegrationTestSuite.java   |   1 +
 ...227DependencyOptionalFlagManagementTest.java |  89 +++++++++++++++++++
 .../src/test/resources/mng-5227/model/pom.xml   |  77 ++++++++++++++++
 .../test/resources/mng-5227/resolution/pom.xml  |  76 ++++++++++++++++
 .../maven/its/mng5227/direct/0.2/direct-0.2.jar | Bin 0 -> 2054 bytes
 .../maven/its/mng5227/direct/0.2/direct-0.2.pom |  46 ++++++++++
 .../maven/its/mng5227/direct/maven-metadata.xml |  12 +++
 .../mng5227/transitive/0.1/transitive-0.1.jar   | Bin 0 -> 2038 bytes
 .../mng5227/transitive/0.1/transitive-0.1.pom   |  38 ++++++++
 .../its/mng5227/transitive/maven-metadata.xml   |  12 +++
 .../mng-5227/resolution/settings-template.xml   |  43 +++++++++
 11 files changed, 394 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/68c0330e/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java
----------------------------------------------------------------------
diff --git 
a/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java 
b/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java
index 9cba111..ba84e06 100644
--- a/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java
+++ b/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java
@@ -106,6 +106,7 @@ public class IntegrationTestSuite
         // 
-------------------------------------------------------------------------------------------------------------
         // suite.addTestSuite( MavenIT0108SnapshotUpdateTest.class ); -- 
MNG-3137
 
+        suite.addTestSuite( 
MavenITmng5227DependencyOptionalFlagManagementTest.class );
         suite.addTestSuite( 
MavenITmng6079DependencyManagementImportInterpolationTest.class );
         suite.addTestSuite( MavenITmng5971HierarchicalImportScopeTest.class );
         suite.addTestSuite( 
MavenITmng5600DependencyManagementImportExclusionsTest.class );

http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/68c0330e/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng5227DependencyOptionalFlagManagementTest.java
----------------------------------------------------------------------
diff --git 
a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng5227DependencyOptionalFlagManagementTest.java
 
b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng5227DependencyOptionalFlagManagementTest.java
new file mode 100644
index 0000000..98d3a17
--- /dev/null
+++ 
b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng5227DependencyOptionalFlagManagementTest.java
@@ -0,0 +1,89 @@
+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.List;
+import java.util.Properties;
+import org.apache.maven.it.util.ResourceExtractor;
+import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.assertTrue;
+
+/**
+ * This is a test set for <a 
href="https://issues.apache.org/jira/browse/MNG-5227";>MNG-5227</a>.
+ *
+ * @author Christian Schulte
+ */
+public class MavenITmng5227DependencyOptionalFlagManagementTest
+    extends AbstractMavenIntegrationTestCase
+{
+
+    public MavenITmng5227DependencyOptionalFlagManagementTest()
+    {
+        super( "[3.6,)" );
+    }
+
+    /**
+     * Verify that a dependency's optional flag is subject to dependency 
management. This part of the test checks
+     * the effective model.
+     */
+    public void testitModel()
+        throws Exception
+    {
+        File testDir = ResourceExtractor.simpleExtractResources( getClass(), 
"/mng-5227/model" );
+
+        Verifier verifier = newVerifier( testDir.getAbsolutePath() );
+        verifier.setAutoclean( false );
+        verifier.deleteDirectory( "target" );
+        verifier.executeGoal( "validate" );
+        verifier.verifyErrorFreeLog();
+        verifier.resetStreams();
+
+        Properties props = verifier.loadProperties( "target/pom.properties" );
+        assertEquals( "dep", props.getProperty( 
"project.dependencies.0.artifactId" ) );
+        assertEquals( "true", props.getProperty( 
"project.dependencies.0.optional" ) );
+    }
+
+    /**
+     * Verify that a transitive dependency's optional flag is subject to 
dependency management of the root artifat.
+     * This part of the test checks the artifact collector.
+     */
+    public void testitResolution()
+        throws Exception
+    {
+        File testDir = ResourceExtractor.simpleExtractResources( getClass(), 
"/mng-5227/resolution" );
+
+        Verifier verifier = newVerifier( testDir.getAbsolutePath() );
+        verifier.setAutoclean( false );
+        verifier.deleteDirectory( "target" );
+        verifier.deleteArtifacts( "org.apache.maven.its.mng5227" );
+        verifier.filterFile( "settings-template.xml", "settings.xml", "UTF-8", 
verifier.newDefaultFilterProperties() );
+        verifier.addCliOption( "--settings" );
+        verifier.addCliOption( "settings.xml" );
+        verifier.executeGoal( "validate" );
+        verifier.verifyErrorFreeLog();
+        verifier.resetStreams();
+
+        List<String> classpath = verifier.loadLines( "target/classpath.txt", 
"UTF-8" );
+        assertTrue( classpath.toString(), classpath.contains( "direct-0.2.jar" 
) );
+        assertFalse( classpath.toString(), classpath.contains( 
"transitive-0.1.jar" ) );
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/68c0330e/core-it-suite/src/test/resources/mng-5227/model/pom.xml
----------------------------------------------------------------------
diff --git a/core-it-suite/src/test/resources/mng-5227/model/pom.xml 
b/core-it-suite/src/test/resources/mng-5227/model/pom.xml
new file mode 100644
index 0000000..0373e9a
--- /dev/null
+++ b/core-it-suite/src/test/resources/mng-5227/model/pom.xml
@@ -0,0 +1,77 @@
+<?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.mng5227</groupId>
+  <artifactId>test</artifactId>
+  <version>0.1</version>
+  <packaging>pom</packaging>
+
+  <name>Maven Integration Test :: MNG-5227</name>
+  <description>
+    Verify that the optional flag of a dependency is controlled by dependency 
management.
+  </description>
+
+  <dependencyManagement>
+    <dependencies>
+      <dependency>
+        <groupId>org.apache.maven.its.mng5227</groupId>
+        <artifactId>dep</artifactId>
+        <version>0.1</version>
+        <!-- This must not be ignored -->
+        <optional>true</optional>
+      </dependency>
+    </dependencies>
+  </dependencyManagement>
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.maven.its.mng5227</groupId>
+      <artifactId>dep</artifactId>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.its.plugins</groupId>
+        <artifactId>maven-it-plugin-expression</artifactId>
+        <version>2.1-SNAPSHOT</version>
+        <executions>
+          <execution>
+            <id>test</id>
+            <phase>validate</phase>
+            <configuration>
+              <expressions>
+                <expression>project/dependencies</expression>
+              </expressions>
+              <outputFile>target/pom.properties</outputFile>
+            </configuration>
+            <goals>
+              <goal>eval</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+</project>

http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/68c0330e/core-it-suite/src/test/resources/mng-5227/resolution/pom.xml
----------------------------------------------------------------------
diff --git a/core-it-suite/src/test/resources/mng-5227/resolution/pom.xml 
b/core-it-suite/src/test/resources/mng-5227/resolution/pom.xml
new file mode 100644
index 0000000..a334b20
--- /dev/null
+++ b/core-it-suite/src/test/resources/mng-5227/resolution/pom.xml
@@ -0,0 +1,76 @@
+<?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.mng5227</groupId>
+  <artifactId>test</artifactId>
+  <version>0.1</version>
+
+  <name>Maven Integration Test :: MNG-5227</name>
+  <description>
+    Verify that the optional state of a transitive dependency is controlled by 
dependency management.
+  </description>
+
+  <dependencyManagement>
+    <dependencies>
+      <dependency>
+        <groupId>org.apache.maven.its.mng5227</groupId>
+        <artifactId>transitive</artifactId>
+        <version>0.1</version>
+        <!-- This must apply to transitive dependencies -->
+        <optional>true</optional>
+      </dependency>
+    </dependencies>
+  </dependencyManagement>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.maven.its.mng5227</groupId>
+      <artifactId>direct</artifactId>
+      <version>0.2</version>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.its.plugins</groupId>
+        <artifactId>maven-it-plugin-dependency-resolution</artifactId>
+        <version>2.1-SNAPSHOT</version>
+        <configuration>
+          <compileClassPath>target/classpath.txt</compileClassPath>
+          <significantPathLevels>1</significantPathLevels>
+        </configuration>
+        <executions>
+          <execution>
+            <id>test</id>
+            <phase>validate</phase>
+            <goals>
+              <goal>compile</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+</project>

http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/68c0330e/core-it-suite/src/test/resources/mng-5227/resolution/repo/org/apache/maven/its/mng5227/direct/0.2/direct-0.2.jar
----------------------------------------------------------------------
diff --git 
a/core-it-suite/src/test/resources/mng-5227/resolution/repo/org/apache/maven/its/mng5227/direct/0.2/direct-0.2.jar
 
b/core-it-suite/src/test/resources/mng-5227/resolution/repo/org/apache/maven/its/mng5227/direct/0.2/direct-0.2.jar
new file mode 100644
index 0000000..d756c3e
Binary files /dev/null and 
b/core-it-suite/src/test/resources/mng-5227/resolution/repo/org/apache/maven/its/mng5227/direct/0.2/direct-0.2.jar
 differ

http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/68c0330e/core-it-suite/src/test/resources/mng-5227/resolution/repo/org/apache/maven/its/mng5227/direct/0.2/direct-0.2.pom
----------------------------------------------------------------------
diff --git 
a/core-it-suite/src/test/resources/mng-5227/resolution/repo/org/apache/maven/its/mng5227/direct/0.2/direct-0.2.pom
 
b/core-it-suite/src/test/resources/mng-5227/resolution/repo/org/apache/maven/its/mng5227/direct/0.2/direct-0.2.pom
new file mode 100644
index 0000000..25913d2
--- /dev/null
+++ 
b/core-it-suite/src/test/resources/mng-5227/resolution/repo/org/apache/maven/its/mng5227/direct/0.2/direct-0.2.pom
@@ -0,0 +1,46 @@
+<?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.mng5227</groupId>
+  <artifactId>direct</artifactId>
+  <version>0.2</version>
+  <packaging>jar</packaging>
+
+  <name>Maven Integration Test :: MNG-5227 :: Direct Dependency</name>
+
+  <distributionManagement>
+    <repository>
+      <id>maven-core-it</id>
+      <url>file:///${basedir}/repo</url>
+    </repository>
+  </distributionManagement>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.maven.its.mng5227</groupId>
+      <artifactId>transitive</artifactId>
+      <version>0.1</version>
+    </dependency>
+  </dependencies>
+</project>

http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/68c0330e/core-it-suite/src/test/resources/mng-5227/resolution/repo/org/apache/maven/its/mng5227/direct/maven-metadata.xml
----------------------------------------------------------------------
diff --git 
a/core-it-suite/src/test/resources/mng-5227/resolution/repo/org/apache/maven/its/mng5227/direct/maven-metadata.xml
 
b/core-it-suite/src/test/resources/mng-5227/resolution/repo/org/apache/maven/its/mng5227/direct/maven-metadata.xml
new file mode 100644
index 0000000..d0a7451
--- /dev/null
+++ 
b/core-it-suite/src/test/resources/mng-5227/resolution/repo/org/apache/maven/its/mng5227/direct/maven-metadata.xml
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<metadata>
+  <groupId>org.apache.maven.its.mng5227</groupId>
+  <artifactId>direct</artifactId>
+  <version>0.2</version>
+  <versioning>
+    <versions>
+      <version>0.2</version>
+    </versions>
+    <lastUpdated>20100319225359</lastUpdated>
+  </versioning>
+</metadata>

http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/68c0330e/core-it-suite/src/test/resources/mng-5227/resolution/repo/org/apache/maven/its/mng5227/transitive/0.1/transitive-0.1.jar
----------------------------------------------------------------------
diff --git 
a/core-it-suite/src/test/resources/mng-5227/resolution/repo/org/apache/maven/its/mng5227/transitive/0.1/transitive-0.1.jar
 
b/core-it-suite/src/test/resources/mng-5227/resolution/repo/org/apache/maven/its/mng5227/transitive/0.1/transitive-0.1.jar
new file mode 100644
index 0000000..2099b1c
Binary files /dev/null and 
b/core-it-suite/src/test/resources/mng-5227/resolution/repo/org/apache/maven/its/mng5227/transitive/0.1/transitive-0.1.jar
 differ

http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/68c0330e/core-it-suite/src/test/resources/mng-5227/resolution/repo/org/apache/maven/its/mng5227/transitive/0.1/transitive-0.1.pom
----------------------------------------------------------------------
diff --git 
a/core-it-suite/src/test/resources/mng-5227/resolution/repo/org/apache/maven/its/mng5227/transitive/0.1/transitive-0.1.pom
 
b/core-it-suite/src/test/resources/mng-5227/resolution/repo/org/apache/maven/its/mng5227/transitive/0.1/transitive-0.1.pom
new file mode 100644
index 0000000..c68a6db
--- /dev/null
+++ 
b/core-it-suite/src/test/resources/mng-5227/resolution/repo/org/apache/maven/its/mng5227/transitive/0.1/transitive-0.1.pom
@@ -0,0 +1,38 @@
+<?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.mng5227</groupId>
+  <artifactId>transitive</artifactId>
+  <version>0.1</version>
+  <packaging>jar</packaging>
+
+  <name>Maven Integration Test :: MNG-5227 :: Transitive Dependency</name>
+
+  <distributionManagement>
+    <repository>
+      <id>maven-core-it</id>
+      <url>file:///${basedir}/repo</url>
+    </repository>
+  </distributionManagement>
+</project>

http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/68c0330e/core-it-suite/src/test/resources/mng-5227/resolution/repo/org/apache/maven/its/mng5227/transitive/maven-metadata.xml
----------------------------------------------------------------------
diff --git 
a/core-it-suite/src/test/resources/mng-5227/resolution/repo/org/apache/maven/its/mng5227/transitive/maven-metadata.xml
 
b/core-it-suite/src/test/resources/mng-5227/resolution/repo/org/apache/maven/its/mng5227/transitive/maven-metadata.xml
new file mode 100644
index 0000000..2c77226
--- /dev/null
+++ 
b/core-it-suite/src/test/resources/mng-5227/resolution/repo/org/apache/maven/its/mng5227/transitive/maven-metadata.xml
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<metadata>
+  <groupId>org.apache.maven.its.mng5227</groupId>
+  <artifactId>transitive</artifactId>
+  <version>0.1</version>
+  <versioning>
+    <versions>
+      <version>0.1</version>
+    </versions>
+    <lastUpdated>20100319225254</lastUpdated>
+  </versioning>
+</metadata>

http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/68c0330e/core-it-suite/src/test/resources/mng-5227/resolution/settings-template.xml
----------------------------------------------------------------------
diff --git 
a/core-it-suite/src/test/resources/mng-5227/resolution/settings-template.xml 
b/core-it-suite/src/test/resources/mng-5227/resolution/settings-template.xml
new file mode 100644
index 0000000..c985d1a
--- /dev/null
+++ b/core-it-suite/src/test/resources/mng-5227/resolution/settings-template.xml
@@ -0,0 +1,43 @@
+<?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.
+-->
+
+<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>

Reply via email to