Skip to content

Commit 0e2e9fc

Browse files
committed
chore: reproducible build fixes
1 parent a81b364 commit 0e2e9fc

File tree

39 files changed

+198
-63
lines changed

39 files changed

+198
-63
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,6 @@ cobertura.ser
1212
kindlegen
1313
out
1414
atlassian-ide-plugin.xml
15-
plugin-ui/plugin/src/main/templates/views/*
15+
plugin-ui/plugin/src/main/templates/views/*
16+
!etc/bin
17+
etc/bin/results

build.gradle

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,30 @@ ext {
3030
.orElseGet(Instant::now)
3131
formattedBuildDate = DateTimeFormatter.ISO_INSTANT.format(buildInstant)
3232
buildDate = (buildInstant as Instant).atZone(ZoneOffset.UTC) // for reproducible builds
33+
isCiBuild = System.getenv().get('CI') as Boolean
3334
}
3435

3536
allprojects {
3637
repositories {
3738
mavenCentral()
3839
maven { url = 'https://repo.grails.org/grails/restricted' }
3940
maven { url = 'https://repository.apache.org/content/groups/snapshots' }
40-
maven { url = 'https://repo.spring.io/milestone' }
41+
maven {
42+
url = 'https://repository.apache.org/content/groups/staging'
43+
content {
44+
includeGroupByRegex 'org[.]apache[.]grails.*'
45+
}
46+
}
47+
}
48+
}
49+
50+
subprojects {
51+
configurations.configureEach {
52+
resolutionStrategy {
53+
def cacheHours = isCiBuild || isReproducibleBuild ? 0 : 24
54+
cacheDynamicVersionsFor(cacheHours, 'hours')
55+
cacheChangingModulesFor(cacheHours, 'hours')
56+
}
4157
}
4258
}
4359

buildSrc/build.gradle

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ repositories {
3030
mavenCentral()
3131
maven { url = 'https://repo.grails.org/grails/core' }
3232
maven { url = 'https://repository.apache.org/content/groups/snapshots' }
33+
maven {
34+
url = 'https://repository.apache.org/content/groups/staging'
35+
content {
36+
includeGroupByRegex 'org[.]apache[.]grails.*'
37+
}
38+
}
3339
}
3440

3541
dependencies {

etc/bin/generate-build-artifact-hashes.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ Files.walk(scanRoot)
7373

7474
artifacts.findAll {
7575
!it.toString().contains("${File.separator}buildSrc${File.separator}" as String) // build src jars aren't published
76-
!it.toString().contains("${File.separator}grails-test-examples${File.separator}" as String) // test examples aren't published
76+
!it.toString().contains("${File.separator}examples${File.separator}" as String) // test examples aren't published
7777
}.sort { a, b -> a.toString() <=> b.toString()
7878
}.collect { Path jar ->
7979
String hash = sha512(jar)

gradle/docs-config.gradle

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -22,22 +22,6 @@ import org.asciidoctor.gradle.jvm.AsciidoctorTask
2222

2323
apply plugin: 'org.asciidoctor.jvm.convert'
2424

25-
configurations.register('documentation') {
26-
canBeConsumed = false
27-
canBeResolved = true
28-
attributes {
29-
attribute(Category.CATEGORY_ATTRIBUTE, objects.named(Category, Category.LIBRARY))
30-
attribute(Bundling.BUNDLING_ATTRIBUTE, objects.named(Bundling, Bundling.EXTERNAL))
31-
attribute(Usage.USAGE_ATTRIBUTE, objects.named(Usage, Usage.JAVA_RUNTIME))
32-
}
33-
}
34-
35-
dependencies {
36-
add('documentation', platform("org.apache.grails:grails-bom:$grailsVersion"))
37-
add('documentation', 'com.github.javaparser:javaparser-core')
38-
add('documentation', 'org.apache.groovy:groovy-groovydoc')
39-
}
40-
4125
tasks.register('createReleaseDropDown', CreateReleaseDropDownTask) {
4226
group = 'documentation'
4327
githubSlug = 'apache/grails-spring-security'
@@ -50,6 +34,7 @@ tasks.register('pluginName') {
5034
ext.value = name - '-docs'
5135
}
5236

37+
apply from: rootProject.layout.projectDirectory.file('gradle/groovydoc-config.gradle')
5338
tasks.withType(Groovydoc).configureEach {
5439
def firstDocTitle
5540
def firstWindowTitle
@@ -65,14 +50,6 @@ tasks.withType(Groovydoc).configureEach {
6550
windowTitle = firstWindowTitle
6651
source = sources
6752
destinationDir = rootProject.layout.buildDirectory.dir("docs/$pluginName.value-plugin/groovydoc").get().asFile
68-
access = GroovydocAccess.PROTECTED
69-
processScripts = false
70-
includeMainForScripts = false
71-
includeAuthor = false
72-
noTimestamp = true
73-
noVersionStamp = false
74-
classpath = configurations.documentation
75-
groovyClasspath += configurations.documentation
7653
}
7754

7855
tasks.named('asciidoctor', AsciidoctorTask) {

gradle/groovydoc-config.gradle

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* https://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
configurations.register('documentation') {
21+
canBeConsumed = false
22+
canBeResolved = true
23+
attributes {
24+
attribute(Category.CATEGORY_ATTRIBUTE, objects.named(Category, Category.LIBRARY))
25+
attribute(Bundling.BUNDLING_ATTRIBUTE, objects.named(Bundling, Bundling.EXTERNAL))
26+
attribute(Usage.USAGE_ATTRIBUTE, objects.named(Usage, Usage.JAVA_RUNTIME))
27+
}
28+
}
29+
30+
dependencies {
31+
add('documentation', platform("org.apache.grails:grails-bom:$grailsVersion"))
32+
add('documentation', 'com.github.javaparser:javaparser-core')
33+
add('documentation', 'org.apache.groovy:groovy')
34+
add('documentation', 'org.apache.groovy:groovy-groovydoc')
35+
add('documentation', 'org.apache.groovy:groovy-ant')
36+
add('documentation', 'org.apache.groovy:groovy-docgenerator')
37+
add('documentation', 'org.apache.groovy:groovy-templates')
38+
}
39+
40+
tasks.withType(Groovydoc).configureEach {
41+
it.access = GroovydocAccess.PROTECTED
42+
it.processScripts = false
43+
it.includeMainForScripts = false
44+
it.includeAuthor = false
45+
it.noTimestamp = true
46+
it.noVersionStamp = false
47+
it.groovyClasspath += configurations.documentation
48+
}

gradle/java-config.gradle

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,4 @@ tasks.withType(GroovyCompile).configureEach {
3838
options.encoding = 'UTF-8' // encoding needs to be the same since it's different across platforms
3939
options.fork = true
4040
options.forkOptions.jvmArgs = ['-Xms128M', '-Xmx2G']
41-
}
42-
43-
// Any jar, zip, or archive should be reproducible
44-
// No longer needed after https://github.com/gradle/gradle/issues/30871
45-
tasks.withType(AbstractArchiveTask).configureEach {
46-
preserveFileTimestamps = false // to prevent timestamp mismatches
47-
reproducibleFileOrder = true // to keep the same ordering
48-
// to avoid platform specific defaults, set the permissions consistently
49-
filePermissions { permissions ->
50-
permissions.unix(0644)
51-
}
52-
dirPermissions { permissions ->
53-
permissions.unix(0755)
54-
}
5541
}

gradle/reproducible-config.gradle

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* https://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
// Any jar, zip, or archive should be reproducible
21+
// No longer needed after https://github.com/gradle/gradle/issues/30871
22+
tasks.withType(AbstractArchiveTask).configureEach {
23+
preserveFileTimestamps = false // to prevent timestamp mismatches
24+
reproducibleFileOrder = true // to keep the same ordering
25+
// to avoid platform specific defaults, set the permissions consistently
26+
filePermissions { permissions ->
27+
permissions.unix(0644)
28+
}
29+
dirPermissions { permissions ->
30+
permissions.unix(0755)
31+
}
32+
}

plugin-acl/docs/build.gradle

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,7 @@ ext {
5151
]
5252
}
5353

54-
apply from: rootProject.layout.projectDirectory.file('gradle/docs-config.gradle')
54+
apply {
55+
from rootProject.layout.projectDirectory.file('gradle/docs-config.gradle')
56+
from rootProject.layout.projectDirectory.file('gradle/reproducible-config.gradle')
57+
}

plugin-acl/examples/functional-test-app/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,4 @@ dependencies {
5757
apply from: rootProject.layout.projectDirectory.file('gradle/java-config.gradle')
5858
apply from: rootProject.layout.projectDirectory.file('gradle/test-config.gradle')
5959
apply from: rootProject.layout.projectDirectory.file('gradle/examples-config.gradle')
60+
apply from: rootProject.layout.projectDirectory.file('gradle/reproducible-config.gradle')

0 commit comments

Comments
 (0)