排除 Gradle tar/zip 工件中的基本目录 [英] Exclude base directory inside Gradle tar/zip artifacts
问题描述
maven 程序集插件 有一个 includeBaseDirectory
选项(当设置为 false 时)避免在 tar/zip 工件内有一个与工件本身同名的顶级目录.
The maven assembly plugin has an includeBaseDirectory
option that (when set to false) avoids having a single top-level directory inside the tar/zip artifact with the same name as the artifact itself.
我想用 Gradle 实现相同的结果,但我不知道如何实现.我正在使用这样的配置:
I'd like to achieve the same result with Gradle, but I don't see how. I'm using a configuration like this:
task distTar(type: Tar) {
compression Compression.GZIP
extension "tar.gz"
}
我没有看到 的任何选项做我想做的 Tar 任务.如何使用 Gradle 排除存档中的基本目录?
I don't see any options for the Tar task that do what I want. How can I exclude the base directory in my archive with Gradle?
推荐答案
好的,我想通了.这比我想象的要简单.要将库依赖项复制到存档根目录的 lib
中,我使用了 CopySpec:
Ok, I figured it out. It was simpler than I thought. To copy the library dependencies into lib
at the root of the archive, I use a CopySpec:
task distTar(type: Tar) {
into('lib') {
from libsDir
include '*.jar'
}
}
类似的 CopySpecs 可用于复制,例如bin
和 conf
目录.
Similar CopySpecs can be used to copy e.g. bin
and conf
directories.
这篇关于排除 Gradle tar/zip 工件中的基本目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!