The Ant Java Task helps to execute a Java class with options to fork and others.
I want to achieve similar behaviour with Gradle. A few things to note, I only want to use the java
plugin and not application
and java-library
, I don't want to use ant
within Gradle. I'm curious on how to achieve this with base java
plugin and gradle tasks.
I'm looking for something similar to
task runClass {
dependsOn build
java('com.example.Main', args={}, fork=true, options={})
}
update: I was able to start a forked JVM instance with target class and args using JavaExec. I'm blocked on trying to run this as a background process, instead of blocking the task workflow.
task run(type: JavaExec) {
dependsOn build
classpath = sourceSets.main.runtimeClasspath
main = 'org.example.Main'
args 'hello'
maxHeapSize '512m'
}