Owen Jacobson wrote: > Hi folks, > > I'm working on upgrading a Maven plugin that runs Apache DS[0] to use the > latest version of their software. Unfortunately, the latest version of > their software does something slightly slack-jawed on startup: it inspects > the java.class.path system property to locate JARs that contain core LDAP > schemata. There is no alternate loader mechanism. > > When this happens inside a plugin, the java.class.path system property > contains one JAR: Maven's own launcher JAR. > > I think the shortest path from where I am to working software is to fake > up java.class.path before running Apache DS and then to reset it back to > its "real" value after the server starts. However, in order to do this, I > need to build a classpath-like string containing the JARs Apache DS needs. > > These JARs are already listed in the plugin's dependencies (and when the > plugin runs, are available in the local repository). I'd like to use that > information if possible, rather than hard-coding specific JAR names into > the plugin. However, after spending half the day looking through various > existing plugins, I'm no closer to doing this than I was this morning. > > 1. Is there a shortcut I missed that produces exactly the string (or list > of JARs) I need? 2. If not, is there a reasonable way to obtain the > dependency artifacts for a plugin? 3. If not, what's a better solution > that doesn't involve patching Apache DS?
Extracts from the AbstractJaxwsMojo in the jaxws-maven-plugin at Codehaus Mojo: ========= %< ========= List classpathFiles = project.getCompileClasspathElements(); URL[] urls = new URL[classpathFiles.size()]; StringBuffer classPath = new StringBuffer(); for ( int i = 0; i < classpathFiles.size(); ++i ) { urls[i] = new File( (String) classpathFiles.get( i ) ).toURL().toURI(); classPath.append( (String) classpathFiles.get( i ) ); classPath.append( File.pathSeparatorChar ); } URLClassLoader cl = new URLClassLoader( urls, Thread.currentThread().getContextClassLoader() ); Thread.currentThread().setContextClassLoader( cl ); System.setProperty( "java.class.path", classPath.toString() ); ========= %< ========= Obviously you should restore the classloader and system property later on. - Jörg --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@maven.apache.org For additional commands, e-mail: users-h...@maven.apache.org