exec-maven-plugin icon indicating copy to clipboard operation
exec-maven-plugin copied to clipboard

includeProjectDependencies is false by default

Open marcelstoer opened this issue 6 years ago • 2 comments
trafficstars

I was getting java.lang.ClassNotFoundException for a class in the same Maven project as the plugin is running against. This despite the fact that the class was available in target/classes.

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>exec-maven-plugin</artifactId>
    <version>1.6.0</version>
    <executions>
        <execution>
            <phase>prepare-package</phase>
            <goals>
                <goal>java</goal>
            </goals>
        </execution>
    </executions>
    <configuration>
        <mainClass>mypackage.MyClass</mainClass>
    </configuration>
</plugin>

This failed until I added <includeProjectDependencies>true</includeProjectDependencies>.

This shouldn't be necessary as https://github.com/mojohaus/exec-maven-plugin/blob/master/src/main/java/org/codehaus/mojo/exec/ExecJavaMojo.java#L105 says that it's true by default and so does the generated documentation at https://www.mojohaus.org/exec-maven-plugin/java-mojo.html#includeProjectDependencies.

$ mvn --version
Apache Maven 3.6.1 (d66c9c0b3152b2e69ee9bac180bb8fcc8e6af555; 2019-04-04T21:00:29+02:00)
Maven home: /Applications/ApacheGroup/Maven-3.6.1
Java version: 1.8.0_202, vendor: Oracle Corporation, runtime: /Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/Contents/Home/jre
Default locale: en_CH, platform encoding: UTF-8
OS name: "mac os x", version: "10.14.5", arch: "x86_64", family: "mac"

marcelstoer avatar Jun 26 '19 07:06 marcelstoer

In the latest released version (1.6.0), the default value for includeProjectDependencies is true:

https://github.com/mojohaus/exec-maven-plugin/blob/exec-maven-plugin-1.6.0/src/main/java/org/codehaus/mojo/exec/ExecJavaMojo.java#L139

cstroe avatar Sep 05 '19 18:09 cstroe

That's the same piece of code I referenced (you from 1.6, I from master). My point is that it behaves like it is false despite what it says in that annotation.

marcelstoer avatar Sep 05 '19 19:09 marcelstoer