gpt4 book ai didi

java - 如何在 Netbeans 中调试具有 native 依赖项的 Gradle 项目?

转载 作者:搜寻专家 更新时间:2023-10-31 20:34:20 25 4
gpt4 key购买 nike

我有一个项目需要本地库才能运行。我正在使用 Gradle-Support Netbeans 插件。

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/"
}

应用程序将在运行模式下正常启动,但在 Debug模式下会产生以下错误:

 FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':debug'.
> No main class specified

最佳答案

我假设,您正在使用应用程序插件,这就是运行任务的这个配置就足够了的原因。也就是说,很可能你应该有这样的东西:

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/"
}

关于java - 如何在 Netbeans 中调试具有 native 依赖项的 Gradle 项目?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23439737/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com