I\'m using the Exec Maven plugin with the following command :
mvn exec:java
and I didn\'t manage to set the working dire
If you like to set it via calling mvn exec:java ...
you need to go via the property like this:
mvn exec:java -Dexec.workingdir=Folder ...
which has nothing to do what you defined in your pom cause calling the goal exec:java
is not part of the life cycle.
I couldn't either find a working fix, however an ugly workaround that was applicable in my case is to simply pass ${project.build.directory}
(or any maven property for the matter) as an argument to the main class and handling it from there.
<configuration>
[...]
<arguments>
<argument>${project.build.directory}</argument>
</arguments>
[...]
</configuration>
Setting the current working directory inside the code to properly simulate the non-working workingDirectory
configuration is a bit tricky if you insist doing so, check this linked answer for more information.
I didn't found solution with exec:java.
So, now I use exec:exec instead because we can set the workingDirectory and it' OK.
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.3.2</version>
<executions>
<execution>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>java</executable>
<arguments>
<argument>-classpath</argument>
<classpath />
<argument>com.package.MyMainClass</argument>
</arguments>
<workingDirectory>${project.build.outputDirectory}</workingDirectory>
</configuration>