mirror of https://github.com/apache/maven.git
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:
parent
912898c716
commit
e054a2fa5a
|
@ -47,19 +47,16 @@ public class ArtifactConstructionSupport
|
||||||
{
|
{
|
||||||
// TODO: can refactor, use scope handler
|
// TODO: can refactor, use scope handler
|
||||||
|
|
||||||
// re-instate this if test deps are propogated
|
String desiredScope = Artifact.SCOPE_RUNTIME;
|
||||||
// if ( Artifact.SCOPE_TEST.equals( inheritedScope ) && Artifact.SCOPE_TEST.equals( scope ) )
|
if ( inheritedScope == null )
|
||||||
if ( Artifact.SCOPE_TEST.equals( inheritedScope ) )
|
{
|
||||||
|
desiredScope = scope;
|
||||||
|
}
|
||||||
|
else if ( Artifact.SCOPE_TEST.equals( scope ) )
|
||||||
{
|
{
|
||||||
return null;
|
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
|
// 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 ) )
|
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
|
// ^^^ 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( inheritedScope ) )
|
||||||
// if ( Artifact.SCOPE_TEST.equals( scope ) || Artifact.SCOPE_TEST.equals( inheritedScope ) )
|
|
||||||
if ( Artifact.SCOPE_TEST.equals( scope ) )
|
|
||||||
{
|
{
|
||||||
desiredScope = Artifact.SCOPE_TEST;
|
desiredScope = Artifact.SCOPE_TEST;
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,14 +66,11 @@ public class ProjectClasspathTest
|
||||||
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" );
|
artifact = getArtifact( project, "maven-test-test", "scope-compile" );
|
||||||
// assertEquals( "Check scope", "test", artifact.getScope() );
|
assertEquals( "Check scope", "test", artifact.getScope() );
|
||||||
assertNull( "Check no test dependencies are transitive", artifact );
|
|
||||||
artifact = getArtifact( project, "maven-test-test", "scope-default" );
|
artifact = getArtifact( project, "maven-test-test", "scope-default" );
|
||||||
// assertEquals( "Check scope", "test", artifact.getScope() );
|
assertEquals( "Check scope", "test", artifact.getScope() );
|
||||||
assertNull( "Check no test dependencies are transitive", artifact );
|
|
||||||
artifact = getArtifact( project, "maven-test-test", "scope-runtime" );
|
artifact = getArtifact( project, "maven-test-test", "scope-runtime" );
|
||||||
// assertEquals( "Check scope", "test", artifact.getScope() );
|
assertEquals( "Check scope", "test", artifact.getScope() );
|
||||||
assertNull( "Check no test dependencies are transitive", artifact );
|
|
||||||
|
|
||||||
// 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" );
|
||||||
|
@ -92,7 +89,7 @@ public class ProjectClasspathTest
|
||||||
artifact = getArtifact( project, groupId, "scope-compile" );
|
artifact = getArtifact( project, groupId, "scope-compile" );
|
||||||
assertEquals( "Check scope", scopeValue, artifact.getScope() );
|
assertEquals( "Check scope", scopeValue, artifact.getScope() );
|
||||||
artifact = getArtifact( project, groupId, "scope-test" );
|
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" );
|
artifact = getArtifact( project, groupId, "scope-default" );
|
||||||
assertEquals( "Check scope", scopeValue, artifact.getScope() );
|
assertEquals( "Check scope", scopeValue, artifact.getScope() );
|
||||||
artifact = getArtifact( project, groupId, "scope-runtime" );
|
artifact = getArtifact( project, groupId, "scope-runtime" );
|
||||||
|
|
Loading…
Reference in New Issue