【发布时间】:2015-11-03 02:02:09
【问题描述】:
当我运行这个 FatJar/UberJar 任务时,我最终得到一个 .jar 文件,其 META-INF\ 文件夹包含两个 MANIFEST.MF 文件。一个是我在任务定义中插入属性的正确的,另一个只包含“Manifest-Version:1.0”。 这会在尝试运行应用程序时导致“无法找到或加载主类”错误(我假设它只读取第一个并且无法识别主类)
task fatJar(type: Jar) {
baseName = project.name
manifest {
attributes 'Implementation-Title': 'Synchronizer',
'Main-Class': 'net.xxx.yyy.Main'
}
from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
with jar
}
MANIFEST.MF #1
清单版本:1.0
MANIFEST.MF #2:
清单版本:1.0
实现-标题:同步器
主类:net.xxx.yyy.Main
Manifest 重复的原因是什么?
我尝试使用
it.isDirectory() ? it : zipTree(it).matching{exclude{it.path.contains == 'META-INF'}}
it.isDirectory() ? it : zipTree(it).matching{exclude{it.name.contains == 'MANIFEST'}}
*** 这些确实排除了子 JAR META-INF 文件夹和清单文件,所以我不确定 MANIFEST.MF #1 来自哪里。这似乎是默认值?
【问题讨论】: