Skip to content

Commit dfbed8a

Browse files
authored
Merge pull request #15557 from apache/grails8-groovy5-sb4
Groovy 5.0.x support for Grails 8 + Spring Boot 4
2 parents 66cd24c + 2966b3b commit dfbed8a

112 files changed

Lines changed: 876 additions & 445 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* https://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
// Gradle init-script applied during the Groovy joint-validation build.
19+
// Overrides Develocity and build-cache configuration injected by Groovy's own
20+
// build-scans.gradle without modifying any of Groovy's source files.
21+
//
22+
// Applied via: ./gradlew --init-script <path>/groovy-joint-build.init.gradle
23+
//
24+
// Defensive: the pluginManager.withPlugin guard makes this a no-op when the
25+
// Develocity plugin is absent, so the script never crashes Groovy's build.
26+
27+
settingsEvaluated { settings ->
28+
settings.pluginManager.withPlugin('com.gradle.develocity') {
29+
def isAuthenticated = System.getenv('GRAILS_DEVELOCITY_ACCESS_KEY') != null
30+
31+
// 'develocity' is the DSL extension registered by the plugin on Settings.
32+
settings.develocity {
33+
server = 'https://develocity.apache.org'
34+
35+
buildScan {
36+
// Tag the build for visibility on develocity.apache.org. Groovy's own
37+
// gradle/build-scans.gradle does not add any tags, so additive is safe.
38+
tag('groovy')
39+
tag('grails-core')
40+
// Only publish when a valid access key is present in the environment.
41+
publishing.onlyIf { isAuthenticated }
42+
uploadInBackground = false
43+
}
44+
}
45+
46+
settings.buildCache {
47+
local {
48+
enabled = false
49+
}
50+
remote(settings.develocity.buildCache) {
51+
push = isAuthenticated
52+
enabled = true
53+
}
54+
}
55+
}
56+
}

.github/workflows/codeql.yml

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -69,26 +69,12 @@ jobs:
6969
uses: github/codeql-action/init@7211b7c8077ea37d8641b6271f6a365a22a5fbfa # v4.36.0
7070
with:
7171
languages: ${{ matrix.language }}
72+
# The autobuild action runs `./gradlew testClasses`, which compiles Groovy sample apps that are covered by regular CI.
73+
build-mode: none
7274
# If you wish to specify custom queries, you can do so here or in a config file.
7375
# By default, queries listed here will override any specified in a config file.
7476
# Prefix the list here with "+" to use these queries and those in the config file.
7577
# queries: ./path/to/local/query, your-org/your-repo/queries@main
7678

77-
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
78-
# If this step fails, then you should remove it and run the build manually (see below)
79-
- name: Autobuild
80-
uses: github/codeql-action/autobuild@7211b7c8077ea37d8641b6271f6a365a22a5fbfa # v4.36.0
81-
82-
# ℹ️ Command-line programs to run using the OS shell.
83-
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
84-
85-
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
86-
# and modify them (or add more) to build your code if your project
87-
# uses a compiled language
88-
89-
#- run: |
90-
# make bootstrap
91-
# make release
92-
9379
- name: Perform CodeQL Analysis
9480
uses: github/codeql-action/analyze@7211b7c8077ea37d8641b6271f6a365a22a5fbfa # v4.36.0

.github/workflows/groovy-joint-workflow.yml

