Skip to content

Commit 98e701d

Browse files
authored
Merge pull request #14710 from jdaugherty/groovyCleanup
reproducible builds - groovydoc 4, profile fixes, and ensuring gradle projects build docs
2 parents 8550ecd + fbcbfc5 commit 98e701d

File tree

17 files changed

+138
-94
lines changed

17 files changed

+138
-94
lines changed

dependencies.gradle

+19-19
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ ext {
8484
'bootstrap.version' : '5.3.3',
8585
'commons-codec.version' : '1.17.1',
8686
'geb-spock.version' : '7.0',
87-
'groovy.version' : '4.0.26',
87+
'groovy.version' : '4.0.27-SNAPSHOT',
8888
'h2.version' : '2.3.232',
8989
'jackson.version' : '2.18.2',
9090
'jquery.version' : '3.7.1',
@@ -107,24 +107,24 @@ ext {
107107

108108
// Note: the name of the dependency must be the prefix of the property name so properties in the pom are resolved correctly
109109
bomDependencies = [
110-
'asset-pipeline-grails' : "com.bertramlabs.plugins:asset-pipeline-grails:${bomDependencyVersions['asset-pipeline-grails.version']}",
111-
'bootstrap' : "org.webjars.npm:bootstrap:${bomDependencyVersions['bootstrap.version']}",
112-
'bootstrap-icons' : "org.webjars.npm:bootstrap-icons:${bomDependencyVersions['bootstrap-icons.version']}",
113-
'commons-codec' : "commons-codec:commons-codec:${bomDependencyVersions['commons-codec.version']}",
114-
'geb-spock' : "org.gebish:geb-spock:${bomDependencyVersions['geb-spock.version']}",
115-
'h2' : "com.h2database:h2:${bomDependencyVersions['h2.version']}",
116-
'jquery' : "org.webjars.npm:jquery:${bomDependencyVersions['jquery.version']}",
117-
'liquibase-hibernate5' : "org.liquibase:liquibase:${bomDependencyVersions['liquibase-hibernate5.version']}",
118-
'liquibase-hibernate5-cdi' : "org.liquibase:liquibase-cdi:${bomDependencyVersions['liquibase-hibernate5.version']}",
119-
'liquibase-hibernate5-core' : "org.liquibase:liquibase-core:${bomDependencyVersions['liquibase-hibernate5.version']}",
120-
'liquibase-hibernate5-ext' : "org.liquibase.ext:liquibase5-hibernate:${bomDependencyVersions['liquibase-hibernate5.version']}",
121-
'mongodb-bson' : "org.mongodb:bson:${bomDependencyVersions['mongodb.version']}",
122-
'mongodb-driver-core' : "org.mongodb:mongodb-driver-core:${bomDependencyVersions['mongodb.version']}",
123-
'mongodb-driver-sync' : "org.mongodb:mongodb-driver-sync:${bomDependencyVersions['mongodb.version']}",
124-
'mongodb-record-codec' : "org.mongodb:bson-record-codec:${bomDependencyVersions['mongodb.version']}",
125-
'rxjava' : "io.reactivex:rxjava:${bomDependencyVersions['rxjava.version']}",
126-
'rxjava2' : "io.reactivex.rxjava2:rxjava:${bomDependencyVersions['rxjava2.version']}",
127-
'rxjava3' : "io.reactivex.rxjava3:rxjava:${bomDependencyVersions['rxjava3.version']}",
110+
'asset-pipeline-grails' : "com.bertramlabs.plugins:asset-pipeline-grails:${bomDependencyVersions['asset-pipeline-grails.version']}",
111+
'bootstrap' : "org.webjars.npm:bootstrap:${bomDependencyVersions['bootstrap.version']}",
112+
'bootstrap-icons' : "org.webjars.npm:bootstrap-icons:${bomDependencyVersions['bootstrap-icons.version']}",
113+
'commons-codec' : "commons-codec:commons-codec:${bomDependencyVersions['commons-codec.version']}",
114+
'geb-spock' : "org.gebish:geb-spock:${bomDependencyVersions['geb-spock.version']}",
115+
'h2' : "com.h2database:h2:${bomDependencyVersions['h2.version']}",
116+
'jquery' : "org.webjars.npm:jquery:${bomDependencyVersions['jquery.version']}",
117+
'liquibase-hibernate5' : "org.liquibase:liquibase:${bomDependencyVersions['liquibase-hibernate5.version']}",
118+
'liquibase-hibernate5-cdi' : "org.liquibase:liquibase-cdi:${bomDependencyVersions['liquibase-hibernate5.version']}",
119+
'liquibase-hibernate5-core': "org.liquibase:liquibase-core:${bomDependencyVersions['liquibase-hibernate5.version']}",
120+
'liquibase-hibernate5-ext' : "org.liquibase.ext:liquibase5-hibernate:${bomDependencyVersions['liquibase-hibernate5.version']}",
121+
'mongodb-bson' : "org.mongodb:bson:${bomDependencyVersions['mongodb.version']}",
122+
'mongodb-driver-core' : "org.mongodb:mongodb-driver-core:${bomDependencyVersions['mongodb.version']}",
123+
'mongodb-driver-sync' : "org.mongodb:mongodb-driver-sync:${bomDependencyVersions['mongodb.version']}",
124+
'mongodb-record-codec' : "org.mongodb:bson-record-codec:${bomDependencyVersions['mongodb.version']}",
125+
'rxjava' : "io.reactivex:rxjava:${bomDependencyVersions['rxjava.version']}",
126+
'rxjava2' : "io.reactivex.rxjava2:rxjava:${bomDependencyVersions['rxjava2.version']}",
127+
'rxjava3' : "io.reactivex.rxjava3:rxjava:${bomDependencyVersions['rxjava3.version']}",
128128
]
129129

130130
// Because pom exclusions aren't properly supported by gradle, we can't inherit the grails-gradle-bom

etc/bin/test-reproducible-builds.sh

+8-2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ set -e
2121

2222
export SOURCE_DATE_EPOCH=$(git log -1 --pretty=%ct)
2323

24+
CWD=$(pwd)
2425
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
2526
cd "${SCRIPT_DIR}/../.."
2627

@@ -29,19 +30,24 @@ mkdir -p "${SCRIPT_DIR}/results"
2930

3031
git clean -xdf --exclude='etc/bin'
3132
killall -e java || true
33+
cd grails-gradle
34+
./gradlew build --rerun-tasks -PskipTests --no-build-cache
35+
cd ..
3236
./gradlew build --rerun-tasks -PskipTests --no-build-cache
3337
"${SCRIPT_DIR}/generate-build-artifact-hashes.groovy" > "${SCRIPT_DIR}/results/first.txt"
3438
mkdir -p "${SCRIPT_DIR}/results/first"
3539
find . -path ./etc -prune -o -type f -path '*/build/libs/*.jar' -print0 | xargs -0 cp --parents -t "${SCRIPT_DIR}/results/first/"
3640

3741
git clean -xdf --exclude='etc/bin'
3842
killall -e java || true
43+
cd grails-gradle
44+
./gradlew build --rerun-tasks -PskipTests --no-build-cache
45+
cd ..
3946
./gradlew build --rerun-tasks -PskipTests --no-build-cache
4047
"${SCRIPT_DIR}/generate-build-artifact-hashes.groovy" > "${SCRIPT_DIR}/results/second.txt"
4148
mkdir -p "${SCRIPT_DIR}/results/second"
4249
find . -path ./etc -prune -o -type f -path '*/build/libs/*.jar' -print0 | xargs -0 cp --parents -t "${SCRIPT_DIR}/results/second/"
4350

44-
cd -
4551
cd "${SCRIPT_DIR}/results"
4652

4753
# diff -u first.txt second.txt
@@ -61,4 +67,4 @@ find second -type f -name '*.jar' -print | sed 's|^second/||' | grep -F -x -v -f
6167
done
6268
rm toPurge.txt
6369
find . -type d -empty -delete
64-
cd -
70+
cd "$CWD"

gradle.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ org.gradle.caching=true
4949
# org.gradle.configuration-cache=true
5050
org.gradle.parallel=true
5151
org.gradle.daemon=true
52-
org.gradle.jvmargs=-Dfile.encoding=UTF-8 -Xmx1536M -XX:MaxMetaspaceSize=1024M
52+
org.gradle.jvmargs=-Dfile.encoding=UTF-8 -Xmx1792M -XX:MaxMetaspaceSize=1024M
5353

5454
# libraries only specific to test apps, these should not be exposed
5555
jbossTransactionApiVersion=2.0.0.Final

gradle/docs-config.gradle

+8-8
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ ext {
2323
includeInApiDocs = true
2424
}
2525

26-
tasks.named('groovydoc', Groovydoc).configure {
26+
tasks.named('groovydoc', Groovydoc).configure { Groovydoc it ->
2727
// TODO: Fix this for testFixtures
28-
classpath = configurations.documentation
29-
groovyClasspath = configurations.documentation
30-
access = GroovydocAccess.PROTECTED
31-
includeAuthor = true
32-
includeMainForScripts = false
33-
processScripts = false
34-
noTimestamp = true
28+
it.classpath = configurations.documentation
29+
it.groovyClasspath = configurations.documentation
30+
it.access = GroovydocAccess.PROTECTED
31+
it.includeAuthor = false
32+
it.includeMainForScripts = false
33+
it.processScripts = false
34+
it.noTimestamp = true
3535
}

gradle/docs-dependencies.gradle

+15-6
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,24 @@
1616
* specific language governing permissions and limitations
1717
* under the License.
1818
*/
19+
configurations.register('documentation') {
20+
canBeConsumed = false
21+
canBeResolved = true
22+
attributes {
23+
attribute(Category.CATEGORY_ATTRIBUTE, objects.named(Category, Category.LIBRARY))
24+
attribute(Bundling.BUNDLING_ATTRIBUTE, objects.named(Bundling, Bundling.EXTERNAL))
25+
attribute(Usage.USAGE_ATTRIBUTE, objects.named(Usage, Usage.JAVA_RUNTIME))
26+
}
27+
}
1928

20-
configurations.register('documentation')
2129
dependencies {
22-
add('documentation', platform("org.apache.grails:grails-gradle-bom:${projectVersion}"))
30+
add('documentation', platform(project(':grails-bom')))
2331
add('documentation', 'org.fusesource.jansi:jansi')
2432
add('documentation', 'jline:jline')
2533
add('documentation', 'com.github.javaparser:javaparser-core')
26-
add('documentation', 'org.codehaus.groovy:groovy')
27-
add('documentation', 'org.codehaus.groovy:groovy-ant')
28-
add('documentation', 'org.codehaus.groovy:groovy-docgenerator')
29-
add('documentation', 'org.codehaus.groovy:groovy-templates')
34+
add('documentation', 'org.apache.groovy:groovy')
35+
add('documentation', 'org.apache.groovy:groovy-groovydoc')
36+
add('documentation', 'org.apache.groovy:groovy-ant')
37+
add('documentation', 'org.apache.groovy:groovy-docgenerator')
38+
add('documentation', 'org.apache.groovy:groovy-templates')
3039
}

grails-bootstrap/build.gradle

+4-6
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,10 @@ dependencies {
3838
exclude group: 'org.codehaus.groovy'
3939
}
4040

41-
// we have to continue to compile with groovy 3 only because of grails-shell
42-
// the grails-shell will run under gradle and thus this must remain compatible
43-
compileOnly "org.codehaus.groovy:groovy:$GroovySystem.version"
44-
compileOnly "org.codehaus.groovy:groovy-templates:$GroovySystem.version"
45-
compileOnly "org.codehaus.groovy:groovy-xml:$GroovySystem.version"
46-
compileOnly "org.codehaus.groovy:groovy-ant:$GroovySystem.version"
41+
compileOnly 'org.apache.groovy:groovy'
42+
compileOnly 'org.apache.groovy:groovy-templates'
43+
compileOnly 'org.apache.groovy:groovy-xml'
44+
compileOnly 'org.apache.groovy:groovy-ant'
4745

4846
compileOnly 'io.methvin:directory-watcher'
4947
compileOnly 'org.fusesource.jansi:jansi'

grails-data-graphql/examples/spring-boot-app/build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ buildscript {
2222
mavenCentral()
2323
}
2424
dependencies {
25-
classpath platform("org.apache.grails:grails-bom:$projectVersion")
25+
classpath platform(project(":grails-bom"))
2626
classpath("org.springframework.boot:spring-boot-gradle-plugin")
2727
}
2828
}

grails-data-hibernate5/docs/build.gradle

+14-10
Original file line numberDiff line numberDiff line change
@@ -57,16 +57,23 @@ dependencies {
5757
.each { documentation project(":$it.name") }
5858
}
5959

60-
tasks.named('asciidoctor', AsciidoctorTask) {
61-
inputs.dir layout.projectDirectory.dir('src/docs')
62-
outputs.dir layout.buildDirectory.dir('asciidoc/manual')
63-
baseDirFollowsSourceDir()
60+
tasks.named('asciidoctor', AsciidoctorTask) { AsciidoctorTask it ->
61+
it.inputs.dir layout.projectDirectory.dir('src/docs/asciidoc')
62+
it.outputs.dir layout.buildDirectory.dir('asciidoc/manual')
63+
64+
it.jvm {
65+
jvmArgs('--add-opens', 'java.base/sun.nio.ch=ALL-UNNAMED', '--add-opens', 'java.base/java.io=ALL-UNNAMED')
66+
}
67+
it.baseDirFollowsSourceDir()
68+
it.sourceDir layout.projectDirectory.dir('src/docs/asciidoc')
69+
it.outputDir = layout.buildDirectory.dir('asciidoc/manual')
70+
6471
resources {
65-
from("$project.projectDir/src/docs/asciidoc/images")
72+
from(project.layout.projectDirectory.dir("src/docs/asciidoc/images"))
6673
into './images'
6774
}
6875

69-
attributes(
76+
it.attributes = [
7077
'experimental': 'true',
7178
'compat-mode': 'true',
7279
'toc': 'left',
@@ -81,10 +88,7 @@ tasks.named('asciidoctor', AsciidoctorTask) {
8188
'migrationPluginGroupId': rootProject.findProject(':grails-data-hibernate5-dbmigration').group,
8289
'migrationPluginArtifactId': rootProject.findProject(':grails-data-hibernate5-dbmigration').name,
8390
'liquibaseHibernate5Version': liquibaseHibernate5Version
84-
)
85-
jvm {
86-
jvmArgs('--add-opens', 'java.base/sun.nio.ch=ALL-UNNAMED', '--add-opens', 'java.base/java.io=ALL-UNNAMED')
87-
}
91+
]
8892
}
8993

9094
tasks.withType(Groovydoc).configureEach {

grails-data-mongodb/docs/build.gradle

+4-4
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,15 @@ dependencies {
7676
tasks.named('asciidoctor', AsciidoctorTask) { AsciidoctorTask it ->
7777
dependsOn('resolveMongodbVersion')
7878

79-
inputs.dir project.layout.projectDirectory.dir('src/docs')
80-
outputs.dir layout.buildDirectory.dir('asciidoc/manual')
79+
it.inputs.dir project.layout.projectDirectory.dir('src/docs/asciidoc')
80+
it.outputs.dir layout.buildDirectory.dir('asciidoc/manual')
8181

8282
it.jvm {
8383
jvmArgs("--add-opens", "java.base/sun.nio.ch=ALL-UNNAMED", "--add-opens", "java.base/java.io=ALL-UNNAMED")
8484
}
8585
it.baseDirFollowsSourceFile()
86-
it.sourceDir layout.projectDirectory.dir('src/docs')
87-
it.outputDir = layout.buildDirectory.dir('docs')
86+
it.sourceDir layout.projectDirectory.dir('src/docs/asciidoc')
87+
it.outputDir = layout.buildDirectory.dir('asciidoc/manual')
8888
it.attributes = [
8989
'experimental' : 'true',
9090
'compat-mode' : 'true',

grails-data-neo4j/grails-plugin/build.gradle

-7
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,6 @@
2020
sourceCompatibility = "1.11"
2121
targetCompatibility = "1.11"
2222

23-
dependencyManagement {
24-
imports {
25-
mavenBom "org.apache.grails:grails-bom:$pluginGrailsVersion"
26-
}
27-
applyMavenExclusions false
28-
}
29-
3023
// TODO: Use bom
3124
//configurations.configureEach {
3225
// exclude group: 'org.apache.grails.data', module: 'grails-data-simple'

grails-gradle/build.gradle

+1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ allprojects {
3131
// mavenLocal()
3232
mavenCentral()
3333
gradlePluginPortal()
34+
maven { url = 'https://repository.apache.org/content/groups/snapshots' }
3435
}
3536

3637
props.forEach { k, v -> project.ext.set(k as String, v) }

grails-gradle/docs-core/build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ tasks.named('jar', Jar).configure { Jar it ->
8585
jar.dependsOn docFilesJar
8686

8787
apply {
88-
from rootProject.layout.projectDirectory.file('gradle/docs-config.gradle')
8988
from rootProject.layout.projectDirectory.file('gradle/java-config.gradle')
89+
from rootProject.layout.projectDirectory.file('gradle/docs-config.gradle')
9090
from rootProject.layout.projectDirectory.file('gradle/test-config.gradle')
9191
}
9292

grails-gradle/gradle/docs-config.gradle

+43-24
Original file line numberDiff line numberDiff line change
@@ -17,42 +17,61 @@
1717
* under the License.
1818
*/
1919

20-
configurations.register('documentation')
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+
}
2129
dependencies {
2230
add('documentation', platform(project(':grails-gradle-bom')))
2331
add('documentation', 'org.fusesource.jansi:jansi')
2432
add('documentation', 'jline:jline')
2533
add('documentation', 'com.github.javaparser:javaparser-core')
26-
add('documentation', 'org.codehaus.groovy:groovy')
27-
add('documentation', 'org.codehaus.groovy:groovy-ant')
28-
add('documentation', 'org.codehaus.groovy:groovy-docgenerator')
29-
add('documentation', 'org.codehaus.groovy:groovy-templates')
34+
add('documentation', "org.apache.groovy:groovy:${bomDependencyVersions['groovy.version']}")
35+
add('documentation', "org.apache.groovy:groovy-groovydoc:${bomDependencyVersions['groovy.version']}")
36+
add('documentation', "org.apache.groovy:groovy-ant:${bomDependencyVersions['groovy.version']}")
37+
add('documentation', "org.apache.groovy:groovy-docgenerator:${bomDependencyVersions['groovy.version']}")
38+
add('documentation', "org.apache.groovy:groovy-templates:${bomDependencyVersions['groovy.version']}")
3039
}
3140

3241
ext {
3342
includeInApiDocs = true
3443
}
3544

36-
tasks.named('groovydoc', Groovydoc).configure {
37-
classpath = configurations.documentation
38-
groovyClasspath = configurations.documentation
39-
access = GroovydocAccess.PROTECTED
40-
includeAuthor = true
41-
includeMainForScripts = false
42-
processScripts = false
43-
destinationDir = project.file('build/docs/api')
45+
TaskProvider<Groovydoc> groovydocTask = tasks.named('groovydoc', Groovydoc)
46+
groovydocTask.configure { Groovydoc it ->
47+
it.classpath = configurations.documentation
48+
it.groovyClasspath = configurations.documentation
49+
it.access = GroovydocAccess.PROTECTED
50+
it.includeAuthor = false
51+
it.includeMainForScripts = false
52+
it.processScripts = false
53+
it.noTimestamp = true
54+
it.destinationDir = project.file('build/docs/api')
4455
}
4556

46-
tasks.named('javadoc', Javadoc).configure { Javadoc it ->
47-
(it.options as StandardJavadocDocletOptions).with {
48-
encoding = 'UTF-8'
49-
docEncoding = 'UTF-8'
50-
charSet = 'UTF-8'
51-
addStringOption('Xms64M')
52-
addStringOption('Xmx512M')
53-
}
57+
tasks.named('javadoc').configure {
58+
it.enabled = false
59+
}
60+
61+
tasks.named('javadocJar', Jar).configure { Jar jar ->
62+
jar.reproducibleFileOrder = true
63+
jar.preserveFileTimestamps = false
64+
jar.dirMode = 0755 // To avoid platform specific defaults
65+
jar.fileMode = 0644 // to avoid platform specific defaults
66+
67+
jar.dependsOn(groovydocTask)
68+
69+
// Ensure the java source set is included in the groovydoc source set
70+
SourceSetContainer sourceSets = project.extensions.getByType(SourceSetContainer)
71+
groovydocTask.get().source(project.files(sourceSets.main.java.srcDirs))
72+
73+
ConfigurableFileCollection groovyDocFiles = project.files(groovydocTask.get().destinationDir)
74+
jar.from(groovyDocFiles)
75+
jar.inputs.files(groovyDocFiles)
5476
}
5577

56-
tasks.named('build').configure {
57-
finalizedBy('groovydoc')
58-
}

grails-gradle/gradle/java-config.gradle

+11-3
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,17 @@ extensions.configure(JavaPluginExtension) {
2525
it.withSourcesJar()
2626
}
2727

28-
tasks.withType(Javadoc).configureEach { Javadoc it ->
29-
it.options.noTimestamp true // prevent the file header with the date
30-
it.options.bottom "Generated ${formattedBuildDate} (UTC)"
28+
tasks.named('sourcesJar', Jar).configure { Jar jar ->
29+
SourceSetContainer sourceSets = project.extensions.getByType(JavaPluginExtension).sourceSets
30+
jar.reproducibleFileOrder = true
31+
jar.preserveFileTimestamps = false
32+
jar.dirMode = 0755 // To avoid platform specific defaults
33+
jar.fileMode = 0644 // to avoid platform specific defaults
34+
jar.duplicatesStrategy = DuplicatesStrategy.EXCLUDE
35+
36+
// don't only include main, but any source set
37+
jar.from sourceSets.collect { it.allSource }
38+
jar.inputs.files(sourceSets.collect { it.allSource })
3139
}
3240

3341
// JavaCompile is not configured because we put java files inside of the groovy source sets

grails-gradle/model/build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ dependencies {
6969
}
7070

7171
apply {
72-
from rootProject.layout.projectDirectory.file('gradle/docs-config.gradle')
7372
from rootProject.layout.projectDirectory.file('gradle/java-config.gradle')
73+
from rootProject.layout.projectDirectory.file('gradle/docs-config.gradle')
7474
from rootProject.layout.projectDirectory.file('gradle/test-config.gradle')
7575
}
7676

0 commit comments

Comments
 (0)