Skip to content

Commit 47a1e7b

Browse files
snazyGooolerCopilot
authored
Enhance docs about reproducible builds (#1882)
* Enhance docs about reproducible builds * Apply suggestions from code review * Update docs/configuration/reproducible-builds/README.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Zongle Wang <wangzongler@gmail.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 99e3991 commit 47a1e7b

File tree

1 file changed

+30
-1
lines changed
  • docs/configuration/reproducible-builds

1 file changed

+30
-1
lines changed

docs/configuration/reproducible-builds/README.md

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,52 @@
33
By default, JAR files generated by Gradle (with or without Shadow) for a single project with the same source code may
44
not be identical to each other. Sometimes it's desirable to configure a project to consistently output a byte-for-byte
55
identical JAR on every build. Gradle supports this with the following configuration, and Shadow will correctly respect
6-
these settings too:
6+
these settings too.
7+
8+
Besides file timestamps and file order, this configuration also ensures that all files in the JAR are set to have the
9+
same permissions, irrespective of the locally configured umask.
10+
11+
More information about reproducible builds can be found at [reproducible-builds.org](https://reproducible-builds.org/).
712

813
=== "Kotlin"
914

1015
```kotlin
16+
import java.nio.file.Files
17+
import java.nio.file.attribute.PosixFilePermission
18+
1119
tasks.withType<AbstractArchiveTask>().configureEach {
1220
isPreserveFileTimestamps = false
1321
isReproducibleFileOrder = true
22+
23+
eachFile {
24+
permissions {
25+
val isExec =
26+
Files.getPosixFilePermissions(file.toPath()).contains(PosixFilePermission.OWNER_EXECUTE)
27+
unix(if (isExec) "755" else "644")
28+
}
29+
}
30+
dirPermissions { unix("755") }
1431
}
1532
```
1633

1734
=== "Groovy"
1835

1936
```groovy
37+
import java.nio.file.Files
38+
import java.nio.file.attribute.PosixFilePermission
39+
2040
tasks.withType(AbstractArchiveTask).configureEach {
2141
preserveFileTimestamps = false
2242
reproducibleFileOrder = true
43+
44+
eachFile {
45+
permissions {
46+
def isExec =
47+
Files.getPosixFilePermissions(file.toPath()).contains(PosixFilePermission.OWNER_EXECUTE)
48+
unix(isExec ? '755' : '644')
49+
}
50+
}
51+
dirPermissions { unix('755') }
2352
}
2453
```
2554

0 commit comments

Comments
 (0)