o Cleaned up code

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@798504 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Benjamin Bentmann 2009-07-28 12:27:10 +00:00
parent f9d5fb4c7a
commit fdb57e65ca
1 changed files with 11 additions and 52 deletions

View File

@ -584,24 +584,10 @@ public class MavenProject
{
if ( a.getArtifactHandler().isAddedToClasspath() )
{
File file = a.getFile();
if ( file == null )
{
throw new DependencyResolutionRequiredException( a );
}
list.add( file.getPath() );
addArtifactPath( a, list );
}
}
/*
System.out.println( "TEST CLASSPATH: ");
for( String s : list )
{
System.out.println( ">>>>> " + s );
}
*/
return list;
}
@ -663,12 +649,7 @@ public class MavenProject
// TODO: let the scope handler deal with this
if ( Artifact.SCOPE_COMPILE.equals( a.getScope() ) || Artifact.SCOPE_RUNTIME.equals( a.getScope() ) )
{
File file = a.getFile();
if ( file == null )
{
throw new DependencyResolutionRequiredException( a );
}
list.add( file.getPath() );
addArtifactPath( a, list );
}
}
}
@ -1911,47 +1892,25 @@ public class MavenProject
}
}
private void addArtifactPath( Artifact a, List<String> list )
private void addArtifactPath( Artifact artifact, List<String> classpath )
throws DependencyResolutionRequiredException
{
File file = a.getFile();
if ( file != null )
File file = artifact.getFile();
if ( file == null )
{
list.add( file.getPath() );
throw new DependencyResolutionRequiredException( artifact );
}
else
{
String refId = getProjectReferenceId( a.getGroupId(), a.getArtifactId(), a.getVersion() );
MavenProject project = projectReferences.get( refId );
boolean projectDirFound = false;
if ( project != null )
{
if ( "test-jar".equals( a.getType() ) )
{
File testOutputDir = new File( project.getBuild().getTestOutputDirectory() );
if ( testOutputDir.exists() )
{
list.add( testOutputDir.getAbsolutePath() );
projectDirFound = true;
}
}
else
{
list.add( project.getBuild().getOutputDirectory() );
projectDirFound = true;
}
}
if ( !projectDirFound )
{
throw new DependencyResolutionRequiredException( a );
}
classpath.add( file.getPath() );
}
}
private static String getProjectReferenceId( String groupId, String artifactId, String version )
{
return groupId + ":" + artifactId + ":" + version;
StringBuilder buffer = new StringBuilder( 128 );
buffer.append( groupId ).append( ':' ).append( artifactId ).append( ':' ).append( version );
return buffer.toString();
}
/**