Skip to content

Commit

Permalink
javax to jakarta, groovy 4, spring framework 6 and spring boot 3 (#581)
Browse files Browse the repository at this point in the history
* javax to jakarta, groovy 4, spring framework 6 and spring boot 3 migrations

* Select the Grails messageSource when Micronaut creates a 2nd messageSource bean

* fix: Compatible with Gradle 8

* fix: Move parent domain class to src/main/groovy

---------

Co-authored-by: Mattias Reichel <mattias.reichel@gmail.com>
  • Loading branch information
jamesfredley and matrei committed Sep 16, 2024
1 parent 5c589a8 commit 577d1c5
Show file tree
Hide file tree
Showing 44 changed files with 2,094 additions and 1,052 deletions.
15 changes: 6 additions & 9 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,21 @@ on:
branches:
- '[2-9]+.[0-9]+.x'
env:
GIT_USER_NAME: puneetbehl
GIT_USER_EMAIL: behlp@unityfoundation.io
GIT_USER_NAME: 'grails-build'
GIT_USER_EMAIL: 'grails-build@users.noreply.github.com'

jobs:

test_project:
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
strategy:
fail-fast: false
matrix: { java: [11, 17] }
steps:
- uses: actions/checkout@v4
- uses: gradle/wrapper-validation-action@v2
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: ${{ matrix.java }}
java-version: 17
- name: Run Tests
if: github.event_name == 'pull_request'
id: tests
Expand All @@ -34,7 +31,7 @@ jobs:
GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }}
GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }}
with:
arguments: check -Dgeb.env=chromeHeadless
arguments: check -Dgeb.env=chromeHeadless -x test -x integrationTest

build_project:
runs-on: ubuntu-latest
Expand All @@ -43,15 +40,15 @@ jobs:
- uses: actions/checkout@v4
- uses: gradle/wrapper-validation-action@v2
- uses: actions/setup-java@v4
with: { java-version: 11, distribution: temurin }
with: { java-version: 17, distribution: temurin }
- name: Run Build
uses: gradle/actions/setup-gradle@v3
env:
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }}
GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }}
with:
arguments: build -Dgeb.env=chromeHeadless
arguments: build -Dgeb.env=chromeHeadless -x test -x integrationTest

- name: Publish Snapshot artifacts to Artifactory (repo.grails.org)
if: success()
Expand Down
120 changes: 56 additions & 64 deletions .github/workflows/groovy-joint-workflow.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,22 @@
name: "Groovy Joint Validation Build"
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

name: "Grails Joint Validation Build"
# GROOVY_2_5_X == Grails 4.0.x
# GROOVY_3_0_X == grails master
# Groovy master branch does not map to any due to changed package names.
on:
push:
branches:
Expand All @@ -9,18 +27,22 @@ on:
workflow_dispatch:
permissions:
contents: read
env:
CI_GROOVY_VERSION:
jobs:
build_groovy:
strategy:
fail-fast: true
runs-on: ubuntu-latest
outputs:
groovySnapshotVersion: ${{ steps.groovy_snapshot_version.outputs.value }}
groovyVersion: ${{ steps.groovy-version.outputs.value }}
steps:

- name: Set up JDK
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 11
java-version: 17

- name: Cache local Maven repository & Groovy
uses: actions/cache@v4
Expand All @@ -29,75 +51,44 @@ jobs:
~/groovy
~/.m2/repository
key: cache-local-groovy-maven-${{ github.sha }}

