A question for the VS Code wizards:
I have a Gradle project where I have multiple tools (i.e. multiple classes with main methods) which I run from the command line. My build.gradle
file (under the project root) looks like this:
plugins {
id 'application'
}
repositories {
...
}
dependencies {
...
}
java {
toolchain ...
}
tasks.withType(JavaCompile) {
options.compilerArgs += ["-nowarn"]
}
application {
// Define a dummy main class because we run main classes in various source files
mainClass = '....console.DontUsePlainRun'
}
tasks.register("run-ToolA", JavaExec) {
jvmArgs = ...
group = ApplicationPlugin.APPLICATION_GROUP
classpath = sourceSets.main.runtimeClasspath
mainClass = '....ToolA'
}
tasks.register("run-ToolB", JavaExec) {
jvmArgs = ...
group = ApplicationPlugin.APPLICATION_GROUP
classpath = sourceSets.main.runtimeClasspath
mainClass = '....ToolB'
}
...
I run the tool classes on the command line like this:
$ gradle run-ToolA
or this:
$ gradle run-ToolB
…
This works perfectly!
However for debugging I would like to run the classes in VS Code via the Gradle for Java plugin. I have installed it, but I look at the Projects outline my run tasks don’t show up:
How can I debug my run tasks in VS Code?