diff --git a/build.gradle b/build.gradle index dd9be6f3..930b0a3b 100644 --- a/build.gradle +++ b/build.gradle @@ -1,7 +1,7 @@ plugins { id 'groovy' id 'io.github.gradle-nexus.publish-plugin' - id "org.asciidoctor.jvm.convert" version "4.0.0-alpha.1" + id 'org.asciidoctor.jvm.convert' version '4.0.0-alpha.1' } version = projectVersion @@ -28,8 +28,8 @@ if(isReleaseVersion) { } } transitionCheckOptions { - maxRetries = 40 - delayBetween = java.time.Duration.ofSeconds 2 + maxRetries = 50 + delayBetween = java.time.Duration.ofSeconds(3) } } } @@ -47,36 +47,36 @@ dependencies { } tasks.withType(Groovydoc).configureEach { - group = "documentation" + group = 'documentation' docTitle = "${project.title} - ${project.version}" - destinationDir = project.file("build/docs/api") + destinationDir = project.file('build/docs/api') def files = [] project.rootProject.subprojects .findAll { !it.name != 'docs' && !it.name.startsWith('examples') } .each { subproject -> if(subproject.file('src/main/groovy').exists()) { - files += subproject.files("src/main/groovy") + files += subproject.files('src/main/groovy') } } if(project.file('src/main/groovy').exists()) { - files += project.files("src/main/groovy") + files += project.files('src/main/groovy') } source = files classpath = configurations.documentation } -tasks.register("publishGuide", grails.doc.gradle.PublishGuide) { - group = "documentation" +tasks.register('publishGuide', grails.doc.gradle.PublishGuide) { + group = 'documentation' description = 'Generate Guide' - dependsOn = ["groovydoc"] - mustRunAfter = ["jar"] + dependsOn = ['groovydoc'] + mustRunAfter = ['jar'] targetDir = project.file("${buildDir}/docs") sourceRepo = "https://github.com/${githubSlug}/edit/${githubBranch}/src/main/docs" - sourceDir = new File(projectDir, "src/main/docs") - propertiesFiles = [new File(rootProject.projectDir, "gradle.properties")] + sourceDir = new File(projectDir, 'src/main/docs') + propertiesFiles = [new File(rootProject.projectDir, 'gradle.properties')] asciidoc = true - resourcesDir = project.layout.projectDirectory.dir("src/main/docs/resources").asFile + resourcesDir = project.layout.projectDirectory.dir('src/main/docs/resources').asFile properties = [ 'safe' : 'UNSAFE', 'version' : project.version, @@ -94,7 +94,7 @@ tasks.register("publishGuide", grails.doc.gradle.PublishGuide) { doLast { ant.move(file: "${project.buildDir}/docs/guide/single.html", tofile: "${project.buildDir}/docs/guide/index.html", overwrite: true) - new File(project.buildDir, "docs/index.html").text = ''' + new File(project.buildDir, 'docs/index.html').text = ''' @@ -107,13 +107,13 @@ tasks.register("publishGuide", grails.doc.gradle.PublishGuide) { } } -tasks.register("docs") { - group = "documentation" - dependsOn = ["groovydoc", "publishGuide"] +tasks.register('docs') { + group = 'documentation' + dependsOn = ['groovydoc', 'publishGuide'] } -tasks.named("build").configure { - finalizedBy("docs") +tasks.named('build') { + finalizedBy('docs') } subprojects { diff --git a/examples/pubsub-demo/src/integration-test/groovy/pubsub/demo/PubSubSpec.groovy b/examples/pubsub-demo/src/integration-test/groovy/pubsub/demo/PubSubSpec.groovy index a2d111ee..5dd8700c 100644 --- a/examples/pubsub-demo/src/integration-test/groovy/pubsub/demo/PubSubSpec.groovy +++ b/examples/pubsub-demo/src/integration-test/groovy/pubsub/demo/PubSubSpec.groovy @@ -24,7 +24,7 @@ class PubSubSpec extends Specification { sumService.sum(1, 2) then: 'the subscriber should receive the events' - new PollingConditions(timeout: 2).eventually { + new PollingConditions(timeout: 5).eventually { totalService.accumulatedTotal == 6 } } diff --git a/gradle.properties b/gradle.properties index 5f308696..d15e6f6a 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -projectVersion=5.0.1 +projectVersion=5.0.1-SNAPSHOT # These versions have to be defined here for usage in settings.gradle # (versions in settings.gradle cannot be set from the version catalog) diff --git a/gradle/grails-plugin-config.gradle b/gradle/grails-plugin-config.gradle index 2efa468a..a70791aa 100644 --- a/gradle/grails-plugin-config.gradle +++ b/gradle/grails-plugin-config.gradle @@ -1,9 +1,9 @@ group = 'org.grails.plugins' -tasks.named('bootJar').configure { +tasks.named('bootJar') { enabled = false // Grails plugins shouldn't produce a boot jar } -tasks.named('jar').configure { +tasks.named('jar') { enabled = true archiveClassifier = '' // Skip the '-plain' suffix on the jar file name } diff --git a/grails-plugin-async/build.gradle b/grails-plugin-async/build.gradle index 61223553..883f180c 100644 --- a/grails-plugin-async/build.gradle +++ b/grails-plugin-async/build.gradle @@ -14,8 +14,19 @@ plugins { dependencies { api project(':grails-async-core') - api project(':grails-events-compat') - api project(':grails-events-core') + + // This project does not really depend on the events plugin + // but rather on the events-core and events-compat modules. + // This is a workaround because without this, plugins created with + // pre-Grails 3.3 will not get the events plugin automatically + // on the classpath and will get an error. + // (The async plugin is automatically added to the classpath by + // grails-core/grails-dependencies and now also the events plugin + // should be pulled in) + // https://github.com/grails/grails-core/issues/13324 + api project(':grails-plugin-events') + //api project(':grails-events-compat') + //api project(':grails-events-core') implementation 'org.grails:grails-core' implementation 'org.grails:grails-plugin-controllers' diff --git a/grails-plugin-async/src/main/groovy/grails/artefact/AsyncController.groovy b/grails-plugin-async/src/main/groovy/grails/artefact/AsyncController.groovy new file mode 100644 index 00000000..6f8efdfa --- /dev/null +++ b/grails-plugin-async/src/main/groovy/grails/artefact/AsyncController.groovy @@ -0,0 +1,61 @@ +/* + * Copyright 2014 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. + * You may obtain a copy of the License at + * + * http://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. + */ +package grails.artefact + +import grails.async.web.AsyncGrailsWebRequest +import grails.events.Events +import org.grails.web.util.GrailsApplicationAttributes +import groovy.transform.CompileStatic +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 org.grails.plugins.web.async.GrailsAsyncContext +import org.grails.web.servlet.mvc.GrailsWebRequest +import org.springframework.web.context.request.RequestContextHolder + +/** + * + * @author Jeff Brown + * @since 3.0 + * @deprecated Use {@link grails.async.web.AsyncController} instead + */ +@CompileStatic +@Deprecated +trait AsyncController extends Events { + + /** + * Raw access to the Servlet 3.0 startAsync method + * + * @return a new {@link javax.servlet.AsyncContext} + */ + AsyncContext startAsync() { + GrailsWebRequest webRequest = (GrailsWebRequest)RequestContextHolder.currentRequestAttributes() + + HttpServletRequest request = webRequest.currentRequest + WebAsyncManager asyncManager = WebAsyncUtils.getAsyncManager(request) + + AsyncWebRequest asyncWebRequest = new AsyncGrailsWebRequest(request, webRequest.currentResponse, webRequest.servletContext) + asyncManager.setAsyncWebRequest(asyncWebRequest) + + asyncWebRequest.startAsync() + request.setAttribute(GrailsApplicationAttributes.ASYNC_STARTED, true) + new GrailsAsyncContext(asyncWebRequest.asyncContext, webRequest) + } +}