reactiverse / vertx-maven-plugin

A Maven plugin for pimping the build of your Vert.x applications
https://reactiverse.io/vertx-maven-plugin/
Apache License 2.0
74 stars 15 forks source link

On Windows, command line may be too long #79

Closed Riduidel closed 4 years ago

Riduidel commented 5 years ago

I'm using vertx-maven-plugin on Windows. I have an application with the following dependency set

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>io.vertx</groupId>
            <artifactId>vertx-stack-depchain</artifactId>
            <version>${vertx.version}</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>
<dependencies>
    <dependency>
        <groupId>io.vertx</groupId>
        <artifactId>vertx-core</artifactId>
    </dependency>

    <dependency>
        <groupId>org.jboss.weld.vertx</groupId>
        <artifactId>weld-vertx-web</artifactId>
        <version>${weld-vertx.version}</version>
    </dependency>
    <!-- Faster injection scanning ! -->
    <dependency>
        <groupId>org.jboss</groupId>
        <artifactId>jandex</artifactId>
        <version>2.0.5.Final</version>
    </dependency>

    <dependency>
        <groupId>io.vertx</groupId>
        <artifactId>vertx-amqp-bridge</artifactId>
    </dependency>
    <dependency>
        <groupId>io.vertx</groupId>
        <artifactId>vertx-kafka-client</artifactId>
    </dependency>

    <dependency>
        <groupId>io.vertx</groupId>
        <artifactId>vertx-config</artifactId>
    </dependency>
    <dependency>
        <groupId>io.vertx</groupId>
        <artifactId>vertx-config-consul</artifactId>
        <version>${vertx.version}</version>
    </dependency>

    <dependency>
        <groupId>com.github.yunyu.vertx-console</groupId>
        <artifactId>vertx-console-base</artifactId>
        <version>${vertx.console.version}</version>
    </dependency>
    <!-- Insert console pages here, e.g. -->
    <dependency>
        <groupId>com.github.yunyu.vertx-console</groupId>
        <artifactId>vertx-console-services</artifactId>
        <version>${vertx.console.version}</version>
    </dependency>
    <dependency>
        <groupId>com.github.yunyu.vertx-console</groupId>
        <artifactId>vertx-console-metrics</artifactId>
        <version>${vertx.console.version}</version>
    </dependency>
    <dependency>
        <groupId>io.prometheus</groupId>
        <artifactId>simpleclient_hotspot</artifactId>
        <version>0.5.0</version>
    </dependency>
    <dependency>
        <groupId>io.prometheus</groupId>
        <artifactId>simpleclient_dropwizard</artifactId>
        <version>0.5.0</version>
    </dependency>
    <dependency>
        <groupId>com.github.yunyu</groupId>
        <artifactId>prometheus-jvm-extras</artifactId>
        <version>1.2-SNAPSHOT</version>
    </dependency>
    <dependency>
        <groupId>com.github.yunyu.vertx-console</groupId>
        <artifactId>vertx-console-logging</artifactId>
        <version>${vertx.console.version}</version>
    </dependency>
    <dependency>
        <groupId>com.github.yunyu.vertx-console</groupId>
        <artifactId>vertx-console-circuit-breakers</artifactId>
        <version>${vertx.console.version}</version>
    </dependency>
    <dependency>
        <groupId>io.vertx</groupId>
        <artifactId>vertx-dropwizard-metrics</artifactId>
    </dependency>
    <dependency>
        <groupId>com.github.yunyu.vertx-console</groupId>
        <artifactId>vertx-console-health</artifactId>
        <version>${vertx.console.version}</version>
    </dependency>
    <dependency>
      <groupId>io.vertx</groupId>
      <artifactId>vertx-health-check</artifactId>
    </dependency>
    <dependency>
        <groupId>com.github.yunyu.vertx-console</groupId>
        <artifactId>vertx-console-http-clients</artifactId>
        <version>${vertx.console.version}</version>
    </dependency>

    <dependency>
        <groupId>io.vertx</groupId>
        <artifactId>vertx-junit5</artifactId>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.assertj</groupId>
        <artifactId>assertj-core</artifactId>
        <version>3.11.1</version>
        <scope>test</scope>
    </dependency>
</dependencies>

When running mvn vertx:run, I have the following information message [INFO] La ligne de commande est trop longue. In other words [INFO] Command line is too long. Running the same build with X reveals the command line to be

cmd.exe /X /C ""C:\Program Files\Java\jdk1.8.0_144\jre\bin\java.exe" -cp C:\Users\nicolas-delsaux\Documents\A***\activemq2kafka\target\classes;C:\Users\nicolas-delsaux\.m2\repository\io\vertx\vertx-core\3.5.4\vertx-core-3.5.4.jar;C:\Users\nicolas-delsaux\.m2\repository\org\jboss\weld\vertx\weld-vertx-web\1.2.0.Final\weld-vertx-web-1.2.0.Final.jar;C:\Users\nicolas-delsaux\.m2\repository\org\jboss\jandex\2.0.5.Final\jandex-2.0.5.Final.jar;C:\Users\nicolas-delsaux\.m2\repository\io\vertx\vertx-amqp-bridge\3.5.4\vertx-amqp-bridge-3.5.4.jar;C:\Users\nicolas-delsaux\.m2\repository\io\vertx\vertx-kafka-client\3.5.4\vertx-kafka-client-3.5.4.jar;C:\Users\nicolas-delsaux\.m2\repository\io\vertx\vertx-config\3.5.4\vertx-config-3.5.4.jar;C:\Users\nicolas-delsaux\.m2\repository\io\vertx\vertx-config-consul\3.5.4\vertx-config-consul-3.5.4.jar;C:\Users\nicolas-delsaux\.m2\repository\com\github\yunyu\vertx-console\vertx-console-base\ca8b2b517f\vertx-console-base-ca8b2b517f.jar;C:\Users\nicolas-delsaux\.m2\repository\com\github\yunyu\vertx-console\vertx-console-services\ca8b2b517f\vertx-console-services-ca8b2b517f.jar;C:\Users\nicolas-delsaux\.m2\repository\com\github\yunyu\vertx-console\vertx-console-metrics\ca8b2b517f\vertx-console-metrics-ca8b2b517f.jar;C:\Users\nicolas-delsaux\.m2\repository\io\prometheus\simpleclient_hotspot\0.5.0\simpleclient_hotspot-0.5.0.jar;C:\Users\nicolas-delsaux\.m2\repository\io\prometheus\simpleclient_dropwizard\0.5.0\simpleclient_dropwizard-0.5.0.jar;C:\Users\nicolas-delsaux\.m2\repository\com\github\yunyu\prometheus-jvm-extras\1.2-SNAPSHOT\prometheus-jvm-extras-1.2-SNAPSHOT.jar;C:\Users\nicolas-delsaux\.m2\repository\com\github\yunyu\vertx-console\vertx-console-logging\ca8b2b517f\vertx-console-logging-ca8b2b517f.jar;C:\Users\nicolas-delsaux\.m2\repository\com\github\yunyu\vertx-console\vertx-console-circuit-breakers\ca8b2b517f\vertx-console-circuit-breakers-ca8b2b517f.jar;C:\Users\nicolas-delsaux\.m2\repository\io\vertx\vertx-dropwizard-metrics\3.5.4\vertx-dropwizard-metrics-3.5.4.jar;C:\Users\nicolas-delsaux\.m2\repository\com\github\yunyu\vertx-console\vertx-console-health\ca8b2b517f\vertx-console-health-ca8b2b517f.jar;C:\Users\nicolas-delsaux\.m2\repository\io\vertx\vertx-health-check\3.5.4\vertx-health-check-3.5.4.jar;C:\Users\nicolas-delsaux\.m2\repository\com\github\yunyu\vertx-console\vertx-console-http-clients\ca8b2b517f\vertx-console-http-clients-ca8b2b517f.jar;C:\Users\nicolas-delsaux\.m2\repository\io\vertx\vertx-core\3.5.4\vertx-core-3.5.4.jar;C:\Users\nicolas-delsaux\.m2\repository\io\netty\netty-common\4.1.19.Final\netty-common-4.1.19.Final.jar;C:\Users\nicolas-delsaux\.m2\repository\io\netty\netty-buffer\4.1.19.Final\netty-buffer-4.1.19.Final.jar;C:\Users\nicolas-delsaux\.m2\repository\io\netty\netty-transport\4.1.19.Final\netty-transport-4.1.19.Final.jar;C:\Users\nicolas-delsaux\.m2\repository\io\netty\netty-handler\4.1.19.Final\netty-handler-4.1.19.Final.jar;C:\Users\nicolas-delsaux\.m2\repository\io\netty\netty-codec\4.1.19.Final\netty-codec-4.1.19.Final.jar;C:\Users\nicolas-delsaux\.m2\repository\io\netty\netty-handler-proxy\4.1.19.Final\netty-handler-proxy-4.1.19.Final.jar;C:\Users\nicolas-delsaux\.m2\repository\io\netty\netty-codec-socks\4.1.19.Final\netty-codec-socks-4.1.19.Final.jar;C:\Users\nicolas-delsaux\.m2\repository\io\netty\netty-codec-http\4.1.19.Final\netty-codec-http-4.1.19.Final.jar;C:\Users\nicolas-delsaux\.m2\repository\io\netty\netty-codec-http2\4.1.19.Final\netty-codec-http2-4.1.19.Final.jar;C:\Users\nicolas-delsaux\.m2\repository\io\netty\netty-resolver\4.1.19.Final\netty-resolver-4.1.19.Final.jar;C:\Users\nicolas-delsaux\.m2\repository\io\netty\netty-resolver-dns\4.1.19.Final\netty-resolver-dns-4.1.19.Final.jar;C:\Users\nicolas-delsaux\.m2\repository\io\netty\netty-codec-dns\4.1.19.Final\netty-codec-dns-4.1.19.Final.jar;C:\Users\nicolas-delsaux\.m2\repository\com\fasterxml\jackson\core\jackson-core\2.9.6\jackson-core-2.9.6.jar;C:\Users\nicolas-delsaux\.m2\repository\com\fasterxml\jackson\core\jackson-databind\2.9.6\jackson-databind-2.9.6.jar;C:\Users\nicolas-delsaux\.m2\repository\com\fasterxml\jackson\core\jackson-annotations\2.9.6\jackson-annotations-2.9.6.jar;C:\Users\nicolas-delsaux\.m2\repository\org\jboss\weld\vertx\weld-vertx-web\1.2.0.Final\weld-vertx-web-1.2.0.Final.jar;C:\Users\nicolas-delsaux\.m2\repository\org\jboss\weld\vertx\weld-vertx-core\1.2.0.Final\weld-vertx-core-1.2.0.Final.jar;C:\Users\nicolas-delsaux\.m2\repository\org\jboss\weld\se\weld-se-core\3.0.1.Final\weld-se-core-3.0.1.Final.jar;C:\Users\nicolas-delsaux\.m2\repository\org\jboss\weld\environment\weld-environment-common\3.0.1.Final\weld-environment-common-3.0.1.Final.jar;C:\Users\nicolas-delsaux\.m2\repository\org\jboss\weld\weld-core-impl\3.0.1.Final\weld-core-impl-3.0.1.Final.jar;C:\Users\nicolas-delsaux\.m2\repository\org\jboss\weld\weld-api\3.0.SP1\weld-api-3.0.SP1.jar;C:\Users\nicolas-delsaux\.m2\repository\org\jboss\weld\weld-spi\3.0.SP1\weld-spi-3.0.SP1.jar;C:\Users\nicolas-delsaux\.m2\repository\javax\annotation\javax.annotation-api\1.3\javax.annotation-api-1.3.jar;C:\Users\nicolas-delsaux\.m2\repository\org\jboss\spec\javax\el\jboss-el-api_3.0_spec\1.0.7.Final\jboss-el-api_3.0_spec-1.0.7.Final.jar;C:\Users\nicolas-delsaux\.m2\repository\org\jboss\spec\javax\interceptor\jboss-interceptors-api_1.2_spec\1.0.0.Final\jboss-interceptors-api_1.2_spec-1.0.0.Final.jar;C:\Users\nicolas-delsaux\.m2\repository\org\jboss\logging\jboss-logging\3.2.1.Final\jboss-logging-3.2.1.Final.jar;C:\Users\nicolas-delsaux\.m2\repository\org\jboss\weld\probe\weld-probe-core\3.0.1.Final\weld-probe-core-3.0.1.Final.jar;C:\Users\nicolas-delsaux\.m2\repository\javax\enterprise\cdi-api\2.0\cdi-api-2.0.jar;C:\Users\nicolas-delsaux\.m2\repository\javax\inject\javax.inject\1\javax.inject-1.jar;C:\Users\nicolas-delsaux\.m2\repository\org\jboss\classfilewriter\jboss-classfilewriter\1.2.1.Final\jboss-classfilewriter-1.2.1.Final.jar;C:\Users\nicolas-delsaux\.m2\repository\me\escoffier\vertx\vertx-completable-future\0.1.2\vertx-completable-future-0.1.2.jar;C:\Users\nicolas-delsaux\.m2\repository\io\vertx\vertx-web\3.5.4\vertx-web-3.5.4.jar;C:\Users\nicolas-delsaux\.m2\repository\io\vertx\vertx-bridge-common\3.5.4\vertx-bridge-common-3.5.4.jar;C:\Users\nicolas-delsaux\.m2\repository\org\jboss\jandex\2.0.5.Final\jandex-2.0.5.Final.jar;C:\Users\nicolas-delsaux\.m2\repository\io\vertx\vertx-amqp-bridge\3.5.4\vertx-amqp-bridge-3.5.4.jar;C:\Users\nicolas-delsaux\.m2\repository\io\vertx\vertx-proton\3.5.4\vertx-proton-3.5.4.jar;C:\Users\nicolas-delsaux\.m2\repository\org\apache\qpid\proton-j\0.25.0\proton-j-0.25.0.jar;C:\Users\nicolas-delsaux\.m2\repository\io\vertx\vertx-kafka-client\3.5.4\vertx-kafka-client-3.5.4.jar;C:\Users\nicolas-delsaux\.m2\repository\org\apache\kafka\kafka-clients\1.0.0\kafka-clients-1.0.0.jar;C:\Users\nicolas-delsaux\.m2\repository\org\lz4\lz4-java\1.4\lz4-java-1.4.jar;C:\Users\nicolas-delsaux\.m2\repository\org\xerial\snappy\snappy-java\1.1.4\snappy-java-1.1.4.jar;C:\Users\nicolas-delsaux\.m2\repository\org\apache\kafka\kafka_2.12\1.0.0\kafka_2.12-1.0.0.jar;C:\Users\nicolas-delsaux\.m2\repository\net\sf\jopt-simple\jopt-simple\5.0.4\jopt-simple-5.0.4.jar;C:\Users\nicolas-delsaux\.m2\repository\com\yammer\metrics\metrics-core\2.2.0\metrics-core-2.2.0.jar;C:\Users\nicolas-delsaux\.m2\repository\com\101tec\zkclient\0.10\zkclient-0.10.jar;C:\Users\nicolas-delsaux\.m2\repository\org\apache\zookeeper\zookeeper\3.4.10\zookeeper-3.4.10.jar;C:\Users\nicolas-delsaux\.m2\repository\org\slf4j\slf4j-api\1.7.21\slf4j-api-1.7.21.jar;C:\Users\nicolas-delsaux\.m2\repository\org\slf4j\slf4j-log4j12\1.7.21\slf4j-log4j12-1.7.21.jar;C:\Users\nicolas-delsaux\.m2\repository\log4j\log4j\1.2.16\log4j-1.2.16.jar;C:\Users\nicolas-delsaux\.m2\repository\io\vertx\vertx-config\3.5.4\vertx-config-3.5.4.jar;C:\Users\nicolas-delsaux\.m2\repository\io\vertx\vertx-config-consul\3.5.4\vertx-config-consul-3.5.4.jar;C:\Users\nicolas-delsaux\.m2\repository\io\vertx\vertx-consul-client\3.5.4\vertx-consul-client-3.5.4.jar;C:\Users\nicolas-delsaux\.m2\repository\io\vertx\vertx-web-client\3.5.4\vertx-web-client-3.5.4.jar;C:\Users\nicolas-delsaux\.m2\repository\io\vertx\vertx-web-common\3.5.4\vertx-web-common-3.5.4.jar;C:\Users\nicolas-delsaux\.m2\repository\com\github\yunyu\vertx-console\vertx-console-base\ca8b2b517f\vertx-console-base-ca8b2b517f.jar;C:\Users\nicolas-delsaux\.m2\repository\com\github\yunyu\vertx-console\vertx-console-services\ca8b2b517f\vertx-console-services-ca8b2b517f.jar;C:\Users\nicolas-delsaux\.m2\repository\com\github\yunyu\vertx-console\vertx-console-metrics\ca8b2b517f\vertx-console-metrics-ca8b2b517f.jar;C:\Users\nicolas-delsaux\.m2\repository\io\prometheus\simpleclient_hotspot\0.5.0\simpleclient_hotspot-0.5.0.jar;C:\Users\nicolas-delsaux\.m2\repository\io\prometheus\simpleclient\0.5.0\simpleclient-0.5.0.jar;C:\Users\nicolas-delsaux\.m2\repository\io\prometheus\simpleclient_dropwizard\0.5.0\simpleclient_dropwizard-0.5.0.jar;C:\Users\nicolas-delsaux\.m2\repository\io\dropwizard\metrics\metrics-core\3.1.2\metrics-core-3.1.2.jar;C:\Users\nicolas-delsaux\.m2\repository\com\github\yunyu\prometheus-jvm-extras\1.2-SNAPSHOT\prometheus-jvm-extras-1.2-SNAPSHOT.jar;C:\Users\nicolas-delsaux\.m2\repository\com\github\yunyu\vertx-console\vertx-console-logging\ca8b2b517f\vertx-console-logging-ca8b2b517f.jar;C:\Users\nicolas-delsaux\.m2\repository\com\github\yunyu\vertx-console\vertx-console-circuit-breakers\ca8b2b517f\vertx-console-circuit-breakers-ca8b2b517f.jar;C:\Users\nicolas-delsaux\.m2\repository\io\vertx\vertx-dropwizard-metrics\3.5.4\vertx-dropwizard-metrics-3.5.4.jar;C:\Users\nicolas-delsaux\.m2\repository\com\github\yunyu\vertx-console\vertx-console-health\ca8b2b517f\vertx-console-health-ca8b2b517f.jar;C:\Users\nicolas-delsaux\.m2\repository\io\vertx\vertx-health-check\3.5.4\vertx-health-check-3.5.4.jar;C:\Users\nicolas-delsaux\.m2\repository\io\vertx\vertx-auth-common\3.5.4\vertx-auth-common-3.5.4.jar;C:\Users\nicolas-delsaux\.m2\repository\com\github\yunyu\vertx-console\vertx-console-http-clients\ca8b2b517f\vertx-console-http-clients-ca8b2b517f.jar;C:\ProgramData\chocolatey\lib\maven\apache-maven-3.5.4\bin\..\boot\plexus-classworlds-2.5.2.jar io.vertx.core.Launcher run com.A***.psh.infra.activemq2kafka.MainVerticle --redeploy=C:\Users\nicolas-delsaux\Documents\A***\activemq2kafka\target\classes/**/* --redeploy-scan-period=1000 redeploy-termination-period=1000 --java-opts=vertx.metrics.options.enabled=true vertx.metrics.options.registryName=aMQ2000-registry -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005 --launcher-class="io.vertx.core.Launcher" -conf C:\Users\nicolas-delsaux\Documents\A***\activemq2kafka\target\config\activemq2kafka.json org.jboss.weld.development=true"

According to notepad++, this command line is 10.794 characters long ... Yes, a little too much. Is there a workaround to avoid having the whole CLASSPATH sent as command line parameters ? Because, according to common wisdom, Windows cmd.exe has a command-line length limit of 8192 characters.

Riduidel commented 5 years ago

Since, as of today, this plugin doesn't support pom reloading, it could be a good thing to generate the uber-jar before to run the application. This way, we wouldn't have to fight against this limitation ...

Riduidel commented 5 years ago

So it seems the most classical "Java" workaround is to build a multi-module maven project,

  1. One module takes all dependencies and generates an assembly jar
  2. The vertx module uses that assembly as sole dependency.

I'm not that fond of this method, but I think it's the simplest possible one.

Riduidel commented 5 years ago

It appears the workaround didn't work. Indeed, maven-assembly-plugin can't handle service porperties files, and maven-shade-plugin, although configured to correctly load those files, has failures regarding weld CDI dependencies in my project. So it is time to take a look at alternatives to cmd.exe.

According to StackOverflow, it seems possible to run PowerShell and commands from java processes, I will try to patch the plugin to support that feature ...

Riduidel commented 5 years ago

Daaaaamn ... JavaProcessExecutor delegates the construction of the command-line shell to plexus-utils ... which knows nothing of PowerShell !

