mirror of https://github.com/apache/maven.git
[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:
parent
0cefc46991
commit
f9d5fb4c7a
|
@ -1,5 +1,6 @@
|
||||||
package org.apache.maven;
|
package org.apache.maven;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
@ -63,21 +64,28 @@ public class ReactorArtifactRepository
|
||||||
|
|
||||||
artifact.setResolved( true );
|
artifact.setResolved( true );
|
||||||
}
|
}
|
||||||
|
else
|
||||||
/*
|
|
||||||
|
|
||||||
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() )
|
|
||||||
{
|
{
|
||||||
artifact.setFile( new File( project.getBuild().getOutputDirectory() ) );
|
File classesDir;
|
||||||
|
|
||||||
artifact.setFromAuthoritativeRepository( true );
|
if ( isTestArtifact( artifact ) )
|
||||||
|
{
|
||||||
|
classesDir = new File( project.getBuild().getTestOutputDirectory() );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
classesDir = new File( project.getBuild().getOutputDirectory() );
|
||||||
|
}
|
||||||
|
|
||||||
artifact.setResolved( true );
|
if ( classesDir.isDirectory() )
|
||||||
|
{
|
||||||
|
artifact.setFile( classesDir );
|
||||||
|
|
||||||
|
artifact.setFromAuthoritativeRepository( true );
|
||||||
|
|
||||||
|
artifact.setResolved( true );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -182,6 +190,25 @@ public class ReactorArtifactRepository
|
||||||
return buffer.toString();
|
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
|
@Override
|
||||||
public int hashCode()
|
public int hashCode()
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue