Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,39 +32,43 @@
import static org.vertx.java.platform.PlatformLocator.factory;

@Mojo(name = "fatJar", requiresProject = true, threadSafe = false, requiresDependencyResolution =
COMPILE_PLUS_RUNTIME)
COMPILE_PLUS_RUNTIME)
public class VertxFatJarMojo extends BaseVertxMojo {

@Parameter(property = "vertx.createFatJar", defaultValue = "false")
protected Boolean createFatJar;
@Parameter(property = "vertx.createFatJar", defaultValue = "false")
protected Boolean createFatJar;

@Override
public void execute() throws MojoExecutionException {
try {
if (createFatJar) {
System.setProperty("vertx.mods", modsDir.getAbsolutePath());
final PlatformManager pm = factory.createPlatformManager();
private static final Object lock = new Object();

final CountDownLatch latch = new CountDownLatch(1);
pm.makeFatJar(moduleName, project.getBasedir().getAbsolutePath() + "/target",
new Handler<AsyncResult<Void>>() {
@Override
public void handle(final AsyncResult<Void> event) {
if (event.succeeded()) {
latch.countDown();
} else {
if (!event.succeeded()) {
getLog().error(event.cause());
}
latch.countDown();
}
}
});
latch.await(MAX_VALUE, MILLISECONDS);
}
} catch (final Exception e) {
throw new MojoExecutionException(e.getMessage());
}
}
@Override
public void execute() throws MojoExecutionException {
synchronized (lock) {
try {
if (createFatJar) {
System.setProperty("vertx.mods", modsDir.getAbsolutePath());
final PlatformManager pm = factory.createPlatformManager();

final CountDownLatch latch = new CountDownLatch(1);
pm.makeFatJar(moduleName, project.getBasedir().getAbsolutePath() + "/target",
new Handler<AsyncResult<Void>>() {
@Override
public void handle(final AsyncResult<Void> event) {
if (event.succeeded()) {
latch.countDown();
} else {
if (!event.succeeded()) {
getLog().error(event.cause());
}
latch.countDown();
}
}
});
latch.await(MAX_VALUE, MILLISECONDS);
}
} catch (final Exception e) {
throw new MojoExecutionException(e.getMessage());
}
}
}
}