Riduidel commented 5 years ago

Easiest workaround, as of today, is to use subst to map the maven repository to a virtual driver (I used M:). This gained me enough characters to have my application working.

gpthome commented 5 years ago

We too experienced this issue with recent versions of the plugin on Windows. We did not experience issues with version 1.0.15, but we do with 1.0.17 and 1.0.18. When turning on Maven debugging, we too see our commands are slightly longer than 8192 characters and receive the same error message you mentioned. We have reviewed and reduced our dependencies (which are added to the classpath when running) as much as possible.

Dudeplayz commented 4 years ago

It's really annoying... I can't create a simple project with some default dependencies because it exceeds more than 10000 characters.

tsegismont commented 4 years ago

@Riduidel in the past I also had the issue on other projects. We moved the Maven repo to C:\mrepo. The subst workaround is more effective though.

Would you mind to send a PR for the documentation? If the workaround is documented, we can close this issue.

Dudeplayz commented 4 years ago

I temporarily fixed it with subst M: C:\{user_path}\.m2\repository and then set the maven repository in IntelliJ to M:. But I think it should be fixed by the plugin and not with a workaround. IntelliJ is fixing this issue by creating a temporary file, writing the dependencies in it and passing the file to the classpath parameter.

tsegismont commented 4 years ago

@Dudeplayz do you mean creating a temporary jar file with classpath references? Would you mind to send a PR?

Dudeplayz commented 4 years ago

IntelliJ seems to support multiple ways to solve this: https://blog.jetbrains.com/idea/2017/10/intellij-idea-2017-3-eap-configurable-command-line-shortener-and-more/ I've never done a PR before and I am not sure if I have enough knowledge to do it the "right" way for an open-source project. I will think about it.

Riduidel commented 4 years ago

Would you mind to send a PR for the documentation? If the workaround is documented, we can close this issue.

Sorry for the incredibly late reply. @tsegismont where do you want that documentation to be added ?

tsegismont commented 4 years ago

No problem @Riduidel

The doc is here https://github.com/reactiverse/vertx-maven-plugin/tree/master/src/main/asciidoc