Chris Lee
10/31/2025, 12:40 AMdistZip no longer pulls the filesystem permissions.
We could force that via useFileSystemPermissions but seems cleaner to set the explicit/desired permissions in the build script.
But doing that seems to be incompatible with the configuration cache.
Seems like filePermissions is incompatible with configuration cache?
plugins {
application
}
tasks.named<Zip>("distZip") {
// setting permissions here fails as properties are finalized already
// filesMatching("**/*") {
// filePermissions {
// unix("rwxr-xr-x")
// }
// }
}
distributions {
main {
contents {
filesMatching("bin/**") {
// simply adding "filePermissions" fails
// Cause: class org.gradle.api.internal.file.copy.DefaultCopySpec cannot be cast to class org.gradle.api.file.FileCollection (org.gradle.api.internal.file.copy.DefaultCopySpec and org.gradle.api.file.FileCollection are in unnamed module of loader org.gradle.internal.classloader.VisitableURLClassLoader @3043fe0e)
filePermissions {
unix("rwxr-xr-x")
}
}
}
}
}Chris Lee
10/31/2025, 12:57 AMThe value for property 'filePermissions' is final and cannot be changed any further. when configuring permission on the distribution contents.
This seems like a common use case - adjust executable permission on distribution files - surprised this is problematic.
On Gradle 9.2.0.Vampire
10/31/2025, 1:07 AMVampire
10/31/2025, 1:09 AMfilePermissions is a property of CopyProcessingSpec and thus Copy.
In the filesMatching you should configure the FileCopyDetails that is the context there.
But you configure the outer one (the task in the upper the copy spec in the lower case).
Use permissions instead of filePermissions, that is on the FileCopyDetails and works without problems. 🙂Vampire
10/31/2025, 1:09 AMVampire
10/31/2025, 1:11 AMthis.<Ctrl+Space> to see what is available on the actual this in the inner-most scope and then after completing remove the this. for better readability.
Without the this. you also get suggestions for the outer scope `this`es.Chris Lee
10/31/2025, 1:13 AMVampire
10/31/2025, 1:14 AMfilePermissions.Vampire
10/31/2025, 1:14 AMfilesMatching