Gradle-没有主要清单属性
运行基于Gradle构建的JAR文件时遇到的错误让我有点发疯。错误显示为“
RxJavaDemo.jar中没有主清单属性”,我尝试操纵Manifest属性,但我想我忘记在其中添加依赖项或其他内容。我到底在做什么错?
apply plugin: 'java'apply plugin: 'application'
mainClassName = 'demo.MainDashboard'
dependencies {
compile files ("H:/Processes/Development/libraries/hikari-cp/HikariCP-2.4.1.jar")
compile files ("H:/Processes/Development/libraries/controls-fx/controlsfx.jar")
compile files ("H:/Processes/Development/libraries/database_connections/sqlite-jdbc-3.8.6.jar")
compile files ("H:/Processes/Development/libraries/guava/guava-18.0.jar")
compile files ("H:/Processes/Development/libraries/rxjava/rxjava-1.0.12.jar")
compile files ("H:/Processes/Development/libraries/rxjava-extras/rxjava-extras-0.5.15.jar")
compile files ("H:/Processes/Development/libraries/rxjavafx/RxJavaFX-1.0.0-RC1-SNAPSHOT.jar")
compile files ("H:/Processes/Development/libraries/rxjavaguava/rxjava-guava-1.0.3.jar")
compile files ("H:/Processes/Development/libraries/rxjava-jdbc/rxjava-jdbc-0.6.3.jar")
compile files ("H:/Processes/Development/libraries/slf4j/slf4j-api-1.7.12.jar")
compile files ("H:/Processes/Development/libraries/tom-commons/tom-commons.jar")
}
sourceSets {
main.java.srcDir "src/main/java"
main.resources.srcDir "src/main/resources"
}
jar {
manifest {
attributes(
"Class-Path": configurations.compile.collect { it.getName() }.join(' '))
}
from configurations.compile.collect { entry -> zipTree(entry) }
}
回答:
尝试更改清单属性,例如:
jar { manifest {
attributes(
'Class-Path': configurations.compile.collect { it.getName() }.join(' '),
'Main-Class': 'hello.HelloWorld'
)
}
}
然后只需更改'hello.helloWorld'
为'<your packagename>.<the name of your Main
class>'(您的Main类具有main方法)。在这种情况下,您可以在清单中创建一个指向此类的属性,然后运行一个jar。
以上是 Gradle-没有主要清单属性 的全部内容, 来源链接: utcz.com/qa/434818.html