Skip to content

Commit

Permalink
WIP, upgrading grails-async to use groovy4 and grails 7.0.0-SNAPSHOT …
Browse files Browse the repository at this point in the history
…base... examples/ project having errors because grails-views is not yet up to date
  • Loading branch information
davydotcom committed Jul 26, 2024
1 parent 665ba86 commit b2b02b7
Show file tree
Hide file tree
Showing 17 changed files with 68 additions and 44 deletions.
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ if(isReleaseVersion) {
}
}


subprojects {
version = rootProject.version
repositories {
Expand Down
6 changes: 5 additions & 1 deletion buildSrc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ plugins {
}

repositories {
mavenLocal()
gradlePluginPortal()
mavenCentral()
maven { url = 'https://repo.grails.org/grails/core' }
Expand All @@ -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
Expand Down
10 changes: 9 additions & 1 deletion examples/pubsub-demo/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions gradle/buildsrc.libs.versions.toml
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
12 changes: 11 additions & 1 deletion gradle/java-config.gradle
Original file line number Diff line number Diff line change
@@ -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')
}
}
12 changes: 6 additions & 6 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
[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'
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' }
Expand All @@ -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' }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,14 @@ class FutureTaskChildPromise<T> implements Promise<T> {

@Override
Promise<T> onComplete(Closure<T> callable) {
def newPromise = new FutureTaskChildPromise(promiseFactory, this, callable)
Promise<T> newPromise = new FutureTaskChildPromise(promiseFactory, this as Promise<T>, callable)
successCallbacks.add(newPromise)
return newPromise
}

@Override
Promise<T> onError(Closure<T> callable) {
def newPromise = new FutureTaskChildPromise(promiseFactory, this, callable)
Promise<T> newPromise = new FutureTaskChildPromise(promiseFactory, this as Promise<T>, callable)
failureCallbacks.add(newPromise)
return newPromise
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class FutureTaskPromise<T> extends FutureTask<T> implements Promise<T> {
}
}
else {
Promise<T> newPromise = new FutureTaskChildPromise(promiseFactory, this, callable)
Promise<T> newPromise = new FutureTaskChildPromise(promiseFactory, this as Promise<T>, callable)
successCallbacks.add(newPromise)
return newPromise
}
Expand All @@ -112,7 +112,7 @@ class FutureTaskPromise<T> extends FutureTask<T> implements Promise<T> {
}
}
else {
def newPromise = new FutureTaskChildPromise(promiseFactory, this, callable)
Promise<T> newPromise = new FutureTaskChildPromise(promiseFactory, this as Promise<T>, callable)
failureCallbacks.add(newPromise)
return newPromise
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import java.lang.reflect.Method
*/
@AutoFinal
@CompileStatic
class MethodEventSubscriber extends MethodSubscriber implements EventSubscriber {
class MethodEventSubscriber<T> extends MethodSubscriber<Event,T> implements EventSubscriber<T> {

MethodEventSubscriber(Object target, Method method) {
super(target, method)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package grails.events.subscriber

import grails.events.Event
import groovy.transform.AutoFinal
import groovy.transform.CompileStatic
import groovy.transform.EqualsAndHashCode
Expand All @@ -22,7 +23,7 @@ import java.lang.reflect.Method
@CompileStatic
@EqualsAndHashCode(includes = ['target', 'method'])
@ToString(includes = ['method'])
class MethodSubscriber implements Subscriber {
class MethodSubscriber<T, R> implements Subscriber<T, R> {

final Object target
final Method method
Expand All @@ -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)
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b2b02b7

Please sign in to comment.