resolve outstanding issues with scoping regarding tests. Algorithm to be documented in user's guide.

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@163953 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Brett Leslie Porter 2005-04-15 07:31:40 +00:00
parent 912898c716
commit e054a2fa5a
2 changed files with 11 additions and 19 deletions

View File

@ -47,19 +47,16 @@ public class ArtifactConstructionSupport
{
// TODO: can refactor, use scope handler
// re-instate this if test deps are propogated
// if ( Artifact.SCOPE_TEST.equals( inheritedScope ) && Artifact.SCOPE_TEST.equals( scope ) )
if ( Artifact.SCOPE_TEST.equals( inheritedScope ) )
String desiredScope = Artifact.SCOPE_RUNTIME;
if ( inheritedScope == null )
{
desiredScope = scope;
}
else if ( Artifact.SCOPE_TEST.equals( scope ) )
{
return null;
}
String desiredScope = Artifact.SCOPE_RUNTIME;
if ( Artifact.SCOPE_COMPILE.equals( scope ) && inheritedScope == null )
{
desiredScope = Artifact.SCOPE_COMPILE;
}
// vvv added to retain compile scope. Remove if you want compile inherited as runtime
else if ( Artifact.SCOPE_COMPILE.equals( scope ) && Artifact.SCOPE_COMPILE.equals( inheritedScope ) )
{
@ -67,9 +64,7 @@ public class ArtifactConstructionSupport
}
// ^^^ added to retain compile scope. Remove if you want compile inherited as runtime
// re-instate this if test deps are propogated
// if ( Artifact.SCOPE_TEST.equals( scope ) || Artifact.SCOPE_TEST.equals( inheritedScope ) )
if ( Artifact.SCOPE_TEST.equals( scope ) )
if ( Artifact.SCOPE_TEST.equals( inheritedScope ) )
{
desiredScope = Artifact.SCOPE_TEST;
}

View File

@ -66,14 +66,11 @@ public class ProjectClasspathTest
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() );
assertNull( "Check no test dependencies are transitive", artifact );
assertEquals( "Check scope", "test", artifact.getScope() );
artifact = getArtifact( project, "maven-test-test", "scope-default" );
// assertEquals( "Check scope", "test", artifact.getScope() );
assertNull( "Check no test dependencies are transitive", artifact );
assertEquals( "Check scope", "test", artifact.getScope() );
artifact = getArtifact( project, "maven-test-test", "scope-runtime" );
// assertEquals( "Check scope", "test", artifact.getScope() );
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" );
@ -92,7 +89,7 @@ public class ProjectClasspathTest
artifact = getArtifact( project, groupId, "scope-compile" );
assertEquals( "Check scope", scopeValue, artifact.getScope() );
artifact = getArtifact( project, groupId, "scope-test" );
assertEquals( "Check scope", "test", artifact.getScope() );
assertNull( "Check test dependency is not transitive", artifact );
artifact = getArtifact( project, groupId, "scope-default" );
assertEquals( "Check scope", scopeValue, artifact.getScope() );
artifact = getArtifact( project, groupId, "scope-runtime" );