File tree Expand file tree Collapse file tree 1 file changed +30
-1
lines changed
docs/configuration/reproducible-builds Expand file tree Collapse file tree 1 file changed +30
-1
lines changed Original file line number Diff line number Diff line change 33By default, JAR files generated by Gradle (with or without Shadow) for a single project with the same source code may
44not be identical to each other. Sometimes it's desirable to configure a project to consistently output a byte-for-byte
55identical 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
You can’t perform that action at this time.
0 commit comments