From e8a0f65e58253cc8fd31ff469f813fbd46d87458 Mon Sep 17 00:00:00 2001 From: Brett Leslie Porter Date: Tue, 8 Mar 2005 07:11:43 +0000 Subject: [PATCH] actually, test deps are transitive, just not for other test deps git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@163496 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/maven/artifact/MavenMetadataSource.java | 5 +++-- .../apache/maven/project/ProjectClasspathTest.java | 13 +++++++------ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/maven-core/src/main/java/org/apache/maven/artifact/MavenMetadataSource.java b/maven-core/src/main/java/org/apache/maven/artifact/MavenMetadataSource.java index b45a8d9e3a..5fb5470f8d 100644 --- a/maven-core/src/main/java/org/apache/maven/artifact/MavenMetadataSource.java +++ b/maven-core/src/main/java/org/apache/maven/artifact/MavenMetadataSource.java @@ -116,7 +116,8 @@ public class MavenMetadataSource protected Artifact createArtifact( Dependency dependency, String scope, ArtifactRepository localRepository ) { // TODO: can refactor - if ( Artifact.SCOPE_TEST.equals( scope ) ) + String requestedScope = dependency.getScope(); + if ( Artifact.SCOPE_TEST.equals( scope ) && Artifact.SCOPE_TEST.equals( requestedScope ) ) { return null; } @@ -124,7 +125,7 @@ public class MavenMetadataSource // TODO: duplicated with the ArtifactFactory, localRepository not used (should be used here to resolve path? // TODO: scope handler String desiredScope = Artifact.SCOPE_RUNTIME; - if ( Artifact.SCOPE_TEST.equals( dependency.getScope() ) ) + if ( Artifact.SCOPE_TEST.equals( requestedScope ) || Artifact.SCOPE_TEST.equals( scope ) ) { desiredScope = Artifact.SCOPE_TEST; } diff --git a/maven-core/src/test/java/org/apache/maven/project/ProjectClasspathTest.java b/maven-core/src/test/java/org/apache/maven/project/ProjectClasspathTest.java index 47e01bb2c1..b011f249c2 100644 --- a/maven-core/src/test/java/org/apache/maven/project/ProjectClasspathTest.java +++ b/maven-core/src/test/java/org/apache/maven/project/ProjectClasspathTest.java @@ -26,7 +26,8 @@ import java.util.Iterator; /** * @todo relocate to maven-artifact in entirety */ -public class ProjectClasspathTest extends MavenTestCase +public class ProjectClasspathTest + extends MavenTestCase { private String dir = "src/test/resources/projects/scope/"; @@ -57,15 +58,15 @@ public class ProjectClasspathTest extends MavenTestCase checkArtifactIdScope( project, "runtime", "runtime" ); checkArtifactIdScope( project, "default", "compile" ); - // check all transitive deps of a test dependency are skipped - artifact = getArtifact( project, "maven-test-test", "scope-compile" ); - assertNull( "Check no test dependencies are transitive", artifact ); + // check all transitive deps of a test dependency are test, except test which is skipped artifact = getArtifact( project, "maven-test-test", "scope-test" ); assertNull( "Check no test dependencies are transitive", artifact ); + artifact = getArtifact( project, "maven-test-test", "scope-compile" ); + assertEquals( "Check scope", "test", artifact.getScope() ); artifact = getArtifact( project, "maven-test-test", "scope-default" ); - assertNull( "Check no test dependencies are transitive", artifact ); + assertEquals( "Check scope", "test", artifact.getScope() ); artifact = getArtifact( project, "maven-test-test", "scope-runtime" ); - assertNull( "Check no test dependencies are transitive", artifact ); + assertEquals( "Check scope", "test", artifact.getScope() ); // check all transitive deps of a runtime dependency are runtime scope, except for test checkGroupIdScope( project, "runtime", "runtime" );