exec-maven-plugin
exec-maven-plugin copied to clipboard
Using exec:exec with plugin dependencies and executableDependency
I want to execute a java class, but I want to run it async and hence why I am using exec:exec, but there does not seem to be a way to do that and at the same time use specific plugin dependencies (don't want project dependencies). This works fine with exec:java but not for exec:exec. The documentation says to omit executable when using executableDependency but then it just tries to run the jar directly (without java).
Is this something that is not supported or am I just not configuring it properly?
This is my configuration:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.6.0</version>
<executions>
<execution>
<id>start-ipg</id>
<phase>pre-integration-test</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<includeProjectDependencies>false</includeProjectDependencies>
<includePluginDependencies>true</includePluginDependencies>
<executableDependency>
<groupId>com.xxx.integration</groupId>
<artifactId>test-dummy</artifactId>
</executableDependency>
<executable>java</executable>
<arguments>
<argument>com.xxx.integration.dummy.DummyStarter</argument>
<argument>-startup</argument>
</arguments>
<async>true</async>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>com.xxx.integration</groupId>
<artifactId>test-dummy</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
</dependencies>
</plugin>
I´ve got the same Problem. The jar-File i will exec runs System.exit(0). Because of this, maven will be exit because the are running in the same VM. Now I Try to run it with exec so they are in different VM´s.
Do you have any solutions?
Have the exact same issues as @DanielFuchs98. Either this needs to be supported or exec:java forking should be supported.
I too am having this very same problem. But I figured out a workaround.
The jar that you depend on will get downloaded into the maven repo. So, point to it explicitly.
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<dependencies>
<dependency>
<groupId>com.example</groupId>
<artifactId>some-cli</artifactId>
<version>${some=cli.version}</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>exec-stuff-and-junk</id>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>java</executable>
<arguments>
<argument>-classpath</argument>
<argument>${settings.localRepository}/com/example/some-cli/${some-cli.version}/some-cli-${some-cli.version}.jar</argument>
<argument>com.example.cli.MyAwesomeCLI</argument>
<argument>stuff</argument>
<argument>and</argument>
<argument>junk</argument>
</arguments>
</configuration>
</plugin>
So much winning! This is still a bug though. Super annoying.
@charlie-harvey Thanks, that worked.
I had a similar problem that I solved with the </classpath>
parameter. Take a look of my solution at Stack Overflow
See https://stackoverflow.com/questions/44409624/maven-execjava-run-executable-plugin-dependency-jar-results-in-npe.
It states that executableDependency is for native libraries.
Using includePluginDependencies
was sufficient in my case.
The includePluginDependencies
suggestion will not work in case you need to use a different workingDirectory
or async
execution.
Therefore the executableDependency
functionality should be extended to use java -jar
in case the dependency is of the default type
jar
, while it should just use it as executable otherwise. The Jar file might have to include all its dependencies like as generated by the shade plugin.
Alternatively the includePluginDependencies
should also be supported for the <classpath>
element, which might be easier (cleaner?) to be implement.
I think that at least the exec
goal should support the includePluginDependenciessuggestion
and the dependencies must be included in de <classpath>
element.