From 75d79fc06346bf1463611d9cfd07b6506033010e Mon Sep 17 00:00:00 2001 From: Benjamin Bentmann Date: Sat, 21 Mar 2009 16:23:09 +0000 Subject: [PATCH] o Fixed dependency processing git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@756964 13f79535-47bb-0310-9956-ffa450edef68 --- .../DependencyManagementProcessor.java | 2 ++ .../processor/DependencyProcessor.java | 2 ++ .../maven/project/PomConstructionTest.java | 30 +++++++++++++++++++ 3 files changed, 34 insertions(+) diff --git a/maven-project/src/main/java/org/apache/maven/project/processor/DependencyManagementProcessor.java b/maven-project/src/main/java/org/apache/maven/project/processor/DependencyManagementProcessor.java index 1ec8d74dda..4b8aebc38c 100644 --- a/maven-project/src/main/java/org/apache/maven/project/processor/DependencyManagementProcessor.java +++ b/maven-project/src/main/java/org/apache/maven/project/processor/DependencyManagementProcessor.java @@ -96,6 +96,8 @@ public class DependencyManagementProcessor extends BaseProcessor } } } + + targetDependency.setOptional( dependency.isOptional() ); } private static boolean containsExclusion( Exclusion exclusion, List exclusions ) diff --git a/maven-project/src/main/java/org/apache/maven/project/processor/DependencyProcessor.java b/maven-project/src/main/java/org/apache/maven/project/processor/DependencyProcessor.java index 802020f077..a8c85ab804 100644 --- a/maven-project/src/main/java/org/apache/maven/project/processor/DependencyProcessor.java +++ b/maven-project/src/main/java/org/apache/maven/project/processor/DependencyProcessor.java @@ -164,6 +164,8 @@ public class DependencyProcessor } } } + + targetDependency.setOptional( source.isOptional() ); } private static boolean containsExclusion( Exclusion exclusion, List exclusions ) diff --git a/maven-project/src/test/java/org/apache/maven/project/PomConstructionTest.java b/maven-project/src/test/java/org/apache/maven/project/PomConstructionTest.java index 38c583a2d5..64371637c8 100644 --- a/maven-project/src/test/java/org/apache/maven/project/PomConstructionTest.java +++ b/maven-project/src/test/java/org/apache/maven/project/PomConstructionTest.java @@ -1046,6 +1046,36 @@ public class PomConstructionTest assertEquals( "reloc-aid", pom.getValue( "distributionManagement/relocation/artifactId" ) ); assertEquals( "reloc-version", pom.getValue( "distributionManagement/relocation/version" ) ); assertEquals( "project-reloc-msg", pom.getValue( "distributionManagement/relocation/message" ) ); + + assertEquals( 1, ( (List) pom.getValue( "modules" ) ).size() ); + assertEquals( "sub", pom.getValue( "modules[1]" ) ); + + assertEquals( 1, ( (Map) pom.getValue( "properties" ) ).size() ); + assertEquals( "project-property", pom.getValue( "properties[1]/itProperty" ) ); + + assertEquals( 1, ( (List) pom.getValue( "dependencyManagement/dependencies" ) ).size() ); + assertEquals( "org.apache.maven.its", pom.getValue( "dependencyManagement/dependencies[1]/groupId" ) ); + assertEquals( "managed-dep", pom.getValue( "dependencyManagement/dependencies[1]/artifactId" ) ); + assertEquals( "0.1", pom.getValue( "dependencyManagement/dependencies[1]/version" ) ); + assertEquals( "war", pom.getValue( "dependencyManagement/dependencies[1]/type" ) ); + assertEquals( "runtime", pom.getValue( "dependencyManagement/dependencies[1]/scope" ) ); + assertEquals( Boolean.FALSE, pom.getValue( "dependencyManagement/dependencies[1]/optional" ) ); + assertEquals( 1, ( (List) pom.getValue( "dependencyManagement/dependencies[1]/exclusions" ) ).size() ); + assertEquals( "org.apache.maven.its", + pom.getValue( "dependencyManagement/dependencies[1]/exclusions[1]/groupId" ) ); + assertEquals( "excluded-managed-dep", + pom.getValue( "dependencyManagement/dependencies[1]/exclusions[1]/artifactId" ) ); + + assertEquals( 1, ( (List) pom.getValue( "dependencies" ) ).size() ); + assertEquals( "org.apache.maven.its", pom.getValue( "dependencies[1]/groupId" ) ); + assertEquals( "dep", pom.getValue( "dependencies[1]/artifactId" ) ); + assertEquals( "0.2", pom.getValue( "dependencies[1]/version" ) ); + assertEquals( "ejb", pom.getValue( "dependencies[1]/type" ) ); + assertEquals( "test", pom.getValue( "dependencies[1]/scope" ) ); + assertEquals( Boolean.TRUE, pom.getValue( "dependencies[1]/optional" ) ); + assertEquals( 1, ( (List) pom.getValue( "dependencies[1]/exclusions" ) ).size() ); + assertEquals( "org.apache.maven.its", pom.getValue( "dependencies[1]/exclusions[1]/groupId" ) ); + assertEquals( "excluded-dep", pom.getValue( "dependencies[1]/exclusions[1]/artifactId" ) ); }