0

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'
}
sampath.xyz
  • 150
  • 1
  • 7
  • *"I want to use the `java` plugin"* So read the **manual**, which tells you all about how to use it: [The Java Plugin](https://docs.gradle.org/current/userguide/java_plugin.html). Click the [JavaCompile](https://docs.gradle.org/current/dsl/org.gradle.api.tasks.compile.JavaCompile.html) link to see compiler options. – Andreas Oct 04 '20 at 10:22
  • Your question is all over the place. Start a new SPECIFIC FOCUSED question. – jnovack Oct 04 '20 at 18:05
  • @jnovack, My question boils down to what is ANT's Java task equivalent in Gradle, without using the ANT wrapper provided. – sampath.xyz Oct 05 '20 at 05:31

0 Answers0