我的build.gradle存在问题,编译正常但是当我尝试执行.jar时,控制台会给我:“没有清单显示属性......”
这是我的bluid.gradle:
apply plugin: 'java'
group = "com.xxx.xxx.xxx"
archivesBaseName = "xxx"
version = "0.1"
task pack(type: Jar, dependsOn: 'jar') {
inputs.files jar.archivePath;
jar {
baseName = 'xxxx'
version = '0.1'
}
manifest {
attributes(
"Manifest-Version" : "1.0",
"Main-Class" : "com.xxx.xxx.xxx.xxx"
)
}
doLast {
manifest.writeTo("${buildDir}/MANIFEST.MF")
project.ant {
taskdef name: "jarjar", classname: "com.tonicsystems.jarjar.JarJarTask", classpath: configurations.tools.asPath
jarjar(jarfile: archivePath, manifest: "${buildDir}/MANIFEST.MF") {
fileset(dir : "${buildDir}/classes")
fileset(dir : "${buildDir}/resources/main")
configurations.runtime.files.each { jarjarFile ->
zipfileset(src: jarjarFile) {
// WARNING: MUST keep META-INF/DgmInfo, META-INF/services, ... which are needed by Groovy
}
}
rule pattern: "*", result: "@0"
}
}
}
configurations {
tools
}
dependencies {
tools files("${rootDir}/tools/jarjar-1.4.jar")
compile files("${rootDir}/lib/bluecove-2.1.0.jar")
compile files("${rootDir}/lib/bluecove-gpl-2.1.0.jar")
}
}
我不写整个代码,我真的不知道编写gradle脚本, 有人帮忙吗? :)
答案 0 :(得分:0)
我理解这一部分:
"Main-Class" : "com.xxx.xxx.xxx.xxx"
实际上是指向一个有效的Java类,里面有一个main方法,而类在你的类路径上?
如果是,请解压缩输出jar,找到META-INF文件夹并检查MANIFEST.MF中的内容并告诉我们。