我正在尝试创建一个包含项目类及其依赖项的可执行jar(使用maven),该依赖项带有清单文件,该清单文件具有主类的条目和指向包含在根目录中的依赖项的类路径条目罐子;像这样的东西:
清单文件:
.....主类:com.acme.MainClass类路径:dependecy1.jardependecy2.jar.....
瓶子:
罐根|-....|-com / acme /../*。class| --dependecy1.jar`--dependecy2.jar
我正在使用maven-jar-plugin创建清单文件,并使用maven-shade-plugin创建“超级” jar,但依赖项已解压缩并作为类添加到我的jar中。
我正在尝试创建一个可执行的jar(使用maven),其中包含项目类,并且它与清单文件具有相关性,该清单文件具有主类的条目和类路径的条目...
实际上,我没有检查maven-shade-plugin
到底在做什么(或任何其他插件),因为maven 2具有创建megajar或uberjar的所有内置功能。您只需要将maven-assembly-plugin与预定义的jar-with-dependencies
描述符一起使用。
过去我已经使用FatJar。 http://fjep.sourceforge.net/
我知道有两种产品可以做到这一点:
task uberJar(type: Jar) {
manifest {
attributes 'Main-Class': 'main.RunTest'
}
dependsOn configurations.runtimeClasspath
from sourceSets.main.output
from sourceSets.test.output
from sourceSets.main.resources
from sourceSets.test.resources
from {
configurations.runtimeClasspath.findAll { it.name.endsWith('jar') }.collect { zipTree(it) }
}
from {
project(':someothermoudule').sourceSets.main.resources // If current project depends on some other modules
project(':someothermoudule').sourceSets.test.resources // If current project depends on some other modules
}
exclude 'META-INF/*.RSA'
exclude 'META-INF/*.SF'
exclude 'META-INF/*.DSA'
}