Gradle Zip DuplicatesStrategy无法正常工作 [英] Gradle Zip DuplicatesStrategy not working correctly

查看:537
本文介绍了Gradle Zip DuplicatesStrategy无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设你有这样的东西:

task zip(type: Zip) {
  archiveName = "out.zip"
  duplicatesStrategy = 'exclude'

  into('TARGET_FOLDER_IN_ZIP') {
    from("$rootDir/customizations/folder1")
    from("$rootDir/customizations/folder2")
  }
}

根据 http://www.gradle.org/docs/current/ javadoc / org / gradle / api / file / DuplicatesStrategy.html 排除意味着


不要通过忽略后续项目来允许重复在同一路径上创建。

Do not allow duplicates by ignoring subsequent items to be created at the same path.

所以如果你在文件夹1和folder2只有来自folder1的文件应该在zip中。如果您更改了构建文件中的两个from行,那么只有来自folder2的文件才会在那里。这似乎不是发生了什么(毕业1.10)。相反,始终使用相同的文件。似乎嵌套的froms不保存其顺序。

So if you have the same filename in folder1 & folder2 only the file from folder1 should end up in the zip. If you change the two "from" lines in the buildfile, only the file from folder2 should end up there. This seems not to be whats happening (gradle 1.10). Instead always the same file is used. Seems like nested "from"s do not preserve their order.

推荐答案

我找到的唯一解决方案是拆分冲突部分:

The only solution I've found is to split up the conflicting parts:

  into('TARGET_FOLDER_IN_ZIP') {
    from("$rootDir/customizations/folder1")
  }
  into('TARGET_FOLDER_IN_ZIP') {
    from("$rootDir/customizations/folder2")
  }

现在订单被保留,输出是确定性的

now the order is preserved and the output is deterministic

这篇关于Gradle Zip DuplicatesStrategy无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