I’m running an executable jar file using the JavaExec task. The code essentially looks in the working directory for some config files and I have no way of changing this code to use the classpath to find these config files. However, setting the workingDir property in the javaexec config block doesn’t seem to affect the working dir (as determined by runtime errors and --debug output).
Can you please help me understand what I’m doing wrong here?
I’ve included a simplified example of the command I’m invoking, which seems to exhibit the same behavior, based on the debug output.
task javaVersion() << {
def workingDir = file('c:/')
println workingDir.absolutePath
javaexec {
main '-version'
workingDir = workingDir
}
}
Relevant debug output: bvanoss@STS123 /cygdrive/c/code/workspaces/tetra-workspace/gradle-example $ gradle :javaVersion --debug
11:43:42.590 [INFO] [org.gradle.process.internal.DefaultExecHandle] Starting process ‘command ‘C:\Program Files\Java\jdk1.8.0_25\bin\java.exe’’. Working directory: C:\code\workspaces\tetra-workspace\gradle-example Command: C:\Program Files\Java\jdk1.8.0_25\bin\java.exe -Dfile.encoding=windows-1252 -Duser.country=US -Duser.language=en -Duser.variant -version
------------------------------------------------------------ Gradle 2.1 ------------------------------------------------------------
Build time:
2014-09-08 10:40:39 UTC Build number: none Revision:
e6cf70745ac11fa943e19294d19a2c527a669a53
Groovy:
2.3.6 Ant:
Apache Ant™ version 1.9.3 compiled on December 23 2013 JVM:
1.8.0_25 (Oracle Corporation 25.25-b02) OS:
Windows 7 6.1 amd64