vertx redeploy arguments not work with exec-maven-plugin

359 views Asked by At

I create a project by the Vert.x starter, use command mvn exec:java to start.

And when I add the redeploy arguments,

      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>exec-maven-plugin</artifactId>
        <version>${exec-maven-plugin.version}</version>
        <configuration>
          <mainClass>io.vertx.core.Launcher</mainClass>
          <arguments>
            <argument>run</argument>
            <argument>--redeploy=src/**/*.java</argument> <!-- just add this line -->
            <argument>${main.verticle}</argument>
          </arguments>
        </configuration>
      </plugin>

get a error:

java.lang.Exception: classworlds configuration not specified nor found in the classpath
        at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:397)
        at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:347)

how to make this Vert.x project support auto redeploy?

1

There are 1 answers

4
tsegismont On

The exec:java goal runs the application in the current VM. As a consequence, the java.class.path system property is set to the classpath that started Maven.

Unfortunately, this is what the Vert.x redeploy mode uses to determine the classpath of the Vert.x app that it should start as a forked process. This is why classes are missing and this exception is printed.

As a workaround, you can switch to the exec:exec goal and this configuration:

<plugin>
  <groupId>org.codehaus.mojo</groupId>
  <artifactId>exec-maven-plugin</artifactId>
  <version>3.0.0</version>
  <configuration>
    <executable>java</executable>
    <commandlineArgs>-cp %classpath io.vertx.core.Launcher run --redeploy=src/**/*.java --on-redeploy="mvn compile" --launcher-class=io.vertx.core.Launcher ${main.verticle}</commandlineArgs>
  </configuration>
</plugin>