[MNG-2871] Subartifact (ejb-client, test-jar etc.) are not reselved as active project artifacts in build phases prior to package

[MNG-3043] Allow 'mvn test' to work with test-jar dependencies in a reactor

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@798494 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Benjamin Bentmann 2009-07-28 11:46:04 +00:00
parent 0cefc46991
commit f9d5fb4c7a
1 changed files with 38 additions and 11 deletions

View File

@ -1,5 +1,6 @@
package org.apache.maven;
import java.io.File;
import java.util.Collection;
import java.util.Map;
@ -63,21 +64,28 @@ public class ReactorArtifactRepository
artifact.setResolved( true );
}
/*
TODO: This is being left out because Maven 2.x does not set this internally and it is only done by the compiler
plugin and not done generally. This should be done generally but currently causes problems with MNG-3023
else if ( new File( project.getBuild().getOutputDirectory() ).exists() )
else
{
artifact.setFile( new File( project.getBuild().getOutputDirectory() ) );
File classesDir;
if ( isTestArtifact( artifact ) )
{
classesDir = new File( project.getBuild().getTestOutputDirectory() );
}
else
{
classesDir = new File( project.getBuild().getOutputDirectory() );
}
if ( classesDir.isDirectory() )
{
artifact.setFile( classesDir );
artifact.setFromAuthoritativeRepository( true );
artifact.setResolved( true );
}
*/
}
}
}
@ -182,6 +190,25 @@ public class ReactorArtifactRepository
return buffer.toString();
}
/**
* Determines whether the specified artifact refers to test classes.
*
* @param artifact The artifact to check, must not be {@code null}.
* @return {@code true} if the artifact refers to test classes, {@code false} otherwise.
*/
private static boolean isTestArtifact( Artifact artifact )
{
if ( "test-jar".equals( artifact.getType() ) )
{
return true;
}
else if ( "jar".equals( artifact.getType() ) && "tests".equals( artifact.getClassifier() ) )
{
return true;
}
return false;
}
@Override
public int hashCode()
{