Lines changed: 32 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -47,23 +47,40 @@ jobs:
4747
with:
4848
path: ~/.m2/repository
4949
key: cache-local-maven-${{ github.sha }}
50-
- name: "📥 Checkout Grails Core to fetch Gradle Plugin versions it uses"
50+
- name: "📥 Checkout Grails Core files needed for the Groovy joint-build"
51+
# Sparse-checkout fetches only the two paths this job actually needs:
52+
# - dependencies.gradle: parsed below to derive the matching Apache
53+
# Groovy branch (GROOVY_<major>_0_X) for this Grails branch.
54+
# - .github/scripts/groovy-joint-build.init.gradle: passed to
55+
# ./gradlew --init-script when publishing Groovy to local Maven so
56+
# the joint build reuses our Develocity / build-cache settings.
57+
# Both paths must be listed here; otherwise the init-script step fails
58+
# with "The specified initialization script ... does not exist."
5159
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
5260
with:
5361
sparse-checkout-cone-mode: false
54-
sparse-checkout: settings.gradle
55-
- name: "📝 Store the Gradle Plugin versions used in this project"
56-
id: gradle-plugin-versions
62+
sparse-checkout: |
63+
dependencies.gradle
64+
.github/scripts/groovy-joint-build.init.gradle
65+
- name: "📝 Derive matching Apache Groovy branch from dependencies.gradle"
66+
id: groovy-branch
5767
run: |
58-
DEVELOCITY_PLUGIN_VERSION=$(grep -m 1 'id\s*\(\"com.gradle.develocity\"\|'"'com.gradle.develocity'"'\)\s*version' settings.gradle | sed -E "s/.*version[[:space:]]*['\"]?([0-9]+\.[0-9]+(\.[0-9]+)?)['\"]?.*/\1/" | tr -d [:space:])
59-
COMMON_CUSTOM_USER_DATA_PLUGIN_VERSION=$(grep -m 1 'id\s*\(\"com.gradle.common-custom-user-data-gradle-plugin\"\|'"'com.gradle.common-custom-user-data-gradle-plugin'"'\)\s*version' settings.gradle | sed -E "s/.*version[[:space:]]*['\"]?([0-9]+\.[0-9]+(\.[0-9]+)?)['\"]?.*/\1/" | tr -d [:space:])
60-
echo "Project uses Develocity Plugin version: $DEVELOCITY_PLUGIN_VERSION"
61-
echo "Project uses Common Custom User Data Plugin version: $COMMON_CUSTOM_USER_DATA_PLUGIN_VERSION"
62-
echo "develocity_plugin_version=$DEVELOCITY_PLUGIN_VERSION" >> $GITHUB_OUTPUT
63-
echo "common_custom_user_data_plugin_version=$COMMON_CUSTOM_USER_DATA_PLUGIN_VERSION" >> $GITHUB_OUTPUT
64-
rm settings.gradle
65-
- name: "📥 Checkout Groovy 4_0_X (Grails 7 and later)"
66-
run: git clone --depth 1 https://github.com/apache/groovy.git -b GROOVY_4_0_X --single-branch
68+
# Extract the major version of `groovy.version` declared in this branch's
69+
# dependencies.gradle (e.g. '5.0.5' -> '5', '4.0.31' -> '4') and use it to
70+
# pick the matching Apache Groovy development branch (GROOVY_<major>_0_X).
71+
# This keeps `7.0.x` PRs validating against Groovy 4 and `8.0.x` PRs
72+
# validating against Groovy 5 without hard-coding the branch here.
73+
GROOVY_MAJOR=$(grep -m 1 "'groovy\.version'" dependencies.gradle | sed -E "s/.*'([0-9]+)\.[0-9]+\.[0-9]+.*/\1/" | tr -d '[:space:]')
74+
if [ -z "$GROOVY_MAJOR" ]; then
75+
echo "::error::Could not determine Apache Groovy major version from dependencies.gradle"
76+
exit 1
77+
fi
78+
GROOVY_BRANCH="GROOVY_${GROOVY_MAJOR}_0_X"
79+
echo "Validating against Apache Groovy branch: $GROOVY_BRANCH"
80+
echo "value=$GROOVY_BRANCH" >> $GITHUB_OUTPUT
81+
rm dependencies.gradle
82+
- name: "📥 Checkout Apache Groovy (${{ steps.groovy-branch.outputs.value }})"
83+
run: git clone --depth 1 https://github.com/apache/groovy.git -b ${{ steps.groovy-branch.outputs.value }} --single-branch
6784
- name: "🐘 Setup Gradle"
6885
uses: gradle/actions/setup-gradle@50e97c2cd7a37755bbfafc9c5b7cafaece252f6e # v6.1.0
6986
with:
@@ -78,54 +95,11 @@ jobs:
7895
GROOVY_VERSION=$(cat gradle.properties | grep groovyVersion | cut -d\= -f2 | tr -d '[:space:]')
7996
echo "Groovy version $GROOVY_VERSION stored"
8097
echo "value=$GROOVY_VERSION" >> $GITHUB_OUTPUT
81-
- name: "🐘 Configure Gradle Plugins (Step 1/3)"
82-
id: develocity-conf-1
83-
run: |
84-
echo "VALUE<<EOF" >> $GITHUB_OUTPUT
85-
echo "plugins { " >> $GITHUB_OUTPUT
86-
echo " id 'com.gradle.develocity' version '${{ steps.gradle-plugin-versions.outputs.develocity_plugin_version }}'" >> $GITHUB_OUTPUT
87-
echo " id 'com.gradle.common-custom-user-data-gradle-plugin' version '${{ steps.gradle-plugin-versions.outputs.common_custom_user_data_plugin_version }}'" >> $GITHUB_OUTPUT
88-
echo "}" >> $GITHUB_OUTPUT
89-
echo "" >> $GITHUB_OUTPUT
90-
echo "EOF" >> $GITHUB_OUTPUT
91-
- name: "🐘 Configure Gradle Plugins (Step 2/3)"
92-
id: develocity-conf-2
93-
run: |
94-
echo "VALUE<<EOF" >> $GITHUB_OUTPUT
95-
echo "def isAuthenticated = System.getenv('DEVELOCITY_ACCESS_KEY ') != null" >> $GITHUB_OUTPUT
96-
echo "develocity {" >> $GITHUB_OUTPUT
97-
echo " server = 'https://develocity.apache.org'" >> $GITHUB_OUTPUT
98-
echo " buildScan {" >> $GITHUB_OUTPUT
99-
echo " tag('groovy')" >> $GITHUB_OUTPUT
100-
echo " tag('grails-core')" >> $GITHUB_OUTPUT
101-
echo " publishing.onlyIf { isAuthenticated }" >> $GITHUB_OUTPUT
102-
echo " uploadInBackground = false" >> $GITHUB_OUTPUT
103-
echo " }" >> $GITHUB_OUTPUT
104-
echo "}" >> $GITHUB_OUTPUT
105-
echo "buildCache {" >> $GITHUB_OUTPUT
106-
echo " local { enabled = false }" >> $GITHUB_OUTPUT
107-
echo " remote(develocity.buildCache) {" >> $GITHUB_OUTPUT
108-
echo " push = isAuthenticated" >> $GITHUB_OUTPUT
109-
echo " enabled = true" >> $GITHUB_OUTPUT
110-
echo " }" >> $GITHUB_OUTPUT
111-
echo "}" >> $GITHUB_OUTPUT
112-
echo "" >> $GITHUB_OUTPUT
113-
echo "EOF" >> $GITHUB_OUTPUT
114-
- name: "🐘 Configure Gradle Plugins (step 3/3)"
115-
run: |
116-
cd groovy
117-
# Delete existing plugins from settings.gradle file
118-
sed -i '32,37d' settings.gradle
119-
# Add Develocity setup related configuration after line no 31 in settings.gradle
120-
echo "${{ steps.develocity-conf-1.outputs.value }}" | sed -i -e "31r /dev/stdin" settings.gradle
121-
# Delete existing buildCache configuration from gradle/build-scans.gradle file
122-
sed -i '23,46d' gradle/build-scans.gradle
123-
# Add Develocity setup related configuration after line no 22 in gradle/build-scans.gradle
124-
echo "${{ steps.develocity-conf-2.outputs.value }}" | sed -i -e "22r /dev/stdin" gradle/build-scans.gradle
12598
- name: "🔨 Publish Groovy to local maven repository (no docs)"
12699
run: |
127100
cd groovy
128-
./gradlew pTML -x groovydoc -x javadoc -x javadocAll -x groovydocAll -x asciidoc -x docGDK
101+
./gradlew pTML -x groovydoc -x javadoc -x javadocAll -x groovydocAll -x asciidoc -x docGDK \
102+
--init-script $GITHUB_WORKSPACE/.github/scripts/groovy-joint-build.init.gradle
129103
build_grails:
130104
needs: [build_groovy]
131105
runs-on: ubuntu-latest

