Skip to content

Commit 05ddf14

Browse files
authored
chore(build): Modernise and clean up build (#504)
* chore(build): Modernise and clean up build - Implement buildSrc to isolate build related code and deps - Rename gradle plugin project dir to gradle-plugin - Add gradle dir for version catalogs - Implement version catalogs to handle versions - Remove redundant gradle files from subprojects - Move grailsCentralPublishing.gradle to gradle dir - Use project.layout to reference files and dirs - Make build more type-safe with IDE code completion - Unify quote usage - Clean up dependencies and tighten their scopes - Use lazy configuration where possible - Remove unused ext properties - Create workarounds for grails-gradle-plugin exposing groovy - Remove used resources and attribute to asciidoctor task - Fix classpath issues with groovydoc task - Change 'docs' task as there is nothing to copy - Change jar manifest to reflect projects properties - Remove redundant Application.groovy from views-markup - Update example projects - Add missing CompileStatic and make compatible with Groovy 3.0.21-SNAPSHOT * fix(build): Move Snapshot repos to the right place The snapshot repositories had accidentally been placed outside the configuration of the PublishingExtension. * build(chore): Clean up secret passing from GH action By using the ORG_GRADLE_PROJECT_** env vars build files can be cleaned up from checking at multiple places for the values. * ci: Replace Java 14 with Java 17 in build matrix * build: Declare grailsVersion in one place With this change the Grails version is only declared once. * build: Update Groovy Joint workflow The groovy version was not resolved correctly previously. With this change it gets set as three different environment vars. CI_GROOVY_VERSION and GROOVY_VERSION as regular environment vars and with ORG_GRADLE_PROJECT_groovyVersion that sets the groovyVersion project property. This allows for some choices in how to handle this in the build script. This change also adds a section to the settings.gradle file to allow for overriding the groovy version in the version catalog with the GROOVY_VERSION env variable. * build: Create configuration for Groovydoc The Groovydoc Gradle task need to be run with the same groovy version as Gradle. * build: Change workflow JDK to temurin AdoptOpenJDK got moved to Eclipe Temurin and won't be updated anymore. * build: Cleanup handling of sonatype credentials With this change there is no need to check both environment variables and project properties. Also move the sonatype repo info to a project property. * chore(deps): Update grails-gradle-plugin to 6.1.2 * chore(deps): Update grails to 6.1.2 * build: Make groovy workflow version independent With this change the workflow will use the versions of groovy and gradle enterprise that are defined in the build rather than hard-coding them in the actions file. * build: Minor cleanups * ci: Remove publishing of test reports These can now be viewed in build scans. * build: Remove unused import * ci: Remove java version matrix for release No need to run this on multiple versions * build: Change author and git email Puneet has a new email
1 parent e8908aa commit 05ddf14

File tree

151 files changed

+992
-3184
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

151 files changed

+992
-3184
lines changed

.github/workflows/gradle.yml

Lines changed: 34 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -9,76 +9,86 @@ on:
99
- master
1010
- '[2-9]+.[0-9]+.x'
1111
jobs:
12+
1213
build:
1314
runs-on: ubuntu-latest
15+
1416
strategy:
17+
fail-fast: false
1518
matrix:
16-
java: ['11', '14']
19+
java: [11, 17]
20+
1721
env:
1822
WORKSPACE: ${{ github.workspace }}
1923
GRADLE_OPTS: -Xmx1500m -Dfile.encoding=UTF-8
24+
2025
steps:
2126
- uses: actions/checkout@v4
22-
- name: Set up JDK
23-
uses: actions/setup-java@v4
27+
- uses: gradle/wrapper-validation-action@v2
28+
- uses: actions/setup-java@v4
2429
with:
25-
distribution: 'adopt'
30+
distribution: temurin
2631
java-version: ${{ matrix.java }}
32+
2733
- name: Run Tests
2834
if: github.event_name == 'pull_request'
2935
id: tests
30-
uses: gradle/gradle-build-action@v2
31-
with:
32-
arguments: check -Dgeb.env=chromeHeadless
36+
uses: gradle/actions/setup-gradle@v3
3337
env:
3438
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
3539
GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }}
36-
GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }}
40+
GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }}
41+
with:
42+
arguments: |
43+
check
44+
-Dgeb.env=chromeHeadless
45+
3746
- name: Run Build
3847
if: github.event_name == 'push'
3948
id: build
40-
uses: gradle/gradle-build-action@v2
49+
uses: gradle/actions/setup-gradle@v3
4150
env:
4251
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
4352
GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }}
4453
GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }}
4554
with:
46-
arguments: build -Dgeb.env=chromeHeadless
47-
- name: Publish Test Report
48-
if: steps.build.outcome == 'failure' || steps.tests.outcome == 'failure'
49-
uses: scacap/action-surefire-report@v1
50-
with:
51-
github_token: ${{ secrets.GITHUB_TOKEN }}
52-
report_paths: '**/build/test-results/test/TEST-*.xml'
53-
- name: Publish to repo.grails.org
55+
arguments: |
56+
build
57+
-Dgeb.env=chromeHeadless
58+
59+
- name: Publish Snapshot to repo.grails.org
5460
id: publish
55-
uses: gradle/gradle-build-action@v2
61+
uses: gradle/actions/setup-gradle@v3
5662
if: steps.build.outcome == 'success' && github.event_name == 'push' && matrix.java == '11'
5763
env:
58-
ARTIFACTORY_USERNAME: ${{ secrets.ARTIFACTORY_USERNAME }}
59-
ARTIFACTORY_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }}
64+
ORG_GRADLE_PROJECT_artifactoryUsername: ${{ secrets.ARTIFACTORY_USERNAME }}
65+
ORG_GRADLE_PROJECT_artifactoryPassword: ${{ secrets.ARTIFACTORY_PASSWORD }}
6066
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
6167
GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }}
6268
GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }}
6369
with:
64-
arguments: -Dorg.gradle.internal.publish.checksums.insecure=true publish
70+
arguments: |
71+
-Dorg.gradle.internal.publish.checksums.insecure=true
72+
publish
73+
6574
- name: Build Docs
6675
id: docs
6776
if: steps.build.outcome == 'success' && github.event_name == 'push' && matrix.java == '11'
68-
uses: gradle/gradle-build-action@v2
77+
uses: gradle/actions/setup-gradle@v3
6978
env:
7079
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
7180
GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }}
7281
GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }}
7382
with:
7483
arguments: views-docs:docs
75-
- name: Publish to Github Pages
84+
85+
- name: Publish Snapshot docs to Github Pages
7686
if: steps.docs.outcome == 'success' && github.event_name == 'push' && matrix.java == '11'
7787
uses: micronaut-projects/github-pages-deploy-action@grails
7888
env:
7989
TARGET_REPOSITORY: ${{ github.repository }}
8090
GH_TOKEN: ${{ secrets.GH_TOKEN }}
8191
BRANCH: gh-pages
8292
FOLDER: docs/build/docs
83-
COMMIT_EMAIL: behlp@objectcomputing.com
93+
COMMIT_EMAIL: behlp@unityfoundation.io
8494
COMMIT_NAME: Puneet Behl
Lines changed: 96 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -1,107 +1,124 @@
1-
# Licensed to the Apache Software Foundation (ASF) under one or more
2-
# contributor license agreements. See the NOTICE file distributed with
3-
# this work for additional information regarding copyright ownership.
4-
# The ASF licenses this file to You under the Apache License, Version 2.0
5-
# (the "License"); you may not use this file except in compliance with
6-
# the License. You may obtain a copy of the License at
7-
#
8-
# http://www.apache.org/licenses/LICENSE-2.0
9-
#
10-
# Unless required by applicable law or agreed to in writing, software
11-
# distributed under the License is distributed on an "AS IS" BASIS,
12-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
# See the License for the specific language governing permissions and
14-
# limitations under the License.
15-
16-
name: "Grails Joint Validation Build"
17-
# GROOVY_2_5_X == Grails 4.0.x
18-
# GROOVY_3_0_X == grails master
19-
# Groovy master branch does not map to any due to changed package names.
1+
name: "Groovy Joint Validation Build"
202
on:
213
push:
224
branches:
23-
- '[3-9]+.[1-9]+.x'
5+
- '[3-9]+.[0-9]+.x'
246
pull_request:
257
branches:
26-
- '[3-9]+.[1-9]+.x'
8+
- '[3-9]+.[0-9]+.x'
279
workflow_dispatch:
2810
permissions:
2911
contents: read
30-
env:
31-
CI_GROOVY_VERSION:
3212
jobs:
3313
build_groovy:
34-
strategy:
35-
fail-fast: true
3614
runs-on: ubuntu-latest
3715
outputs:
38-
groovyVersion: ${{ steps.groovy-version.outputs.value }}
16+
groovySnapshotVersion: ${{ steps.groovy_snapshot_version.outputs.value }}
3917
steps:
18+
4019
- name: Set up JDK
4120
uses: actions/setup-java@v4
4221
with:
43-
distribution: 'adopt'
44-
java-version: '11.0.6'
22+
distribution: temurin
23+
java-version: 11
24+
4525
- name: Cache local Maven repository & Groovy
4626
uses: actions/cache@v4
4727
with:
4828
path: |
4929
~/groovy
5030
~/.m2/repository
5131
key: cache-local-groovy-maven-${{ github.sha }}
52-
- name: Checkout Groovy 3_0_X (Grails 5 and later)
53-
if: startsWith(github.ref, 'refs/heads/3.') || startsWith(github.base_ref, '3.')
54-
run: cd .. && git clone --depth 1 https://github.com/apache/groovy.git -b GROOVY_3_0_X --single-branch
55-
- name: Set CI_GROOVY_VERSION for Grails
56-
id: groovy-version
32+
33+
- name: Checkout project to fetch some versions it uses
34+
uses: actions/checkout@v4
35+
with:
36+
sparse-checkout-cone-mode: false
37+
sparse-checkout: |
38+
settings.gradle
39+
gradle/libs.versions.toml
40+
41+
- name: Get version of Gradle Enterprise plugin
42+
id: gradle_enterprise_version
43+
run: |
44+
GE_PLUGIN_VERSION=$(grep -m 1 'id\s*\(\"com.gradle.enterprise\"\|'"'com.gradle.enterprise'"'\)\s*version' settings.gradle | sed -E "s/.*version[[:space:]]*['\"]?([0-9]+\.[0-9]+\.[0-9]+)['\"]?.*/\1/" | tr -d [:space:])
45+
GE_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:])
46+
echo "Project uses Gradle Enterprise Plugin version: $GE_PLUGIN_VERSION"
47+
echo "Project uses Gradle Common Custom User Data Plugin version: $GE_USER_DATA_PLUGIN_VERSION"
48+
echo "ge_plugin_version=$GE_PLUGIN_VERSION" >> $GITHUB_OUTPUT
49+
echo "ge_user_data_plugin_version=$GE_USER_DATA_PLUGIN_VERSION" >> $GITHUB_OUTPUT
50+
rm settings.gradle
51+
52+
- name: Select Groovy Branch to checkout
53+
id: groovy_branch
54+
run: |
55+
PROJECT_GROOVY_VERSION=$(grep -m 1 groovy gradle/libs.versions.toml | cut -d\= -f2 | tr -d "[:space:]'\"")
56+
MAJOR_VERSION=$(echo $PROJECT_GROOVY_VERSION | cut -d'.' -f1)
57+
MINOR_VERSION=$(echo $PROJECT_GROOVY_VERSION | cut -d'.' -f2)
58+
BRANCH="GROOVY_${MAJOR_VERSION}_${MINOR_VERSION}_X"
59+
echo "Project uses Groovy $PROJECT_GROOVY_VERSION"
60+
echo "value=$BRANCH" >> $GITHUB_OUTPUT
61+
rm -rf gradle
62+
63+
- name: Checkout Groovy Snapshot
64+
run: |
65+
BRANCH=${{ steps.groovy_branch.outputs.value }}
66+
echo "Checking out Groovy branch $BRANCH"
67+
cd .. && git clone --depth 1 https://github.com/apache/groovy.git -b $BRANCH --single-branch
68+
69+
- name: Set Groovy Snapshot version for project build
70+
id: groovy_snapshot_version
5771
run: |
5872
cd ../groovy
59-
echo "CI_GROOVY_VERSION=$(cat gradle.properties | grep groovyVersion | cut -d\= -f2 | tr -d '[:space:]')" >> $GITHUB_ENV
60-
echo "value=$(cat gradle.properties | grep groovyVersion | cut -d\= -f2 | tr -d '[:space:]')" >> $GITHUB_OUTPUT
61-
- name: Prepare GE Set-up Configuration
73+
GROOVY_SNAPSHOT_VERSION=$(cat gradle.properties | grep groovyVersion | cut -d\= -f2 | tr -d "[:space:]")
74+
echo "value=$GROOVY_SNAPSHOT_VERSION" >> $GITHUB_OUTPUT
75+
76+
- name: Prepare Gradle Enterprise Set-up Configuration
6277
id: ge_conf
6378
run: |
6479
echo "VALUE<<EOF" >> $GITHUB_OUTPUT
6580
echo "plugins { " >> $GITHUB_OUTPUT
66-
echo " id 'com.gradle.enterprise' version '3.15.1'" >> $GITHUB_OUTPUT
67-
echo " id 'com.gradle.common-custom-user-data-gradle-plugin' version '1.11.3'" >> $GITHUB_OUTPUT
68-
echo "}" >> $GITHUB_OUTPUT
69-
echo "" >> $GITHUB_OUTPUT
70-
echo "gradleEnterprise {" >> $GITHUB_OUTPUT
71-
echo " server = 'https://ge.grails.org'" >> $GITHUB_OUTPUT
72-
echo " buildScan {" >> $GITHUB_OUTPUT
73-
echo " publishAlways()" >> $GITHUB_OUTPUT
74-
echo " publishIfAuthenticated()" >> $GITHUB_OUTPUT
75-
echo " uploadInBackground = System.getenv('CI') == null" >> $GITHUB_OUTPUT
76-
echo " capture {" >> $GITHUB_OUTPUT
77-
echo " taskInputFiles = true" >> $GITHUB_OUTPUT
78-
echo " }" >> $GITHUB_OUTPUT
79-
echo " }" >> $GITHUB_OUTPUT
80-
echo "}" >> $GITHUB_OUTPUT
81+
echo " id 'com.gradle.enterprise' version '${{ steps.gradle_enterprise_version.outputs.ge_plugin_version }}'" >> $GITHUB_OUTPUT
82+
echo " id 'com.gradle.common-custom-user-data-gradle-plugin' version '${{ steps.gradle_enterprise_version.outputs.ge_user_data_plugin_version }}'" >> $GITHUB_OUTPUT
83+
echo "}" >> $GITHUB_OUTPUT
84+
echo "" >> $GITHUB_OUTPUT
85+
echo "gradleEnterprise {" >> $GITHUB_OUTPUT
86+
echo " server = 'https://ge.grails.org'" >> $GITHUB_OUTPUT
87+
echo " buildScan {" >> $GITHUB_OUTPUT
88+
echo " publishAlways()" >> $GITHUB_OUTPUT
89+
echo " publishIfAuthenticated()" >> $GITHUB_OUTPUT
90+
echo " uploadInBackground = false" >> $GITHUB_OUTPUT
91+
echo " capture {" >> $GITHUB_OUTPUT
92+
echo " taskInputFiles = true" >> $GITHUB_OUTPUT
93+
echo " }" >> $GITHUB_OUTPUT
94+
echo " }" >> $GITHUB_OUTPUT
95+
echo "}" >> $GITHUB_OUTPUT
8196
echo "" >> $GITHUB_OUTPUT
82-
echo "buildCache {" >> $GITHUB_OUTPUT
83-
echo " local { enabled = System.getenv('CI') != 'true' }" >> $GITHUB_OUTPUT
84-
echo " remote(HttpBuildCache) {" >> $GITHUB_OUTPUT
85-
echo " push = System.getenv('CI') == 'true'" >> $GITHUB_OUTPUT
86-
echo " enabled = true" >> $GITHUB_OUTPUT
87-
echo " url = 'https://ge.grails.org/cache/'" >> $GITHUB_OUTPUT
88-
echo " credentials {" >> $GITHUB_OUTPUT
89-
echo " username = System.getenv('GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER')" >> $GITHUB_OUTPUT
90-
echo " password = System.getenv('GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY')" >> $GITHUB_OUTPUT
91-
echo " }" >> $GITHUB_OUTPUT
92-
echo " }" >> $GITHUB_OUTPUT
93-
echo "}" >> $GITHUB_OUTPUT
97+
echo "buildCache {" >> $GITHUB_OUTPUT
98+
echo " local { enabled = false }" >> $GITHUB_OUTPUT
99+
echo " remote(HttpBuildCache) {" >> $GITHUB_OUTPUT
100+
echo " push = true" >> $GITHUB_OUTPUT
101+
echo " enabled = true" >> $GITHUB_OUTPUT
102+
echo " url = 'https://ge.grails.org/cache/'" >> $GITHUB_OUTPUT
103+
echo " credentials {" >> $GITHUB_OUTPUT
104+
echo " username = System.getenv('GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER')" >> $GITHUB_OUTPUT
105+
echo " password = System.getenv('GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY')" >> $GITHUB_OUTPUT
106+
echo " }" >> $GITHUB_OUTPUT
107+
echo " }" >> $GITHUB_OUTPUT
108+
echo "}" >> $GITHUB_OUTPUT
94109
echo "" >> $GITHUB_OUTPUT
95110
echo "EOF" >> $GITHUB_OUTPUT
111+
96112
- name: Gradle Enterprise Set-up
97113
run: |
98114
cd ../groovy
99115
# Delete exiting plugins and build-scan from settings.gradle file
100116
sed -i '21,31d' settings.gradle
101117
# Add Gradle Enterprise set-up related configuration after line no 20 in settings.gradle
102-
echo "${{ steps.ge_conf.outputs.value}}" | sed -i -e "20r /dev/stdin" settings.gradle
118+
echo "${{ steps.ge_conf.outputs.value }}" | sed -i -e "20r /dev/stdin" settings.gradle
119+
103120
- name: Build and install groovy (no docs)
104-
uses: gradle/gradle-build-action@v2
121+
uses: gradle/actions/setup-gradle@v3
105122
env:
106123
GRADLE_SCANS_ACCEPT: yes
107124
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
@@ -117,36 +134,39 @@ jobs:
117134
-x groovydocAll
118135
-x asciidoc
119136
-x docGDK
120-
build_grails_views:
137+
138+
build_project:
121139
needs: [build_groovy]
122-
strategy:
123-
fail-fast: true
124140
runs-on: ubuntu-latest
125141
steps:
142+
126143
- uses: actions/checkout@v4
144+
127145
- name: Set up JDK
128146
uses: actions/setup-java@v4
129147
with:
130-
distribution: 'adopt'
131-
java-version: '11'
148+
distribution: temurin
149+
java-version: 11
150+
132151
- name: Cache local Maven repository & Groovy
133152
uses: actions/cache@v4
134153
with:
135154
path: |
136155
~/groovy
137156
~/.m2/repository
138157
key: cache-local-groovy-maven-${{ github.sha }}
139-
- name: Set CI_GROOVY_VERSION for Grails
140-
run: |
141-
echo "CI_GROOVY_VERSION=${{needs.build_groovy.outputs.groovyVersion}}" >> $GITHUB_ENV
142-
- name: Build
143-
id: build
144-
uses: gradle/gradle-build-action@v2
158+
159+
- name: Build Project
160+
uses: gradle/actions/setup-gradle@v3
145161
env:
162+
GROOVY_VERSION: ${{ needs.build_groovy.outputs.groovySnapshotVersion }}
163+
CI_GROOVY_VERSION: ${{ needs.build_groovy.outputs.groovySnapshotVersion }}
164+
ORG_GRADLE_PROJECT_groovyVersion: ${{ needs.build_groovy.outputs.groovySnapshotVersion }}
146165
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
147166
GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }}
148167
GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }}
149168
with:
150169
arguments: |
151170
build
171+
-x groovydoc
152172
-Dgeb.env=chromeHeadless

0 commit comments

Comments
 (0)