Tôi có một dự án yêu cầu thư viện gốc để chạy. Tôi đang sử dụng plugin Netbeans Gradle-Support.Làm thế nào để bạn gỡ lỗi một dự án Gradle với phụ thuộc bản địa trong 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/"
}
Ứng dụng này sẽ khởi động tốt ở chế độ chạy nhưng chế độ gỡ lỗi mang lại các lỗi sau:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':debug'.
> No main class specified
này ném lỗi sau: 'Thực hiện thất bại cho nhiệm vụ ': debug'. > Không có lớp học chính được chỉ định ' – ZeroDivide
Tôi đã cập nhật câu hỏi của mình với build.gradle đầy đủ của tôi. – ZeroDivide
thay vì main = mainClass, không nên là task.main = mainClass? Trong một ví dụ tương tự, điều này vẫn không giải quyết được vấn đề của tôi. Tò mò nếu nó giải quyết của bạn. – vextorspace