build-logic/plugins/src/main/groovy/org/apache/grails/buildsrc/SbomPlugin.groovy

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,15 +92,25 @@ class SbomPlugin implements Plugin<Project> {
9292
]
9393

9494
private static Map<String, String> LICENSE_MAPPING = [
95-
'pkg:maven/org.antlr/antlr4-runtime@4.7.2?type=jar' : 'BSD-3-Clause', // maps incorrectly because of https://github.com/CycloneDX/cyclonedx-core-java/issues/205
96-
'pkg:maven/jline/jline@2.14.6?type=jar' : 'BSD-2-Clause', // maps incorrectly because of https://github.com/CycloneDX/cyclonedx-core-java/issues/205
97-
'pkg:maven/org.jline/jline@3.30.6?type=jar' : 'BSD-3-Clause', // maps incorrectly because of https://github.com/CycloneDX/cyclonedx-core-java/issues/205
98-
'pkg:maven/org.liquibase.ext/liquibase-hibernate5@4.27.0?type=jar': 'Apache-2.0', // maps incorrectly because of https://github.com/liquibase/liquibase/issues/2445 & the base pom does not define a license
9995
'pkg:maven/com.oracle.coherence.ce/coherence-bom@25.03.1?type=pom': 'UPL-1.0', // does not have map based on license id
10096
'pkg:maven/com.oracle.coherence.ce/coherence-bom@25.03.2?type=pom': 'UPL-1.0', // does not have map based on license id
10197
'pkg:maven/com.oracle.coherence.ce/coherence-bom@22.06.2?type=pom': 'UPL-1.0', // does not have map based on license id
98+
'pkg:maven/jline/jline@2.14.6?type=jar' : 'BSD-2-Clause', // maps incorrectly because of https://github.com/CycloneDX/cyclonedx-core-java/issues/205
10299
'pkg:maven/opensymphony/sitemesh@2.6.0?type=jar' : 'OpenSymphony', // custom license approved by legal LEGAL-707
100+
'pkg:maven/org.antlr/antlr4-runtime@4.7.2?type=jar' : 'BSD-3-Clause', // maps incorrectly because of https://github.com/CycloneDX/cyclonedx-core-java/issues/205
101+
'pkg:maven/org.jline/jansi@3.30.9?type=jar' : 'BSD-3-Clause', // jline group resolved at 3.30.9 transitively via groovy-groovysh; main org.jline:jline pinned at 3.30.6 directly
102+
'pkg:maven/org.jline/jline@3.30.6?type=jar' : 'BSD-3-Clause', // direct dependency declared at jline.version in dependencies.gradle
103+
'pkg:maven/org.jline/jline-builtins@3.30.9?type=jar' : 'BSD-3-Clause', // jline group resolved at 3.30.9 transitively via groovy-groovysh; main org.jline:jline pinned at 3.30.6 directly
104+
'pkg:maven/org.jline/jline-console@3.30.9?type=jar' : 'BSD-3-Clause', // jline group resolved at 3.30.9 transitively via groovy-groovysh; main org.jline:jline pinned at 3.30.6 directly
105+
'pkg:maven/org.jline/jline-native@3.30.9?type=jar' : 'BSD-3-Clause', // jline group resolved at 3.30.9 transitively via groovy-groovysh; main org.jline:jline pinned at 3.30.6 directly
106+
'pkg:maven/org.jline/jline-reader@3.30.9?type=jar' : 'BSD-3-Clause', // jline group resolved at 3.30.9 transitively via groovy-groovysh; main org.jline:jline pinned at 3.30.6 directly
107+
'pkg:maven/org.jline/jline-style@3.30.9?type=jar' : 'BSD-3-Clause', // jline group resolved at 3.30.9 transitively via groovy-groovysh; main org.jline:jline pinned at 3.30.6 directly
108+
'pkg:maven/org.jline/jline-terminal@3.30.9?type=jar' : 'BSD-3-Clause', // jline group resolved at 3.30.9 transitively via groovy-groovysh; main org.jline:jline pinned at 3.30.6 directly
109+
'pkg:maven/org.jline/jline-terminal-jansi@3.30.9?type=jar' : 'BSD-3-Clause', // jline group resolved at 3.30.9 transitively via groovy-groovysh; main org.jline:jline pinned at 3.30.6 directly
110+
'pkg:maven/org.jline/jline-terminal-jna@3.30.9?type=jar' : 'BSD-3-Clause', // jline group resolved at 3.30.9 transitively via groovy-groovysh; main org.jline:jline pinned at 3.30.6 directly
111+
'pkg:maven/org.jline/jline-terminal-jni@3.30.9?type=jar' : 'BSD-3-Clause', // jline group resolved at 3.30.9 transitively via groovy-groovysh; main org.jline:jline pinned at 3.30.6 directly
103112
'pkg:maven/org.jruby/jzlib@1.1.5?type=jar' : 'BSD-3-Clause', // https://web.archive.org/web/20240822213507/http://www.jcraft.com/jzlib/LICENSE.txt shows it's a 3 clause
113+
'pkg:maven/org.liquibase.ext/liquibase-hibernate5@4.27.0?type=jar': 'Apache-2.0', // maps incorrectly because of https://github.com/liquibase/liquibase/issues/2445 & the base pom does not define a license
104114
]
105115

106116
// we don't distribute these so these licenses are considered acceptable, but we still prefer ASF licenses.

0 commit comments

Comments
 (0)