gradle-execfork-plugin icon indicating copy to clipboard operation
gradle-execfork-plugin copied to clipboard

Declarative support for java -jar processes

Open lukasito opened this issue 6 years ago • 1 comments

Currently workaround for this is to use ExecFork task and use it as follows:

  executable = Jvm.current().javaExecutable.absolutePath
  args = ["-DsomeJvmArg=something", "-jar", "$buildDir/libs/some-fat-jar.jar"]
  waitForPort = 30000
  stopAfter = xyz
  ...

Problem with this approach is that you need to keep in mind the proper ordering of args (e.g. -D args before -jar arg. or -javaagent arg order etc.)

Proposal is to enhance JavaExecFork to support running java application declaratively e.g.

  jarFile = "$buildDir/libs/some-fat-jar.jar"
  javaagent = "$buildDir/agent/some-agent.jar" //optional or can be moved  to jvmArgs
  jvmArgs = [ '-Dconfig.file=src/main/resources/some.conf' ]
  waitForPort = 30000
  stopAfter = xyz
  ...

lukasito avatar Feb 27 '19 11:02 lukasito

My build.gradle script couldn't resolve executable = Jvm.current().getJavaExecutable().getAbsolutePath(), so I added a full path like executable = org.gradle.internal.jvm.Jvm.current().getJavaExecutable().getAbsolutePath() and it works!

Thank you @lukasito for the workaround!

ultraon avatar Sep 07 '21 18:09 ultraon