[Lutingenerator-commits] r375 - in maven-generator-plugin/trunk: . src/main/java/org/codelutin/generator/plugin
Author: chemit Date: 2008-11-17 11:21:33 +0000 (Mon, 17 Nov 2008) New Revision: 375 Modified: maven-generator-plugin/trunk/changelog maven-generator-plugin/trunk/pom.xml maven-generator-plugin/trunk/src/main/java/org/codelutin/generator/plugin/GeneratorPlugin.java Log: - add extraClassPathDirectory parameter to can specify an extra directory to add in classLoader - bump lutingenerator version Modified: maven-generator-plugin/trunk/changelog =================================================================== --- maven-generator-plugin/trunk/changelog 2008-11-17 11:20:09 UTC (rev 374) +++ maven-generator-plugin/trunk/changelog 2008-11-17 11:21:33 UTC (rev 375) @@ -1,4 +1,9 @@ -0.61 chemit 200811?? +0.62 chemit 200811?? + * 20081117 [chemit] + - add extraClassPathDirectory parameter to can specify an extra directory to add in classLoader + - bump lutingenerator version + +0.61 chatellier 20081114 * 20081107 [chatellier] - add test compile dir and test resources in generation gaol * 20081101 [chemit] Modified: maven-generator-plugin/trunk/pom.xml =================================================================== --- maven-generator-plugin/trunk/pom.xml 2008-11-17 11:20:09 UTC (rev 374) +++ maven-generator-plugin/trunk/pom.xml 2008-11-17 11:21:33 UTC (rev 375) @@ -20,7 +20,7 @@ <dependency> <groupId>org.codelutin</groupId> <artifactId>lutingenerator</artifactId> - <version>0.61</version> + <version>0.62-SNAPSHOT</version> <scope>compile</scope> </dependency> Modified: maven-generator-plugin/trunk/src/main/java/org/codelutin/generator/plugin/GeneratorPlugin.java =================================================================== --- maven-generator-plugin/trunk/src/main/java/org/codelutin/generator/plugin/GeneratorPlugin.java 2008-11-17 11:20:09 UTC (rev 374) +++ maven-generator-plugin/trunk/src/main/java/org/codelutin/generator/plugin/GeneratorPlugin.java 2008-11-17 11:21:33 UTC (rev 375) @@ -40,6 +40,9 @@ import org.codelutin.generator.GeneratorTask; import java.io.File; +import java.net.URLClassLoader; +import java.net.URL; +import java.net.MalformedURLException; import java.util.Arrays; import java.util.List; @@ -111,6 +114,14 @@ */ private boolean overwrite = false; + /** + * An extra direcotry to be added to the classpath. + * + * @parameter expression="${generator.extraClassPathDirectory}" + */ + protected File extraClassPathDirectory; + + public void execute() throws MojoExecutionException, MojoFailureException { getLog().info("Effectue toutes les générations et copie les fichiers générés " + "dans le répertoire de compilation"); @@ -147,8 +158,12 @@ generator.setProperties("defaultPackage=" + defaultPackage); generator.setIncludes(includes); - generator.setExcludeTemplates(excludeTemplates==null?java.util.Collections.<String>emptyList():excludeTemplates); + generator.setExcludeTemplates(excludeTemplates == null ? java.util.Collections.<String>emptyList() : excludeTemplates); + if (extraClassPathDirectory != null) { + getLog().info("will add the cp to classloader "+ extraClassPathDirectory); + generator.setLoader(fixClassLoader(extraClassPathDirectory)); + } /* Execution */ generator.execute(); } @@ -158,7 +173,7 @@ * de compilation du projet Maven. */ protected void fixCompileSourceRoots() { - + if (!project.getCompileSourceRoots().contains(destDirGen.getPath())) { getLog().info("add compile source root : " + destDirGen); project.addCompileSourceRoot(destDirGen.getPath()); @@ -182,4 +197,16 @@ project.addTestResource(resources); } } + + protected ClassLoader fixClassLoader(File dirToAdd) throws MojoExecutionException { + try { + // we ask to add the directory in classloader + return new URLClassLoader(new URL[]{dirToAdd.toURI().toURL()}, getClass().getClassLoader()); + } catch (MalformedURLException e) { + throw new MojoExecutionException(e.getMessage()); + } + + + + } }
participants (1)
-
chemit@users.labs.libre-entreprise.org