Index: C:/javadev/Develop/maven2/doxia/doxia-sandbox/doxia-maven-plugin/src/main/java/org/apache/maven/doxia/plugin/DoxiaRenderBooksMojo.java =================================================================== --- C:/javadev/Develop/maven2/doxia/doxia-sandbox/doxia-maven-plugin/src/main/java/org/apache/maven/doxia/plugin/DoxiaRenderBooksMojo.java (revision 494373) +++ C:/javadev/Develop/maven2/doxia/doxia-sandbox/doxia-maven-plugin/src/main/java/org/apache/maven/doxia/plugin/DoxiaRenderBooksMojo.java (working copy) @@ -24,12 +24,21 @@ import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; +import org.codehaus.classworlds.ClassRealm; +import org.codehaus.classworlds.ClassWorld; +import org.codehaus.classworlds.ClassWorldException; +import org.codehaus.classworlds.DuplicateRealmException; import org.codehaus.plexus.util.FileUtils; import org.codehaus.plexus.util.StringUtils; import java.io.File; import java.io.IOException; +import java.lang.reflect.Method; +import java.net.URL; +import java.net.URLClassLoader; +import java.util.Enumeration; import java.util.Iterator; +import java.util.LinkedList; import java.util.List; /** @@ -67,6 +76,12 @@ private File generatedDocs; /** + * List of URLs to be added to the class path. + * @parameter + */ + private List classpath; + + /** * BookDoxia component * * @component @@ -82,6 +97,12 @@ public void execute() throws MojoExecutionException, MojoFailureException { + try { + configureClassPath(); + } catch (ClassWorldException e1) { + throw new MojoFailureException(e1, "Configuring class path", ""); + } + for ( Iterator it = books.iterator(); it.hasNext(); ) { Book book = (Book) it.next(); @@ -211,6 +232,34 @@ } } + private void configureClassPath() throws ClassWorldException { + if (classpath == null) + { + return; + } + ClassWorld world = new ClassWorld(); + ClassLoader pcl = Thread.currentThread().getContextClassLoader(); + + ClassRealm realm = world.newRealm("plugin.doxia", pcl); + ClassRealm bookRealm = realm.createChildRealm("books"); + + for ( Iterator iter = classpath.iterator(); iter.hasNext(); ) + { + try + { + String s = (String) iter.next(); + File f = new File(s); + bookRealm.addConstituent(f.toURL()); + + } catch(Exception e) { + getLog().error(e); + } + } + + ClassLoader cl = bookRealm.getClassLoader(); + Thread.currentThread().setContextClassLoader(cl); + } + private String formatResult( ValidationResult result ) { StringBuffer buffer = new StringBuffer();