You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by jv...@apache.org on 2002/12/09 06:59:39 UTC
cvs commit: jakarta-turbine-maven/src/java/org/apache/maven DependencyClasspathBuilder.java
jvanzyl 2002/12/08 21:59:39
Modified: src/java/org/apache/maven DependencyClasspathBuilder.java
Log:
refactoring
Revision Changes Path
1.4 +18 -51 jakarta-turbine-maven/src/java/org/apache/maven/DependencyClasspathBuilder.java
Index: DependencyClasspathBuilder.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/DependencyClasspathBuilder.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- DependencyClasspathBuilder.java 7 Dec 2002 02:19:08 -0000 1.3
+++ DependencyClasspathBuilder.java 9 Dec 2002 05:59:39 -0000 1.4
@@ -56,16 +56,14 @@
* ====================================================================
*/
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.apache.maven.project.Dependency;
-import org.apache.maven.project.Project;
import org.apache.maven.repository.Artifact;
import org.apache.maven.repository.DefaultArtifactFactory;
import org.apache.tools.ant.types.Path;
import java.io.File;
import java.util.Iterator;
+import java.util.List;
/**
* Take a valid MavenJellyContext which contains references to the POM, ant
@@ -86,9 +84,6 @@
// I N S T A N C E M E M B E R S
// ------------------------------------------------------------
- /** Log. */
- private static final Log log = LogFactory.getLog( DependencyClasspathBuilder.class );
-
/** Reference id for the generated classpath. */
private String refid;
@@ -128,57 +123,29 @@
public void execute()
throws Exception
{
- try
- {
- boolean mavenJarOverride = getContext().getMavenJarOverride().booleanValue();
- String mavenRepoLocal = getContext().getMavenRepoLocal();
- Path classpath = new Path( getContext().getAntProject() );
-
- for ( Iterator i = getProject().getDependencies().iterator(); i.hasNext(); )
- {
- Dependency d = (Dependency) i.next();
+ Path classpath = new Path( getContext().getAntProject() );
+ List projectArtifacts = ArtifactListBuilder.build( getProject(), getContext() );
- // Only add jar dependencies to the classpath
- if ( !( d.isCompileType() || d.isTestType() || "jar".equals( d.getType() ) ) )
- {
- continue;
- }
-
- String mavenJarProperty = getContext().getMavenJarOverride( d.getId() );
- Path path = new Path( getContext().getAntProject() );
-
- if ( mavenJarOverride
- &&
- mavenJarProperty != null
- &&
- mavenJarProperty.length() > 0 )
- {
- // The jar override option has been set and we have a property
- // for the this dependency so override the path with the user
- // specified value.
- path.setPath( new File( mavenJarProperty ).getAbsolutePath() );
- }
- else
- {
- Artifact artifact = DefaultArtifactFactory.createArtifact( d );
- // Use the jar in the local repository.
- path.setPath( mavenRepoLocal + artifact.getPath() );
- }
-
- classpath.append( path );
- getProject().setDependencyPath( d.getId(), path.toString() );
- }
+ for ( Iterator i = projectArtifacts.iterator(); i.hasNext(); )
+ {
+ Artifact artifact = (Artifact) i.next();
+ Dependency d = artifact.getDependency();
- if ( getRefid() != null )
+ // Only add jar dependencies to the classpath
+ if ( !( d.isCompileType() || d.isTestType() || "jar".equals( d.getType() ) ) )
{
- getContext().getAntProject().addReference( getRefid(), classpath );
+ continue;
}
+ Path path = new Path( getContext().getAntProject() );
+ path.setPath( artifact.getPath() );
+ classpath.append( path );
+ getProject().setDependencyPath( d.getId(), path.toString() );
}
- catch ( Exception e )
+
+ if ( getRefid() != null )
{
- e.printStackTrace();
- throw e;
+ getContext().getAntProject().addReference( getRefid(), classpath );
}
}
}