kelemen / netbeans-gradle-project

This project is a NetBeans plugin able to open Gradle based Java projects. The implementation is based on Geertjan Wielenga's plugin.
172 stars 57 forks source link

[feature request] Add option to launch debugger on custom tasks. #357

Closed vs49688 closed 6 years ago

vs49688 commented 6 years ago

I've a few custom tasks that start the JVM in debug mode (see below). It'd be nice if the debugger auto-launched and attached to these tasks.

task debugMaster(type: JavaExec, dependsOn: classes) {
    debug = true
    main = mainClassName
    classpath = sourceSets.main.runtimeClasspath
    args = ["master"]
}

Does something like this exist? If not, I'll take a crack at it sometime tomorrow. I'm thinking adding it as another checkbox in the "Custom Tasks" menu.

Hillkorn commented 6 years ago

I would recommend to use "--debug-jvm" as a parameter on exection for the netbeans debug task as you don't need to touch the build gradle to debug. Like gradle someJavaExecTask --debug-jvm See https://docs.gradle.org/current/dsl/org.gradle.api.tasks.JavaExec.html

kelemen commented 6 years ago

You don't need to touch the build scripts if you already have a JavaExec task. You just have to configure the Debug task in Project Properties/Built-in Tasks. That is, here you have to change the name of "run" (or "debug" depending on your debug mode). I recommend to set the debug mode to "Debugger listens for connection" globally (then change these settings).

vs49688 commented 6 years ago

Ahh, I didn't even think of changing the built-in tasks -- That worked nicely. Thanks. My suggestion was that the debugger auto-attach if it detects a JVM being started in debug mode -- it's a minor QoL thing, but it's easy enough to add a profile and change the tasks.