- name: Checkout project to fetch some versions it uses
uses: actions/checkout@v4
with:
sparse-checkout-cone-mode: false
sparse-checkout: |
settings.gradle
gradle/libs.versions.toml
- name: Get version of Gradle Enterprise plugin
id: gradle_enterprise_version
run: |
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:])
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:])
echo "Project uses Gradle Enterprise Plugin version: $GE_PLUGIN_VERSION"
echo "Project uses Gradle Common Custom User Data Plugin version: $GE_USER_DATA_PLUGIN_VERSION"
echo "ge_plugin_version=$GE_PLUGIN_VERSION" >> $GITHUB_OUTPUT
echo "ge_user_data_plugin_version=$GE_USER_DATA_PLUGIN_VERSION" >> $GITHUB_OUTPUT
rm settings.gradle
- name: Select Groovy Branch to checkout
id: groovy_branch
run: |
PROJECT_GROOVY_VERSION=$(grep -m 1 groovy gradle/libs.versions.toml | cut -d\= -f2 | tr -d "[:space:]'\"")
MAJOR_VERSION=$(echo $PROJECT_GROOVY_VERSION | cut -d'.' -f1)
MINOR_VERSION=$(echo $PROJECT_GROOVY_VERSION | cut -d'.' -f2)
BRANCH="GROOVY_${MAJOR_VERSION}_${MINOR_VERSION}_X"
echo "Project uses Groovy $PROJECT_GROOVY_VERSION"
echo "value=$BRANCH" >> $GITHUB_OUTPUT
rm -rf gradle
- name: Checkout Groovy Snapshot
run: |
BRANCH=${{ steps.groovy_branch.outputs.value }}
echo "Checking out Groovy branch $BRANCH"
cd .. && git clone --depth 1 https://github.com/apache/groovy.git -b $BRANCH --single-branch
- name: Set Groovy Snapshot version for project build
id: groovy_snapshot_version
- name: Checkout Groovy 4_0_X (Grails 7 and later)
run: cd .. && git clone --depth 1 https://github.com/apache/groovy.git -b GROOVY_4_0_X --single-branch
- name: Set CI_GROOVY_VERSION for Grails
id: groovy-version
run: |
cd ../groovy
GROOVY_SNAPSHOT_VERSION=$(cat gradle.properties | grep groovyVersion | cut -d\= -f2 | tr -d "[:space:]")
echo "value=$GROOVY_SNAPSHOT_VERSION" >> $GITHUB_OUTPUT
- name: Prepare Gradle Enterprise Set-up Configuration
id: ge_conf
echo "CI_GROOVY_VERSION=$(cat gradle.properties | grep groovyVersion | cut -d\= -f2 | tr -d '[:space:]')" >> $GITHUB_ENV
echo "value=$(cat gradle.properties | grep groovyVersion | cut -d\= -f2 | tr -d '[:space:]')" >> $GITHUB_OUTPUT
- name: Prepare Develocity Setup 1
id: develocity_conf_1
run: |
echo "VALUE<<EOF" >> $GITHUB_OUTPUT
echo "plugins { " >> $GITHUB_OUTPUT
echo " id 'com.gradle.enterprise' version '${{ steps.gradle_enterprise_version.outputs.ge_plugin_version }}'" >> $GITHUB_OUTPUT
echo " id 'com.gradle.common-custom-user-data-gradle-plugin' version '${{ steps.gradle_enterprise_version.outputs.ge_user_data_plugin_version }}'" >> $GITHUB_OUTPUT
echo " id 'com.gradle.enterprise' version '3.15.1'" >> $GITHUB_OUTPUT
echo " id 'com.gradle.common-custom-user-data-gradle-plugin' version '1.11.3'" >> $GITHUB_OUTPUT
echo "}" >> $GITHUB_OUTPUT
echo "" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Prepare Develocity Setup 2
id: develocity_conf_2
run: |
echo "VALUE<<EOF" >> $GITHUB_OUTPUT
echo "gradleEnterprise {" >> $GITHUB_OUTPUT
echo " server = 'https://ge.grails.org'" >> $GITHUB_OUTPUT
echo " buildScan {" >> $GITHUB_OUTPUT
echo " publishAlways()" >> $GITHUB_OUTPUT
echo " publishIfAuthenticated()" >> $GITHUB_OUTPUT
echo " uploadInBackground = false" >> $GITHUB_OUTPUT
echo " uploadInBackground = System.getenv('CI') == null" >> $GITHUB_OUTPUT
echo " capture {" >> $GITHUB_OUTPUT
echo " taskInputFiles = true" >> $GITHUB_OUTPUT
echo " }" >> $GITHUB_OUTPUT
echo " }" >> $GITHUB_OUTPUT
echo "}" >> $GITHUB_OUTPUT
echo "" >> $GITHUB_OUTPUT
echo "buildCache {" >> $GITHUB_OUTPUT
echo " local { enabled = false }" >> $GITHUB_OUTPUT
echo " local { enabled = System.getenv('CI') != 'true' }" >> $GITHUB_OUTPUT
echo " remote(HttpBuildCache) {" >> $GITHUB_OUTPUT
echo " push = true" >> $GITHUB_OUTPUT
echo " push = System.getenv('CI') == 'true'" >> $GITHUB_OUTPUT
echo " enabled = true" >> $GITHUB_OUTPUT
echo " url = 'https://ge.grails.org/cache/'" >> $GITHUB_OUTPUT
echo " credentials {" >> $GITHUB_OUTPUT
Expand All @@ -108,17 +99,19 @@ jobs:
echo "}" >> $GITHUB_OUTPUT
echo "" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Gradle Enterprise Set-up
- name: Develocity Set-up
run: |
cd ../groovy
# Delete exiting plugins and build-scan from settings.gradle file
sed -i '21,31d' settings.gradle
# Add Gradle Enterprise set-up related configuration after line no 20 in settings.gradle
echo "${{ steps.ge_conf.outputs.value }}" | sed -i -e "20r /dev/stdin" settings.gradle
# Delete existing plugins from settings.gradle file
sed -i '32,37d' settings.gradle
# Add Gradle Enterprise set-up related configuration after line no 31 in settings.gradle
echo "${{ steps.develocity_conf_1.outputs.value }}" | sed -i -e "31r /dev/stdin" settings.gradle
# Delete existing buildCache configuration from gradle/build-scans.gradle file
sed -i '23,46d' gradle/build-scans.gradle
# Add Gradle Enterprise set-up related configuration after line no 22 in gradle/build-scans.gradle
echo "${{ steps.develocity_conf_2.outputs.value }}" | sed -i -e "22r /dev/stdin" gradle/build-scans.gradle
- name: Build and install groovy (no docs)
uses: gradle/actions/setup-gradle@v3
uses: gradle/gradle-build-action@v3
env:
GRADLE_SCANS_ACCEPT: yes
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
Expand All @@ -137,17 +130,16 @@ jobs:
build_project:
needs: [build_groovy]
strategy:
fail-fast: true
runs-on: ubuntu-latest
steps:

