Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you debug a Gradle project with native dependencies in Netbeans?

I have a project that requires native libraries to run. I'm using the Gradle-Support Netbeans plugin.

apply plugin: "java"
apply plugin: "application"
apply plugin: "eclipse"

sourceCompatibility = 1.7

mainClassName = "com.myPackage.MainClass"

if (!project.hasProperty('mainClass')) {
    ext.mainClass = mainClassName
}

repositories {
    mavenCentral()

    maven {
        url "http://teleal.org/m2"
    }
}

dependencies {
    compile group: "com.esotericsoftware.kryo", name: "kryo", version: "2.23.0"
    compile group: "net.java.jinput", name: "jinput", version: "2.0.5"
    compile group: "org.jcraft", name: "jorbis", version: "0.0.17"
    compile group: "org.jdom", name: "jdom2", version: "2.0.5"
    compile group: "org.lwjgl.lwjgl", name: "lwjgl", version: "2.9.0"
    compile group: "org.lwjgl.lwjgl", name: "lwjgl_util", version: "2.9.0"
    compile group: "org.teleal.cling", name: "cling-core", version: "1.0.5"
    compile group: "org.teleal.cling", name: "cling-support", version: "1.0.5"
    compile group: "xpp3", name: "xpp3", version: "1.1.4c"

    compile files("./lib/jars/kryonet-2.21.jar")
    compile files("./lib/jars/slick.jar")
    compile files("./lib/jars/slick-util.jar")
    compile files("./lib/jars/TWL.jar")
}

jar {
    from {
        configurations.compile.collect { it.isDirectory() ? it : zipTree(it) }
        configurations.runtime.collect { it.isDirectory() ? it : zipTree(it) }
    }

    manifest {
        attributes "Main-Class": project.mainClassName
    }
}

run {
    configureRun(it)
}

task(debug, dependsOn: 'classes', type: JavaExec) {
    configureRun(it)
    classpath = sourceSets.main.runtimeClasspath
}

void configureRun (def task){
    main = mainClass
    task.systemProperty "java.library.path", "./lib/native/"
}

The application will launch fine in run mode but debug mode yields the following error:

 FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':debug'.
> No main class specified
like image 205
Stephen__T Avatar asked Nov 11 '22 08:11

Stephen__T


1 Answers

I assume, you are using the application plugin and that is why this configuration for the run task is enough. That is, most likely you should have something like this:

if (!project.hasProperty('mainClass')) {
    ext.mainClass = mainClassName
}

run {
    configureRun(it)
}

task(debug, dependsOn: 'classes', type: JavaExec) {
    configureRun(it)
    classpath = sourceSets.main.runtimeClasspath
}

void configureRun(def task) {
    main = mainClass
    task.systemProperty "java.library.path", "./lib/native/"
}
like image 164
Attila Kelemen Avatar answered Nov 14 '22 22:11

Attila Kelemen