dion 2003/08/10 23:21:33 Modified: src/java/org/apache/maven/project Tag: MAVEN_RC1_STABLE Project.java Log: Start of MAVEN-536 Revision Changes Path No revision No revision 1.83.2.2 +77 -37 maven/src/java/org/apache/maven/project/Project.java Index: Project.java =================================================================== RCS file: /home/cvs/maven/src/java/org/apache/maven/project/Project.java,v retrieving revision 1.83.2.1 retrieving revision 1.83.2.2 diff -u -r1.83.2.1 -r1.83.2.2 --- Project.java 7 Aug 2003 16:56:39 -0000 1.83.2.1 +++ Project.java 11 Aug 2003 06:21:33 -0000 1.83.2.2 @@ -70,10 +70,13 @@ import org.apache.maven.jelly.JellyUtils; import org.apache.tools.ant.types.Path; import org.apache.commons.grant.GrantProject; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.dom4j.Document; import org.dom4j.io.SAXReader; import com.werken.forehead.Forehead; +import com.werken.forehead.ForeheadClassLoader; import java.io.File; import java.io.InputStreamReader; @@ -234,6 +237,9 @@ /** ArtifactId. */ private String artifactId; + + /** log for debug and output */ + private static final Log log = LogFactory.getLog(Project.class); /** * Default constructor. @@ -1376,40 +1382,6 @@ } /** - * process the dependencies for this project - */ - public void processDependencies() throws MalformedURLException - { - if (getArtifacts() == null) - { - return; - } - - for ( Iterator i = getArtifacts().iterator(); i.hasNext(); ) - { - Artifact artifact = (Artifact) i.next(); - Dependency dependency = artifact.getDependency(); - String classloader = dependency.getProperty( "classloader" ); - - // Only add compile type dependencies to classloader - if ( classloader != null && dependency.getType().equals( "jar" ) ) - { - // We have the jar and the classloader to push it into so - // lets do it! - if ( artifact.exists() ) - { - // Make sure the stated classloader actually exists. - if ( Forehead.getInstance().getClassLoader( classloader ) != null ) - { - Forehead.getInstance().getClassLoader( classloader ).addURL( artifact.getFile().toURL() ); - } - } - } - } - - } - - /** * Set the dependency verifier. * * @param dependencyVerifier Dependency Verifier. @@ -1452,14 +1424,14 @@ } /** - * Currently this is just jars. + * Jars and ejbs. * * @param d * @return true if the given dependency belongs on the classpath */ private boolean isClasspathDependency(Dependency d) { - return d.getType().equals( "jar" ); + return d.getType().equals( "jar" ) || d.getType().equals( "ejb" ); } /** @@ -1607,5 +1579,73 @@ } return id; + } + + /** + * Process the dependencies of the project, adding dependencies to the + * appropriate classloader etc + * + * @param project The project to process + * @param cl The classloader to add dependencies + * @throws MalformedURLException + */ + public void processDependencies() throws MalformedURLException + { + if (getArtifacts() == null) + { + log.debug("No dependencies to process for project " + getName()); + return; + } + + // This may definitely break plugins. + ClassLoader projectClassLoader = getContext().getClassLoader(); + + if ( projectClassLoader instanceof ForeheadClassLoader ) + { + // add the dependencies to the classpath + for ( Iterator i = getArtifacts().iterator(); i.hasNext(); ) + { + ForeheadClassLoader loader = (ForeheadClassLoader)projectClassLoader; + Artifact artifact = (Artifact) i.next(); + // get correct classloader + String classLoader = artifact.getDependency().getProperty( "classloader" ); + if (classLoader != null) + { + loader = Forehead.getInstance().getClassLoader( classLoader ); + if (loader == null) + { + log.info("classloader '" + classLoader + + "' not found. Adding dependencies to the project classloader instead"); + loader = (ForeheadClassLoader)projectClassLoader; + } + } + + // add to classloader + if (artifact.exists()) + { + if (isClasspathDependency(artifact.getDependency())) + { + loader.addURL( artifact.getFile().toURL() ); + } + else + { + log.debug("Non classpath dependency: '" + artifact.getFile() + "'" + + " not added to classpath " + loader); + } + } + else + { + log.info("Artifact '" + artifact.getFile() + "' not found to add to classpath"); + } + + // FIXME: handle plugin dependencies here - download from remote repos + // and install + } + } + + // FIXME: Don't know why we're doing this? + // Explicity set the classloader used to find resources. As we just + // poked all the dependencies into the classloader. + getContext().setClassLoader( projectClassLoader ); } }
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]