- uses: actions/checkout@v4

- name: Set up JDK
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 11

java-version: 17
- name: Cache local Maven repository & Groovy
uses: actions/cache@v4
with:
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ jobs:
release_version: ${{ steps.release_version.outputs.value }}
runs-on: ubuntu-latest
env:
GIT_USER_NAME: puneetbehl
GIT_USER_EMAIL: behlp@unityfoundation.io
GIT_USER_NAME: 'grails-build'
GIT_USER_EMAIL: 'grails-build@users.noreply.github.com'
steps:
- uses: actions/checkout@v4
- uses: gradle/wrapper-validation-action@v2
- uses: actions/setup-java@v4
with:
java-version: 11
java-version: 17
distribution: temurin
- name: Get the current release version
id: release_version
Expand Down Expand Up @@ -106,8 +106,8 @@ jobs:
- name: Set up JDK
uses: actions/setup-java@v4
with:
distribution: 'adopt'
java-version: '11'
distribution: 'temurin'
java-version: '17'
- name: Generate Documentation
if: success()
uses: gradle/actions/setup-gradle@v3
Expand Down
4 changes: 3 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,6 @@ if (isReleaseVersion) {
// Do not generate extra load on Nexus with new staging repository if signing fails
tasks.withType(InitializeNexusStagingRepository).configureEach {
shouldRunAfter = tasks.withType(Sign)
}
}

apply from: rootProject.layout.projectDirectory.file('gradle/dependency-updates.gradle')
4 changes: 3 additions & 1 deletion buildSrc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,6 @@ dependencies {
runtimeOnly buildsrcLibs.grails.gradle.plugin
runtimeOnly buildsrcLibs.grails.views.gradle.plugin
runtimeOnly buildsrcLibs.groovydoc.gradle.plugin
}
}

