我希望我的 Gradle 构建脚本将完整的 Classpath 添加到构建后创建的 JAR 文件中包含的 list 文件中。
例子:
Manifest-Version: 1.0
Class-Path: MyProject.jar SomeLibrary.jar AnotherLib.jar
我的构建脚本已经通过这种方式向 list 中添加了一些信息:
jar {
manifest {
attributes("Implementation-Title": project.name,
"Implementation-Version": version,
"Main-Class": mainClassName,
}
}
如何获取要添加到 list 的依赖项列表?
此 Java 教程页面更详细地描述了如何以及为什么将类路径添加到 list :Adding Classes to the JAR File's Classpath
最佳答案
在 Gradle 的论坛上找到了解决方案:
jar {
manifest {
attributes(
"Class-Path": configurations.compile.collect { it.getName() }.join(' '))
}
}
关于java - 使用 Gradle 在 list 中添加类路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22659463/