This message was deleted.
# community-support
s
This message was deleted.
v
Translation-wise it is fine except for one detail. 0777 != 777
left is an octal number, right is a decimal number
0777 == 0x1FF == 511 == 0b0001_1111_1111
Kotlin does not know octal number literals
And really translated it would be
tasks.create
, but
tasks.register
is much better of course. 😄
You could also write it as
val createCommitHook by tasks.registering(Copy::class) { ... }
if you prefer
Unrelated to the conversion,
rootProject.rootDir
does make little sense.
rootDir
is the
projectDir
of the
rootProject
. So you get the project dir from the root project of the root project. 🙂 Either just use
rootDir
, or actually use
rootProject.file(".git/hooks")
instead of
File(...)
❤️ 1
c
Thanks! So
fileMode = 0x755
would also be incorrect? Because that seems to work?
v
Depends on how you define correct. It will be 03525, or 1877, or 0b0111_0101_0101. If that is what you want, fine. But it will not be the same as 0755 would have been.
What you can do use octal mode is
fileMode = "0755".toInt(8)
👆 1
c
Okay. Yeah. I think I want typical 755 file permissions, so fileMode = "0755".toInt(8) is more clear to what i want to do. IMO. I think ill do that
👌 1
thanks @Vampire
v
Actually, you can leave out the leading 0. As a number literal in Java and Groovy it tells the complier it is octal. But as you already tell it by
(8)
, the leading 0 is just noise. 🙂
❤️ 1
e
IMO it would be nice if Gradle were to add an API using NIO types, such as
Copy code
filePermissions = PosixFilePermissions.fromString("rwxr-xr-x")
(and maybe even a
setFilePermissions("rwxr-xr-x")
shortcut) but clearly that hasn't happened
I guess technically that API doesn't support the setuid/setgid/sticky bits, but I think it's reasonable to call that out of scope for Gradle anyway
Copy code
fileMode = PermissionUtils.modeFromPermissions(PosixFilePermissions.fromString("rwxr-xr-x"), PermissionUtils.FileType.REGULAR_FILE)
is a lot more verbose but with some shortcuts it could be clearer than octal
👍 1
🙏 1