我有一个Gradle构建项目依赖于另一个项目。我的项目应该从另一个项目中提取zip文件并提取存档。存档内的一个文件名为“name.txt”,里面有一个字符串,我需要在我的“构建”任务中作为参数传递。Gradle,提取依赖zip和使用其文件中的内容?
def unzippedDir = file('build/dependencies/unzippedDir').getAbsolutePath()
configurations {
zipArchive
}
dependencies {
ziparchive "<path>"
}
task unzip(type:Copy) {
into unzippedDir from zipTree(configurations.zipArchive.singleFile)
}
task build {
dependsOn unzip
def name = new File(unzippedDir + '/name.txt').text
<the test of the build steps that uses the "name" variable>
}
但是我得到了一个“没有文件或目录”错误的“name.txt”。难道我做错了什么?
我在提取的目录中看到的是,只有一个ZIP压缩文件内的文件以unzippedDir结尾。即使是另一个文件,“name.txt”也不存在。这是否意味着我做了解压缩任务的错误?
我在提取的目录中看到的是,只有一个ZIP压缩文件内的文件结束了unzippedDir。即使是另一个文件,“name.txt”也不存在。这是否意味着我做了解压缩任务的错误? – JimmyT