Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: Update to Groovy 4 #13532

Merged
merged 10 commits into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 22 additions & 14 deletions .github/workflows/groovy-joint-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,33 +40,37 @@ jobs:
- name: Set up JDK
uses: actions/setup-java@v4
with:
distribution: 'adopt'
java-version: '11.0.6'
distribution: temurin
java-version: 17
- name: Cache local Maven repository & Groovy
uses: actions/cache@v4
with:
path: |
~/groovy
~/.m2/repository
key: cache-local-groovy-maven-${{ github.sha }}
- name: Checkout Groovy 3_0_X (Grails 5 and later)
if: startsWith(github.ref, 'refs/heads/7.') || startsWith(github.base_ref, '7.') || startsWith(github.ref, 'refs/heads/6.') || startsWith(github.base_ref, '6.') || startsWith(github.ref, 'refs/heads/5.') || startsWith(github.base_ref, '5.')
run: cd .. && git clone --depth 1 https://github.com/apache/groovy.git -b GROOVY_3_0_X --single-branch
- 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
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 GE Set-up Configuration
id: ge_conf
- 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 '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
Expand All @@ -93,13 +97,17 @@ 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/gradle-build-action@v3
env:
Expand Down Expand Up @@ -127,8 +135,8 @@ jobs:
- name: Set up JDK
uses: actions/setup-java@v4
with:
distribution: 'adopt'
java-version: '17'
distribution: temurin
java-version: 17
- name: Cache local Maven repository & Groovy
uses: actions/cache@v4
with:
Expand Down
42 changes: 26 additions & 16 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ ext {
modules: ['']
],
'groovy' : [version: groovyVersion,
group : 'org.codehaus.groovy',
group : 'org.apache.groovy',
names : ['groovy'],
modules: ['', 'xml', 'swing', 'console', 'json', 'ant', 'sql', 'templates', 'nio', 'dateutil', 'macro']
],
Expand Down Expand Up @@ -189,9 +189,9 @@ if (jointBuildGroovyJarProperty) {
throw new GradleException("The groovy.jar system property points to ${jointBuildGroovyJar.absolutePath} which does not exist.")
}
} else {
groovyDependency = dependencies.create("org.codehaus.groovy:groovy:${groovyVersion}") {
exclude module: "commons-cli"
exclude module: "ant"
groovyDependency = dependencies.create("org.apache.groovy:groovy:${groovyVersion}") {
exclude module:"commons-cli"
exclude module:"ant"
}
}

Expand Down Expand Up @@ -220,15 +220,25 @@ if (isReleaseVersion) {
}

allprojects {

// FORCE UPGRADE OF GROOVY IN DEPENDENCIES TO GROOVY 4
configurations.configureEach {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
if (details.requested.group == 'org.codehaus.groovy' && details.requested.name != 'groovy-bom') {
details.useTarget(group: 'org.apache.groovy', name: details.requested.name, version: groovyVersion)
}
}
}

repositories {
mavenLocal()
mavenCentral()
maven { url "https://repo.grails.org/grails/core" }
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
if (groovyVersion.endsWith('-SNAPSHOT')) {
maven { url = 'https://repo.grails.org/grails/core' }
maven { url = 'https://oss.sonatype.org/content/repositories/snapshots' }
if(groovyVersion.endsWith('-SNAPSHOT')) {
maven {
name 'JFrog OSS snapshot repo'
url 'https://oss.jfrog.org/oss-snapshot-local/'
name = 'ASF Snapshot repo'
url = 'https://repository.apache.org/content/repositories/snapshots'
}
}
}
Expand All @@ -241,7 +251,7 @@ allprojects {
cacheChangingModulesFor cacheHours, 'hours'
eachDependency { DependencyResolveDetails details ->
//specifying a fixed version for all libraries with 'org.gradle' group
if (details.requested.group == 'org.codehaus.groovy') {
if (details.requested.group == 'org.apache.groovy') {
details.useVersion(groovyVersion)
}
if (details.requested.group == "org.spockframework") {
Expand Down Expand Up @@ -472,15 +482,15 @@ subprojects { project ->
}

dependencies {
documentation "org.fusesource.jansi:jansi:$jansiVersion"
documentation "jline:jline:$jlineVersion"
documentation "org.codehaus.groovy:groovy-ant:$groovyVersion"
documentation "org.codehaus.groovy:groovy-cli-picocli:$groovyVersion"
documentation "com.github.javaparser:javaparser-core:$javaParserCoreVersion"
documentation("org.fusesource.jansi:jansi:$jansiVersion")
documentation("jline:jline:$jlineVersion")
documentation "org.apache.groovy:groovy-ant:$groovyVersion"
documentation "org.apache.groovy:groovy-cli-picocli:$groovyVersion"
documentation ("com.github.javaparser:javaparser-core:$javaParserCoreVersion")

api groovyDependency

testImplementation "org.codehaus.groovy:groovy-test-junit5:${groovyVersion}"
testImplementation "org.apache.groovy:groovy-test-junit5:${groovyVersion}"
testImplementation "org.junit.jupiter:junit-jupiter-api:5.10.2"
testImplementation "org.junit.platform:junit-platform-runner:1.10.2"
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:5.10.2"
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ feildsPluginVersion=5.0.2
gdocEngineVersion=1.0.1
gradleNexusPluginVersion=2.3.1
gradleNexusStagingPluginVersion=0.12.0
groovyVersion=3.0.21
groovyVersion=4.0.22
gspVersion=6.2.1
h2.version=2.2.224
h2Version=2.2.224
Expand All @@ -38,7 +38,7 @@ scaffoldingCoreVersion=2.1.0
servletApiVersion=4.0.1
slf4jVersion=1.7.36
snakeyamlVersion=2.2
spockVersion=2.1-groovy-3.0
spockVersion=2.3-groovy-4.0
springBootVersion=2.7.18
springLoadedVersion=1.2.8.RELEASE
springVersion=5.3.33
Expand Down
2 changes: 1 addition & 1 deletion gradle/docs.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ configurations {
}

dependencies {
documentation "org.codehaus.groovy:groovy-groovydoc:$groovyVersion"
documentation "org.apache.groovy:groovy-groovydoc:$groovyVersion"
}

ext.grailsDocSrc = project.findProperty('grails-doc.home') ?: project.buildDir.absolutePath + "/checkout/grails-docs-src"
Expand Down
2 changes: 1 addition & 1 deletion grails-bom/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ publishing {
mkp.artifactId 'jna'
}
mkp.exclusion {
mkp.groupId 'org.codehaus.groovy'
mkp.groupId 'org.apache.groovy'
mkp.artifactId 'groovy-ant'
}
}
Expand Down
6 changes: 3 additions & 3 deletions grails-bootstrap/build.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import org.apache.tools.ant.filters.ReplaceTokens

dependencies {
api ( "org.codehaus.groovy:groovy-xml:$groovyVersion" )
api ( "org.codehaus.groovy:groovy-templates:$groovyVersion" )
api ( "org.apache.groovy:groovy-xml:$groovyVersion" )
api ( "org.apache.groovy:groovy-templates:$groovyVersion" )
api "org.yaml:snakeyaml"
api "io.micronaut:micronaut-inject:$micronautVersion"

Expand All @@ -12,7 +12,7 @@ dependencies {
compileOnly("net.java.dev.jna:jna:$jnaVersion")

// Ant
compileOnly "org.codehaus.groovy:groovy-ant:$groovyVersion"
compileOnly "org.apache.groovy:groovy-ant:$groovyVersion"

testImplementation("org.fusesource.jansi:jansi:$jansiVersion")
testImplementation("jline:jline:$jlineVersion")
Expand Down
32 changes: 18 additions & 14 deletions grails-bootstrap/src/main/groovy/grails/util/Environment.groovy
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2004-2005 the original author or authors.
* Copyright 2004-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -57,6 +57,10 @@ enum Environment {
/** A custom environment */
CUSTOM

/**
* Initialize the Logger lazily because:
* https://github.com/grails/grails-core/issues/11476
*/
private static final Supplier<Logger> LOG = SupplierUtil.memoized(() -> LoggerFactory.getLogger(Environment.class))

/**
Expand Down Expand Up @@ -120,9 +124,9 @@ enum Environment {

@SuppressWarnings("unchecked")
private static Map<String, String> envNameMappings = CollectionUtils.<String, String> newMap(
DEVELOPMENT_ENVIRONMENT_SHORT_NAME, Environment.DEVELOPMENT.getName(),
PRODUCTION_ENV_SHORT_NAME, Environment.PRODUCTION.getName(),
TEST_ENVIRONMENT_SHORT_NAME, Environment.TEST.getName())
DEVELOPMENT_ENVIRONMENT_SHORT_NAME, DEVELOPMENT.getName(),
PRODUCTION_ENV_SHORT_NAME, PRODUCTION.getName(),
TEST_ENVIRONMENT_SHORT_NAME, TEST.getName())
private static Holder<Environment> cachedCurrentEnvironment = new Holder<>("Environment")
private static final boolean DEVELOPMENT_MODE = getCurrent() == DEVELOPMENT && BuildSettings.GRAILS_APP_DIR_PRESENT
private static Boolean RELOADING_AGENT_ENABLED = null
Expand Down Expand Up @@ -295,14 +299,14 @@ enum Environment {
Environment env = getEnvironment(envName)
if (env == null) {
try {
env = Environment.valueOf(envName.toUpperCase())
env = valueOf(envName.toUpperCase())
}
catch (IllegalArgumentException e) {
// ignore
}
}
if (env == null) {
env = Environment.CUSTOM
env = CUSTOM
env.setName(envName)
}
return env
Expand Down Expand Up @@ -355,7 +359,7 @@ enum Environment {
* @return True if the development sources are present
*/
static boolean isDevelopmentRun() {
Environment env = Environment.getCurrent()
Environment env = getCurrent()
return isDevelopmentEnvironmentAvailable() && Boolean.getBoolean(RUN_ACTIVE) && (env == Environment.DEVELOPMENT)
}

Expand All @@ -368,7 +372,7 @@ enum Environment {
LOG.get().debug("Looking for pid file at: {}", pidFile)
boolean isDevToolsRestart = false
try {
if (Environment.isDevelopmentMode()) {
if (isDevelopmentMode()) {
String pid = ManagementFactory.getRuntimeMXBean().getName()
if (pidFile.exists()) {
if (pid.equals(Files.readAllLines(pidFile.toPath()).get(0))) {
Expand Down Expand Up @@ -479,10 +483,10 @@ enum Environment {
static Environment getEnvironment(String shortName) {
final String envName = envNameMappings.get(shortName)
if (envName != null) {
return Environment.valueOf(envName.toUpperCase())
return valueOf(envName.toUpperCase())
} else {
try {
return Environment.valueOf(shortName.toUpperCase())
return valueOf(shortName.toUpperCase())
} catch (IllegalArgumentException ise) {
return null
}
Expand Down Expand Up @@ -646,7 +650,7 @@ enum Environment {
}
try {
Class.forName("org.springframework.boot.devtools.RemoteSpringApplication")
RELOADING_AGENT_ENABLED = Environment.getCurrent().isReloadEnabled()
RELOADING_AGENT_ENABLED = getCurrent().isReloadEnabled()
LOG.get().debug("Found spring-dev-tools on the class path")
}
catch (ClassNotFoundException e) {
Expand All @@ -655,7 +659,7 @@ enum Environment {
Class.forName("org.springsource.loaded.TypeRegistry")
String jvmVersion = System.getProperty("java.specification.version")
LOG.get().debug("Found spring-loaded on the class path")
RELOADING_AGENT_ENABLED = Environment.getCurrent().isReloadEnabled()
RELOADING_AGENT_ENABLED = getCurrent().isReloadEnabled()
}
catch (ClassNotFoundException e1) {
RELOADING_AGENT_ENABLED = false
Expand Down Expand Up @@ -712,8 +716,8 @@ enum Environment {
}

private static String getEnvironmentInternal() {
String envName = System.getProperty(Environment.KEY)
return isBlank(envName) ? System.getenv(Environment.ENV_KEY) : envName
String envName = System.getProperty(KEY)
return isBlank(envName) ? System.getenv(ENV_KEY) : envName
}

}
4 changes: 2 additions & 2 deletions grails-bootstrap/src/main/groovy/grails/util/Metadata.groovy
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2004-2005 the original author or authors.
* Copyright 2004-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -360,7 +360,7 @@ class Metadata extends PropertySourcePropertyResolver {
return ((PropertyResolver) this).getProperty(key.toString(), Object).orElse(defaultValue)
}

static class FinalReference<T> extends SoftReference<T> {
final static class FinalReference<T> extends SoftReference<T> {
private final T ref

FinalReference(T t) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2008 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -15,7 +15,7 @@
*/
package org.grails.io.support;

import groovy.util.XmlSlurper;
import groovy.xml.XmlSlurper;
import groovy.xml.FactorySupport;
import org.xml.sax.SAXException;
import javax.xml.XMLConstants;
Expand Down
4 changes: 2 additions & 2 deletions grails-bootstrap/src/test/groovy/grails/io/IOUtilsSpec.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ class IOUtilsSpec extends Specification{
IOUtils.findClassResource(BuildSettings).path.contains('grails-bootstrap')
}

void "Test findJarResource finds a the JAR resource"() {
void "Test findJarResource finds a JAR resource"() {
expect:
IOUtils.findJarResource(Specification)
IOUtils.findJarResource(Specification).path.endsWith('spock-core-2.1-groovy-3.0.jar!/')
IOUtils.findJarResource(Specification).path.endsWith('spock-core-2.3-groovy-4.0.jar!/')
}
}
6 changes: 3 additions & 3 deletions grails-console/build.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
dependencies {
api project(":grails-core")
api "org.codehaus.groovy:groovy-console:$groovyVersion"
api "org.codehaus.groovy:groovy-swing:$groovyVersion"
api "org.codehaus.groovy:groovy-groovysh:$groovyVersion"
api "org.apache.groovy:groovy-console:$groovyVersion"
api "org.apache.groovy:groovy-swing:$groovyVersion"
api "org.apache.groovy:groovy-groovysh:$groovyVersion"
implementation "org.fusesource.jansi:jansi:$jansiVersion",
"jline:jline:$jlineVersion",
"net.java.dev.jna:jna:$jnaVersion"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2014 original authors
* Copyright 2014-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -17,7 +17,7 @@ package grails.ui.shell.support

import grails.core.GrailsApplication
import grails.ui.support.DevelopmentWebApplicationContext
import org.codehaus.groovy.tools.shell.Groovysh
import org.apache.groovy.groovysh.Groovysh
import org.codehaus.groovy.tools.shell.IO
import org.springframework.context.support.GenericApplicationContext

Expand Down
Loading
Loading