From b2b02b749a7cb1363773b4948fab1e6b2dbceb28 Mon Sep 17 00:00:00 2001 From: David Estes Date: Thu, 25 Jul 2024 21:11:42 -0400 Subject: [PATCH] WIP, upgrading grails-async to use groovy4 and grails 7.0.0-SNAPSHOT base... examples/ project having errors because grails-views is not yet up to date --- build.gradle | 1 + buildSrc/build.gradle | 6 +++++- examples/pubsub-demo/build.gradle | 10 +++++++++- gradle.properties | 4 ++-- gradle/buildsrc.libs.versions.toml | 4 ++-- gradle/java-config.gradle | 12 +++++++++++- gradle/libs.versions.toml | 12 ++++++------ .../factory/future/FutureTaskChildPromise.groovy | 4 ++-- .../async/factory/future/FutureTaskPromise.groovy | 4 ++-- .../events/subscriber/MethodEventSubscriber.groovy | 2 +- .../events/subscriber/MethodSubscriber.groovy | 13 +++++++------ .../groovy/grails/artefact/AsyncController.groovy | 4 ++-- .../groovy/grails/async/web/AsyncController.groovy | 4 ++-- .../grails/async/web/AsyncGrailsWebRequest.groovy | 12 ++++++------ .../async/AsyncWebRequestPromiseDecorator.groovy | 6 +++--- .../plugins/web/async/GrailsAsyncContext.groovy | 8 ++++---- .../async/mvc/AsyncActionResultTransformer.groovy | 6 +++--- 17 files changed, 68 insertions(+), 44 deletions(-) diff --git a/build.gradle b/build.gradle index 7121f934..a1804d7b 100644 --- a/build.gradle +++ b/build.gradle @@ -26,6 +26,7 @@ if(isReleaseVersion) { } } + subprojects { version = rootProject.version repositories { diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle index 21d47188..dfdbccc0 100644 --- a/buildSrc/build.gradle +++ b/buildSrc/build.gradle @@ -4,6 +4,7 @@ plugins { } repositories { + mavenLocal() gradlePluginPortal() mavenCentral() maven { url = 'https://repo.grails.org/grails/core' } @@ -12,7 +13,10 @@ repositories { dependencies { // Needs to be implementation as classes are referenced in build scripts - implementation buildsrcLibs.grails.docs + implementation(buildsrcLibs.grails.docs) { + exclude group: 'org.apache.groovy', module: 'groovy' + exclude group: 'org.apache.groovy', module: 'groovy-ant' + } implementation buildsrcLibs.nexus.publish.gradle.plugin runtimeOnly buildsrcLibs.grails.gradle.plugin diff --git a/examples/pubsub-demo/build.gradle b/examples/pubsub-demo/build.gradle index 8f3b9ed1..32fe150d 100644 --- a/examples/pubsub-demo/build.gradle +++ b/examples/pubsub-demo/build.gradle @@ -6,7 +6,15 @@ plugins { } group = 'pubsub.demo' - +configurations.all { + + resolutionStrategy.dependencySubstitution { + substitute module("org.codehaus.groovy:groovy") using module('org.apache.groovy:groovy:4.0.22') + substitute module("org.codehaus.groovy:groovy-templates") using module('org.apache.groovy:groovy-templates:4.0.22') + substitute module("org.codehaus.groovy:groovy-xml") using module('org.apache.groovy:groovy-xml:4.0.22') + substitute module("org.codehaus.groovy:groovy-json") using module('org.apache.groovy:groovy-json:4.0.22') + } +} dependencies { implementation project(':grails-plugin-async') diff --git a/gradle.properties b/gradle.properties index e17683f7..409a7f6c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -projectVersion=5.1.0 +projectVersion=7.0.0-SNAPSHOT # This prevents the Grails Gradle Plugin from unnecessarily excluding slf4j-simple in the generated POMs # https://github.com/grails/grails-gradle-plugin/issues/222 @@ -9,7 +9,7 @@ authors=Graeme Rocher projectDesc=Grails Async Libraries projectUrl=https://github.com/grails/grails-async githubSlug=grails/grails-async -githubBranch=5.1.x +githubBranch=7.0.x developers=Graeme Rocher, Mattias Reichel #gpars docs is currently not available with https diff --git a/gradle/buildsrc.libs.versions.toml b/gradle/buildsrc.libs.versions.toml index 00a93edd..b00ca76d 100644 --- a/gradle/buildsrc.libs.versions.toml +++ b/gradle/buildsrc.libs.versions.toml @@ -1,6 +1,6 @@ [versions] -grails = '6.1.2' -grails-gradle-plugin = '6.1.2' +grails = '7.0.0-SNAPSHOT' +grails-gradle-plugin = '7.0.0-SNAPSHOT' grails-views = '3.2.1' groovy-doc = '1.0.1' nexus-publish-gradle-plugin = '1.3.0' diff --git a/gradle/java-config.gradle b/gradle/java-config.gradle index f5363192..7e8c621b 100644 --- a/gradle/java-config.gradle +++ b/gradle/java-config.gradle @@ -1,5 +1,15 @@ java { - sourceCompatibility = JavaVersion.VERSION_11 + sourceCompatibility = JavaVersion.VERSION_17 withSourcesJar() withJavadocJar() +} + +configurations.all { + + resolutionStrategy.dependencySubstitution { + substitute module("org.codehaus.groovy:groovy") using module('org.apache.groovy:groovy:4.0.22') + substitute module("org.codehaus.groovy:groovy-templates") using module('org.apache.groovy:groovy-templates:4.0.22') + substitute module("org.codehaus.groovy:groovy-xml") using module('org.apache.groovy:groovy-xml:4.0.22') + substitute module("org.codehaus.groovy:groovy-json") using module('org.apache.groovy:groovy-json:4.0.22') + } } \ No newline at end of file diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index c55255fd..7eefa293 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,9 +1,9 @@ [versions] bytebuddy = '1.14.12' gpars = '1.2.1' -grails = '6.1.2' -grails-gsp = '6.2.1' -groovy = '3.0.21' +grails = '7.0.0-SNAPSHOT' +grails-gsp = '7.0.0-SNAPSHOT' +groovy = '4.0.22' gorm = '8.1.2' javax-annotation = '1.3.2' objenesis = '3.3' @@ -11,8 +11,8 @@ rxjava = '1.3.8' rxjava2 = '2.2.21' sitemesh = '2.4.4' slf4j = '1.7.36' -spock = '2.3-groovy-3.0' -spring = '5.3.33' +spock = '2.3-groovy-4.0' +spring = '6.1.8' [libraries] bytebuddy = { module = 'net.bytebuddy:byte-buddy', version.ref = 'bytebuddy' } @@ -26,7 +26,7 @@ grails-web-common = { module = 'org.grails:grails-web-common', version.ref = 'gr grails-web-mvc = { module = 'org.grails:grails-web-mvc', version.ref = 'grails' } grails-web-sitemesh = { module = 'org.grails:grails-web-sitemesh', version.ref = 'grails-gsp' } gpars = { module = 'org.codehaus.gpars:gpars', version.ref = 'gpars' } -groovy-core = { module = 'org.codehaus.groovy:groovy', version.ref = 'groovy' } +groovy-core = { module = 'org.apache.groovy:groovy', version.ref = 'groovy' } javax-annotation-api = { module = 'javax.annotation:javax.annotation-api', version.ref = 'javax-annotation' } objenesis = { module = 'org.objenesis:objenesis', version.ref = 'objenesis' } rxjava = { module = 'io.reactivex:rxjava', version.ref = 'rxjava' } diff --git a/grails-async-core/src/main/groovy/org/grails/async/factory/future/FutureTaskChildPromise.groovy b/grails-async-core/src/main/groovy/org/grails/async/factory/future/FutureTaskChildPromise.groovy index 5fd1ad18..d5a2a326 100644 --- a/grails-async-core/src/main/groovy/org/grails/async/factory/future/FutureTaskChildPromise.groovy +++ b/grails-async-core/src/main/groovy/org/grails/async/factory/future/FutureTaskChildPromise.groovy @@ -58,14 +58,14 @@ class FutureTaskChildPromise implements Promise { @Override Promise onComplete(Closure callable) { - def newPromise = new FutureTaskChildPromise(promiseFactory, this, callable) + Promise newPromise = new FutureTaskChildPromise(promiseFactory, this as Promise, callable) successCallbacks.add(newPromise) return newPromise } @Override Promise onError(Closure callable) { - def newPromise = new FutureTaskChildPromise(promiseFactory, this, callable) + Promise newPromise = new FutureTaskChildPromise(promiseFactory, this as Promise, callable) failureCallbacks.add(newPromise) return newPromise } diff --git a/grails-async-core/src/main/groovy/org/grails/async/factory/future/FutureTaskPromise.groovy b/grails-async-core/src/main/groovy/org/grails/async/factory/future/FutureTaskPromise.groovy index 12b48f82..5ba6fabe 100644 --- a/grails-async-core/src/main/groovy/org/grails/async/factory/future/FutureTaskPromise.groovy +++ b/grails-async-core/src/main/groovy/org/grails/async/factory/future/FutureTaskPromise.groovy @@ -93,7 +93,7 @@ class FutureTaskPromise extends FutureTask implements Promise { } } else { - Promise newPromise = new FutureTaskChildPromise(promiseFactory, this, callable) + Promise newPromise = new FutureTaskChildPromise(promiseFactory, this as Promise, callable) successCallbacks.add(newPromise) return newPromise } @@ -112,7 +112,7 @@ class FutureTaskPromise extends FutureTask implements Promise { } } else { - def newPromise = new FutureTaskChildPromise(promiseFactory, this, callable) + Promise newPromise = new FutureTaskChildPromise(promiseFactory, this as Promise, callable) failureCallbacks.add(newPromise) return newPromise } diff --git a/grails-events-core/src/main/groovy/grails/events/subscriber/MethodEventSubscriber.groovy b/grails-events-core/src/main/groovy/grails/events/subscriber/MethodEventSubscriber.groovy index 982ba97e..b7d182cc 100644 --- a/grails-events-core/src/main/groovy/grails/events/subscriber/MethodEventSubscriber.groovy +++ b/grails-events-core/src/main/groovy/grails/events/subscriber/MethodEventSubscriber.groovy @@ -14,7 +14,7 @@ import java.lang.reflect.Method */ @AutoFinal @CompileStatic -class MethodEventSubscriber extends MethodSubscriber implements EventSubscriber { +class MethodEventSubscriber extends MethodSubscriber implements EventSubscriber { MethodEventSubscriber(Object target, Method method) { super(target, method) diff --git a/grails-events-core/src/main/groovy/grails/events/subscriber/MethodSubscriber.groovy b/grails-events-core/src/main/groovy/grails/events/subscriber/MethodSubscriber.groovy index cc44f3fd..396f0c72 100644 --- a/grails-events-core/src/main/groovy/grails/events/subscriber/MethodSubscriber.groovy +++ b/grails-events-core/src/main/groovy/grails/events/subscriber/MethodSubscriber.groovy @@ -1,5 +1,6 @@ package grails.events.subscriber +import grails.events.Event import groovy.transform.AutoFinal import groovy.transform.CompileStatic import groovy.transform.EqualsAndHashCode @@ -22,7 +23,7 @@ import java.lang.reflect.Method @CompileStatic @EqualsAndHashCode(includes = ['target', 'method']) @ToString(includes = ['method']) -class MethodSubscriber implements Subscriber { +class MethodSubscriber implements Subscriber { final Object target final Method method @@ -44,19 +45,19 @@ class MethodSubscriber implements Subscriber { } @Override - Object call(Object arg) { + R call(T arg) { switch (parameterLength) { case 0: - return ReflectionUtils.invokeMethod(method, target) + return ReflectionUtils.invokeMethod(method, target) as R case 1: Class parameterType = parameterTypes[0] if(parameterType.isInstance(arg)) { - return ReflectionUtils.invokeMethod(method, target, arg) + return ReflectionUtils.invokeMethod(method, target, arg) as R } else { def converted = conversionService.canConvert(arg.getClass(), parameterType) ? conversionService.convert(arg, parameterType) : null if(converted != null) { - return ReflectionUtils.invokeMethod(method, target, converted) + return ReflectionUtils.invokeMethod(method, target, converted) as R } else { log.debug('Could not convert Event argument [{}] to required type to invoke listener [{}]. Ignoring.', arg, method) @@ -80,7 +81,7 @@ class MethodSubscriber implements Subscriber { } i++ } - return ReflectionUtils.invokeMethod(method, target, converted) + return ReflectionUtils.invokeMethod(method, target, converted) as R } else { log.debug("Could not convert Event argument [{}] to required type to invoke listener [{}]. Ignoring.", arg, method) diff --git a/grails-plugin-async/src/main/groovy/grails/artefact/AsyncController.groovy b/grails-plugin-async/src/main/groovy/grails/artefact/AsyncController.groovy index 6f8efdfa..5a326e3d 100644 --- a/grails-plugin-async/src/main/groovy/grails/artefact/AsyncController.groovy +++ b/grails-plugin-async/src/main/groovy/grails/artefact/AsyncController.groovy @@ -23,8 +23,8 @@ import org.springframework.web.context.request.async.AsyncWebRequest import org.springframework.web.context.request.async.WebAsyncManager import org.springframework.web.context.request.async.WebAsyncUtils -import javax.servlet.AsyncContext -import javax.servlet.http.HttpServletRequest +import jakarta.servlet.AsyncContext +import jakarta.servlet.http.HttpServletRequest import org.grails.plugins.web.async.GrailsAsyncContext import org.grails.web.servlet.mvc.GrailsWebRequest diff --git a/grails-plugin-async/src/main/groovy/grails/async/web/AsyncController.groovy b/grails-plugin-async/src/main/groovy/grails/async/web/AsyncController.groovy index fc48c239..7100adb9 100644 --- a/grails-plugin-async/src/main/groovy/grails/async/web/AsyncController.groovy +++ b/grails-plugin-async/src/main/groovy/grails/async/web/AsyncController.groovy @@ -9,8 +9,8 @@ import org.springframework.web.context.request.async.AsyncWebRequest import org.springframework.web.context.request.async.WebAsyncManager import org.springframework.web.context.request.async.WebAsyncUtils -import javax.servlet.AsyncContext -import javax.servlet.http.HttpServletRequest +import jakarta.servlet.AsyncContext +import jakarta.servlet.http.HttpServletRequest /** * Exposes a startAsync() method for access to the Servlet 3.x API diff --git a/grails-plugin-async/src/main/groovy/grails/async/web/AsyncGrailsWebRequest.groovy b/grails-plugin-async/src/main/groovy/grails/async/web/AsyncGrailsWebRequest.groovy index 95343e08..1abb9f1d 100644 --- a/grails-plugin-async/src/main/groovy/grails/async/web/AsyncGrailsWebRequest.groovy +++ b/grails-plugin-async/src/main/groovy/grails/async/web/AsyncGrailsWebRequest.groovy @@ -7,12 +7,12 @@ import org.springframework.context.ApplicationContext import org.springframework.util.Assert import org.springframework.web.context.request.async.AsyncWebRequest -import javax.servlet.AsyncContext -import javax.servlet.AsyncEvent -import javax.servlet.AsyncListener -import javax.servlet.ServletContext -import javax.servlet.http.HttpServletRequest -import javax.servlet.http.HttpServletResponse +import jakarta.servlet.AsyncContext +import jakarta.servlet.AsyncEvent +import jakarta.servlet.AsyncListener +import jakarta.servlet.ServletContext +import jakarta.servlet.http.HttpServletRequest +import jakarta.servlet.http.HttpServletResponse import java.util.concurrent.atomic.AtomicBoolean import java.util.function.Consumer diff --git a/grails-plugin-async/src/main/groovy/org/grails/plugins/web/async/AsyncWebRequestPromiseDecorator.groovy b/grails-plugin-async/src/main/groovy/org/grails/plugins/web/async/AsyncWebRequestPromiseDecorator.groovy index 4dffa40d..f2cb8163 100644 --- a/grails-plugin-async/src/main/groovy/org/grails/plugins/web/async/AsyncWebRequestPromiseDecorator.groovy +++ b/grails-plugin-async/src/main/groovy/org/grails/plugins/web/async/AsyncWebRequestPromiseDecorator.groovy @@ -10,9 +10,9 @@ import org.springframework.web.context.request.RequestContextHolder import org.springframework.web.context.request.async.WebAsyncManager import org.springframework.web.context.request.async.WebAsyncUtils -import javax.servlet.AsyncContext -import javax.servlet.http.HttpServletRequest -import javax.servlet.http.HttpServletResponse +import jakarta.servlet.AsyncContext +import jakarta.servlet.http.HttpServletRequest +import jakarta.servlet.http.HttpServletResponse import java.util.concurrent.TimeoutException /** diff --git a/grails-plugin-async/src/main/groovy/org/grails/plugins/web/async/GrailsAsyncContext.groovy b/grails-plugin-async/src/main/groovy/org/grails/plugins/web/async/GrailsAsyncContext.groovy index 7577510b..132a832b 100644 --- a/grails-plugin-async/src/main/groovy/org/grails/plugins/web/async/GrailsAsyncContext.groovy +++ b/grails-plugin-async/src/main/groovy/org/grails/plugins/web/async/GrailsAsyncContext.groovy @@ -17,8 +17,8 @@ package org.grails.plugins.web.async import grails.async.web.AsyncGrailsWebRequest -import javax.servlet.AsyncContext -import javax.servlet.AsyncListener +import jakarta.servlet.AsyncContext +import jakarta.servlet.AsyncListener import grails.persistence.support.PersistenceContextInterceptor import org.grails.web.servlet.mvc.GrailsWebRequest @@ -28,8 +28,8 @@ import org.grails.web.util.WebUtils import com.opensymphony.sitemesh.webapp.SiteMeshWebAppContext -import javax.servlet.http.HttpServletRequest -import javax.servlet.http.HttpServletResponse +import jakarta.servlet.http.HttpServletRequest +import jakarta.servlet.http.HttpServletResponse /** * Wraps an AsyncContext providing additional logic to provide the appropriate context to a Grails application. diff --git a/grails-plugin-async/src/main/groovy/org/grails/plugins/web/async/mvc/AsyncActionResultTransformer.groovy b/grails-plugin-async/src/main/groovy/org/grails/plugins/web/async/mvc/AsyncActionResultTransformer.groovy index b5a9b11e..d495e123 100644 --- a/grails-plugin-async/src/main/groovy/org/grails/plugins/web/async/mvc/AsyncActionResultTransformer.groovy +++ b/grails-plugin-async/src/main/groovy/org/grails/plugins/web/async/mvc/AsyncActionResultTransformer.groovy @@ -28,9 +28,9 @@ import org.springframework.web.context.request.async.WebAsyncManager import org.springframework.web.context.request.async.WebAsyncUtils import org.springframework.web.servlet.ModelAndView -import javax.servlet.AsyncContext -import javax.servlet.http.HttpServletRequest -import javax.servlet.http.HttpServletResponse +import jakarta.servlet.AsyncContext +import jakarta.servlet.http.HttpServletRequest +import jakarta.servlet.http.HttpServletResponse /** * Handles an Async response from a controller