65 changes: 34 additions & 31 deletions plugin/src/main/java/org/vertx/maven/plugin/mojo/VertxInitMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,39 +38,42 @@
@Mojo(name = "init", requiresProject = true, threadSafe = false, requiresDependencyResolution = COMPILE_PLUS_RUNTIME)
public class VertxInitMojo extends BaseVertxMojo {

@Override
public void execute() throws MojoExecutionException {
private static final Object lock = new Object();

try {
setVertxMods();
@Override
public void execute() throws MojoExecutionException {
synchronized (lock) {
try {
setVertxMods();

File cpFile = new File("vertx_classpath.txt");
if (!cpFile.exists()) {
cpFile.createNewFile();
String defaultCp = "src/main/resources\r\n" +
"target/classes\r\n" +
"target/dependencies\r\n" +
"bin\r\n";
try (FileWriter writer = new FileWriter(cpFile)) {
writer.write(defaultCp);
}
}
File cpFile = new File("vertx_classpath.txt");
if (!cpFile.exists()) {
cpFile.createNewFile();
String defaultCp = "src/main/resources\r\n" +
"target/classes\r\n" +
"target/dependencies\r\n" +
"bin\r\n";
try (FileWriter writer = new FileWriter(cpFile)) {
writer.write(defaultCp);
}
}

final PlatformManager pm = factory.createPlatformManager();
final PlatformManager pm = factory.createPlatformManager();

final CountDownLatch latch = new CountDownLatch(1);
pm.createModuleLink(moduleName, new Handler<AsyncResult<Void>>() {
@Override
public void handle(AsyncResult<Void> asyncResult) {
if (!asyncResult.succeeded()) {
getLog().info(asyncResult.cause().getMessage());
}
latch.countDown();
}
});
latch.await(MAX_VALUE, MILLISECONDS);
} catch (final Exception e) {
throw new MojoExecutionException(e.getMessage(), e);
}
}
final CountDownLatch latch = new CountDownLatch(1);
pm.createModuleLink(moduleName, new Handler<AsyncResult<Void>>() {
@Override
public void handle(AsyncResult<Void> asyncResult) {
if (!asyncResult.succeeded()) {
getLog().info(asyncResult.cause().getMessage());
}
latch.countDown();
}
});
latch.await(MAX_VALUE, MILLISECONDS);
} catch (final Exception e) {
throw new MojoExecutionException(e.getMessage(), e);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,39 +15,43 @@
import static org.vertx.java.platform.PlatformLocator.factory;

@Mojo(name = "pullInDeps", requiresProject = true, threadSafe = false, requiresDependencyResolution =
COMPILE_PLUS_RUNTIME)
COMPILE_PLUS_RUNTIME)
public class VertxPullInDepsMojo extends BaseVertxMojo {

@Parameter(property = "vertx.pullInDeps", defaultValue = "false")
protected Boolean pullInDeps;

@Override
public void execute() throws MojoExecutionException {
if (pullInDeps) {
ClassLoader oldTCCL = Thread.currentThread().getContextClassLoader();
try {
setVertxMods();
Thread.currentThread().setContextClassLoader(createClassLoader());
PlatformManager pm = factory.createPlatformManager();

final CountDownLatch latch = new CountDownLatch(1);
pm.pullInDependencies(moduleName,
new Handler<AsyncResult<Void>>() {
@Override
public void handle(final AsyncResult<Void> event) {
if (!event.succeeded()) {
getLog().error(event.cause());
}
latch.countDown();
}
});
latch.await(MAX_VALUE, MILLISECONDS);

} catch (final Exception e) {
throw new MojoExecutionException(e.getMessage());
} finally {
Thread.currentThread().setContextClassLoader(oldTCCL);
}
}
}
private static final Object lock = new Object();

@Parameter(property = "vertx.pullInDeps", defaultValue = "false")
protected Boolean pullInDeps;

@Override
public void execute() throws MojoExecutionException {
synchronized (lock) {
if (pullInDeps) {
ClassLoader oldTCCL = Thread.currentThread().getContextClassLoader();
try {
setVertxMods();
Thread.currentThread().setContextClassLoader(createClassLoader());
PlatformManager pm = factory.createPlatformManager();

final CountDownLatch latch = new CountDownLatch(1);
pm.pullInDependencies(moduleName,
new Handler<AsyncResult<Void>>() {
@Override
public void handle(final AsyncResult<Void> event) {
if (!event.succeeded()) {
getLog().error(event.cause());
}
latch.countDown();
}
});
latch.await(MAX_VALUE, MILLISECONDS);

} catch (final Exception e) {
throw new MojoExecutionException(e.getMessage());
} finally {
Thread.currentThread().setContextClassLoader(oldTCCL);
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@

import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.vertx.java.core.AsyncResult;
import org.vertx.java.core.Handler;
import org.vertx.java.platform.PlatformManager;

import java.util.Collections;
import java.util.Map;
import java.util.concurrent.CountDownLatch;

import static java.lang.Long.MAX_VALUE;
Expand Down Expand Up @@ -36,11 +39,21 @@
@Mojo(name = "runMod", requiresProject = true, threadSafe = false, requiresDependencyResolution = COMPILE_PLUS_RUNTIME)
public class VertxRunModMojo extends BaseVertxMojo {

/**
* List of system properties to set when running a module.
*/
@Parameter
protected Map<String, String> systemPropertyVariables = Collections.emptyMap();

@Override
public void execute() throws MojoExecutionException {

ClassLoader oldTCCL = Thread.currentThread().getContextClassLoader();
try {
for (final Map.Entry<String, String> entry : systemPropertyVariables.entrySet()) {
System.setProperty(entry.getKey(), entry.getValue());
}

setVertxMods();

Thread.currentThread().setContextClassLoader(createClassLoader());
Expand Down