gpt4 book ai didi

gradle - 如何在Gradle(不包括xz tar文件)中使用ant-compress?

转载 作者:行者123 更新时间:2023-12-03 03:55:34 25 4
gpt4 key购买 nike

我想解压缩.tar.xz格式的文件。 Gradle的tarTree()不支持此格式,因此我需要将.xz解压缩为.tar,然后才能使用它。

根据docs,我应该能够做这样的事情:

    ant.untar(src: myTarFile, compression: "xz", dest: extractDir)

但是,我得到一个错误:
Caused by: : xz is not a legal value for this attribute
at org.apache.tools.ant.types.EnumeratedAttribute.setValue(EnumeratedAttribute.java:94)

SO answer讨论在Maven中使用Apache Ant Compress antlib的问题。如何使用Gradle获得相似的结果?

最佳答案

在您的链接中转换Maven SO答案将类似于:

configurations {
antCompress
}
dependencies {
antCompress 'org.apache.ant:ant-compress:1.4'
}
task untar {
ext {
xzFile = file('path/to/file.xz')
outDir = "$buildDir/untar"
}
inputs.file xzFile
outputs.dir outDir
doLast {
ant.taskdef(
resource:"org/apache/ant/compress/antlib.xml"
classpath: configurations.antCompress.asPath
)
ant.unxz(src:xzFile.absolutePath, dest:"$buildDir/unxz.tar" )
copy {
from tarTree("$buildDir/unxz.tar")
into outDir
}
}
}

参见 https://docs.gradle.org/current/userguide/ant.html

关于gradle - 如何在Gradle(不包括xz tar文件)中使用ant-compress?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60374815/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com