如果我有这样的gradle文件
apply plugin: 'distribution'
version = '1.2'
distributions {
custom {}
}
按照约定,“src / custom / dist”目录中的所有文件将自动包含在发行版中。
https://docs.gradle.org/current/userguide/distribution_plugin.html
如果要在其中一些文件上设置fileMode怎么办?
如果我只指定fileMode,它什么也不做。
into("") {
from "src/custom/scripts"
fileMode 0755
}
编辑:如果我将脚本放在另一个目录中并显式复制它们(而不是按惯例复制它们,则下面的代码有效。
distributions {
custom {
baseName = 'myApp'
contents {
into("") {
from "src/external/scripts"
fileMode 0755
}
}
}
我想知道是否可以将文件保留在常规位置,但可以更改某些文件的属性。
最佳答案
在@RaGe链接之后,我想到了这个:
distributions {
custom {
baseName = 'myApp'
contents {
//Other stuff
eachFile { file ->
if(file.getName().endsWith(".sh")) {
file.setMode(0755)
}
}
}
关于gradle - 按照约定将文件复制到Tar时,将fileMode设置为* .sh,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36482293/