如何将 class 路径条目附加到清单?

How to append a class-path entry to the Manifest?

我的 gradle 构建创建了一个清单文件,其中包含 lib/ 中包含的所有 *.jar 文件。我想将 lib 目录添加到这个类路径中,以便 lib/log4j.properties 在运行时被 myapp 抓取。我怎样才能附加到下面的'Class-Path'

jar {
    manifest {
        attributes 'Implementation-Title': 'myapp', 'Implementation-Version': version,
        'Class-Path': configurations.runtime.files.collect { it.name }.join(' lib/'),
    'Main-Class': 'ca.company.product.myapp.Application',
    'Built-By': System.getProperty('user.name'),
    'Built-JDK': System.getProperty('java.version')
    }
}

我查看了 gradle 文档,但尚未深入研究 Gravy。我可能忽略了 SO 或 Gradle 论坛上的一些问题。

我刚刚发现可以像常规 Java 一样连接变量。所以关注 build.gradle 对我有用:

jar {
    manifest {
        attributes 'Implementation-Title': 'myapp', 'Implementation-Version': version,
        'Class-Path': configurations.runtime.files.collect { it.name }.join(' lib/') + ' lib/log4j.properties',
    'Main-Class': 'ca.company.product.myapp.Application',
    'Built-By': System.getProperty('user.name'),
    'Built-JDK': System.getProperty('java.version')
}