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
This commit is contained in:
Brett Leslie Porter 2005-03-08 07:11:43 +00:00
parent 24a8a801e9
commit e8a0f65e58
2 changed files with 10 additions and 8 deletions

View File

@ -116,7 +116,8 @@ public class MavenMetadataSource
protected Artifact createArtifact( Dependency dependency, String scope, ArtifactRepository localRepository ) protected Artifact createArtifact( Dependency dependency, String scope, ArtifactRepository localRepository )
{ {
// TODO: can refactor // 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; 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: duplicated with the ArtifactFactory, localRepository not used (should be used here to resolve path?
// TODO: scope handler // TODO: scope handler
String desiredScope = Artifact.SCOPE_RUNTIME; 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; desiredScope = Artifact.SCOPE_TEST;
} }

View File

@ -26,7 +26,8 @@ import java.util.Iterator;
/** /**
* @todo relocate to maven-artifact in entirety * @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/"; private String dir = "src/test/resources/projects/scope/";
@ -57,15 +58,15 @@ public class ProjectClasspathTest extends MavenTestCase
checkArtifactIdScope( project, "runtime", "runtime" ); checkArtifactIdScope( project, "runtime", "runtime" );
checkArtifactIdScope( project, "default", "compile" ); checkArtifactIdScope( project, "default", "compile" );
// check all transitive deps of a test dependency are skipped // check all transitive deps of a test dependency are test, except test which is skipped
artifact = getArtifact( project, "maven-test-test", "scope-compile" );
assertNull( "Check no test dependencies are transitive", artifact );
artifact = getArtifact( project, "maven-test-test", "scope-test" ); artifact = getArtifact( project, "maven-test-test", "scope-test" );
assertNull( "Check no test dependencies are transitive", artifact ); 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" ); 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" ); 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 // check all transitive deps of a runtime dependency are runtime scope, except for test
checkGroupIdScope( project, "runtime", "runtime" ); checkGroupIdScope( project, "runtime", "runtime" );