diff --git a/plugin/src/main/java/org/vertx/maven/plugin/mojo/BaseVertxMojo.java b/plugin/src/main/java/org/vertx/maven/plugin/mojo/BaseVertxMojo.java index c568794..0629c9c 100644 --- a/plugin/src/main/java/org/vertx/maven/plugin/mojo/BaseVertxMojo.java +++ b/plugin/src/main/java/org/vertx/maven/plugin/mojo/BaseVertxMojo.java @@ -29,11 +29,14 @@ import java.net.URLClassLoader; import java.util.ArrayList; import java.util.List; +import java.util.regex.Pattern; import static java.nio.file.Files.readAllBytes; public abstract class BaseVertxMojo extends AbstractMojo { + private Pattern CLASSPATH_DELIMITER = Pattern.compile(":"); + @Component protected MavenProject project; @@ -60,6 +63,22 @@ public abstract class BaseVertxMojo extends AbstractMojo { @Parameter protected File configFile = null; + /** + *

+ * The extra classpath for this verticle. + *

+ *

+ * If the path is relative (does not start with / or a drive letter like + * C:), the path is relative to the directory containing the POM. + *

+ *

+ * An example value would be src/main/resources/:src/test/resources/ + *

+ */ + + @Parameter + protected String classpath = null; + /** * The number of instances of the verticle to instantiate in the vert.x * server. The default is 1. @@ -73,6 +92,8 @@ public abstract class BaseVertxMojo extends AbstractMojo { @Parameter(defaultValue = "target/mods") protected File modsDir; + + protected JsonObject getConf() { JsonObject config = null; final String confContent = readConfigFile(configFile); @@ -106,6 +127,7 @@ protected ClassLoader createClassLoader() throws Exception { List urls = new ArrayList<>(); addURLs(urls, "src/main/platform_lib"); addURLs(urls, "src/main/resources/platform_lib"); + addClasspathResources(urls); return new LoadFirstClassLoader(urls.toArray(new URL[urls.size()]), getClass().getClassLoader()); } @@ -134,6 +156,20 @@ private void addURLs(List urls, String dirName) throws IOException { } } + private void addClasspathResources(final List urls) throws IOException{ + if(classpath != null){ + String[] paths = CLASSPATH_DELIMITER.split(classpath); + if(paths != null){ + for(String path: paths){ + File dir = new File(path); + if(dir.exists()){ + urls.add(dir.getCanonicalFile().toURI().toURL()); + } + } + } + } + } + private static class LoadFirstClassLoader extends URLClassLoader { private final ClassLoader parent; diff --git a/plugin/src/main/java/org/vertx/maven/plugin/mojo/VertxFatJarMojo.java b/plugin/src/main/java/org/vertx/maven/plugin/mojo/VertxFatJarMojo.java index 5fcd7f0..da092e8 100644 --- a/plugin/src/main/java/org/vertx/maven/plugin/mojo/VertxFatJarMojo.java +++ b/plugin/src/main/java/org/vertx/maven/plugin/mojo/VertxFatJarMojo.java @@ -44,9 +44,8 @@ public void execute() throws MojoExecutionException { if (createFatJar) { System.setProperty("vertx.mods", modsDir.getAbsolutePath()); final PlatformManager pm = factory.createPlatformManager(); - final CountDownLatch latch = new CountDownLatch(1); - pm.makeFatJar(moduleName, "target", + pm.makeFatJar(moduleName, project.getBuild().getDirectory(), new Handler>() { @Override public void handle(final AsyncResult event) {