Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using exec:exec with plugin dependencies and executableDependency #79

Closed
ShahinKordasti opened this issue Jun 14, 2017 · 9 comments · Fixed by #432
Closed

Using exec:exec with plugin dependencies and executableDependency #79

ShahinKordasti opened this issue Jun 14, 2017 · 9 comments · Fixed by #432

Comments

@ShahinKordasti
Copy link

ShahinKordasti commented Jun 14, 2017

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>
@dfoxg
Copy link

dfoxg commented Sep 1, 2017

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?

@samgurtman-zz
Copy link

Have the exact same issues as @DanielFuchs98. Either this needs to be supported or exec:java forking should be supported.

@charlie-harvey
Copy link

charlie-harvey commented Mar 2, 2018

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.

@bhagyas
Copy link

bhagyas commented May 8, 2018

@charlie-harvey Thanks, that worked.

@pauloneves
Copy link

pauloneves commented Dec 4, 2018

I had a similar problem that I solved with the </classpath> parameter. Take a look of my solution at Stack Overflow

@vkopichenko
Copy link

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.

@dranuhl
Copy link

dranuhl commented Sep 8, 2020

The includePluginDependenciessuggestion 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.

@lujop
Copy link

lujop commented Jan 10, 2022

I think that at least the exec goal should support the includePluginDependenciessuggestion and the dependencies must be included in de <classpath> element.

@sebthom
Copy link
Contributor

sebthom commented Jun 1, 2024

@slawekjaranowski I think this issue can be closed now that #432 is merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.