Search code examples
javanetbeansgradlenetbeans-plugins

Can't execute debug task in NetBeans after switching to Gradle


I've installed the Gradle-support plugin in Netbeans and I can build and run the project just fine. When I try to run in debug mode, I get the following output:

Executing: gradle debug

:debug
Cannot execute debug because the property "mainClass" is not defined or empty.

BUILD SUCCESSFUL

Total time: 0.222 secs

I'm using:

 Oracle Java 1.8
 Gradle 1.12
 Netbeans 8.0
 Gradle-Support 1.3.0
 LinuxMint 16

Why can't I run my debugger?


Solution

  • Add something like

    if (!hasProperty('mainClass')) {
        ext.mainClass = 'com.foo.acme.Main'
    }
    

    to your build.gradle. It will tell Gradle plugin what class to use when starting your application. Perhaps that should be customizable in the UI but I cannot see it now.