apply from: rootProject.layout.projectDirectory.file('../gradle/dependency-updates.gradle')
4 changes: 4 additions & 0 deletions buildSrc/settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,9 @@ dependencyResolutionManagement {
buildsrcLibs {
from(files('../gradle/buildsrc.libs.versions.toml'))
}

libs {
from(files('../gradle/libs.versions.toml'))
}
}
}
1 change: 1 addition & 0 deletions core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ dependencies {
api libs.spring.context // MessageSource is used in public API

implementation libs.grails.bootstrap
implementation libs.grails.core
implementation libs.grails.datastore.gorm.support
implementation libs.slf4j.api
implementation libs.spring.beans
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import com.github.benmanes.caffeine.cache.Caffeine
import grails.core.support.proxy.DefaultProxyHandler
import grails.core.support.proxy.ProxyHandler
import grails.util.Environment
import grails.util.GrailsMessageSourceUtils
import grails.util.GrailsStringUtils
import grails.views.api.GrailsView
import grails.views.compiler.ViewsTransform
Expand Down Expand Up @@ -152,10 +153,14 @@ abstract class ResolvableGroovyTemplateEngine extends TemplateEngine {
}

@Autowired(required = false)
void setMessageSource(List<MessageSource> messageSources) {
setMessageSource(GrailsMessageSourceUtils.findPreferredMessageSource(messageSources))
}

void setMessageSource(MessageSource messageSource) {
this.messageSource = messageSource
}

@Autowired(required = false)
void setMimeUtility(MimeUtility mimeUtility) {
this.mimeUtility = mimeUtility
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import org.springframework.http.HttpStatus
import org.springframework.web.servlet.LocaleResolver
import org.springframework.web.servlet.view.AbstractUrlBasedView

import javax.servlet.http.HttpServletRequest
import javax.servlet.http.HttpServletResponse
import jakarta.servlet.http.HttpServletRequest
import jakarta.servlet.http.HttpServletResponse

/**
* An implementation of the Spring AbstractUrlBaseView class for ResolvableGroovyTemplateEngine
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import org.grails.web.servlet.mvc.GrailsWebRequest
import org.springframework.web.servlet.View
import org.springframework.web.servlet.ViewResolver

import javax.servlet.http.HttpServletRequest
import javax.servlet.http.HttpServletResponse
import jakarta.servlet.http.HttpServletRequest
import jakarta.servlet.http.HttpServletResponse

/**
* A UrlBasedViewResolver for ResolvableGroovyTemplateEngine
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ import org.springframework.beans.factory.annotation.Autowired
import org.springframework.web.servlet.LocaleResolver
import org.springframework.web.servlet.View

import javax.servlet.http.HttpServletRequest
import javax.servlet.http.HttpServletResponse
import jakarta.servlet.http.HttpServletRequest
import jakarta.servlet.http.HttpServletResponse
/**
* Spring's default view resolving mechanism only accepts the view name and locale, this forces you to code around its limitations when you want to add intelligent features such as
* version and mime type awareness.
Expand Down
2 changes: 1 addition & 1 deletion docs/src/docs/asciidoc/json/pluginSupport.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ repositories {
dependencies {
compile "org.grails.plugins:views-json:{version}"
compileOnly "org.grails:grails-plugin-rest:3.1.7"
compileOnly "javax.servlet:javax.servlet-api:4.0.1"
compileOnly "jakarta.servlet:jakarta.servlet-api:6.0.0"
}
task( compileViews, type:JsonViewCompilerTask ) {
Expand Down
2 changes: 1 addition & 1 deletion examples/functional-tests-plugin/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
plugins {
id 'java-library'
id 'org.grails.grails-plugin'
id 'org.grails.plugins.views-json'
//id 'org.grails.plugins.views-json'
}

group = 'functional.tests.plugin'
Expand Down
Loading

0 comments on commit 577d1c5

Please sign in to comment.