Skip to content

Commit

Permalink
Patch for 5.0.x (#70)
Browse files Browse the repository at this point in the history
* fix: grails-core issue 13324

* chore: Back to snapshot (5.0.1 release failed)

* build: update faulty build config

* fix: revert removal of deprecated class

* build: extend nexus publishing transition check period

* build: update faulty build config

* build(style): Consistent use of quotes

* test: Extend timout in PubSubSpec
  • Loading branch information
matrei authored Dec 22, 2023
1 parent 48e636a commit 0ec11ca
Show file tree
Hide file tree
Showing 6 changed files with 98 additions and 26 deletions.
40 changes: 20 additions & 20 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -28,8 +28,8 @@ if(isReleaseVersion) {
}
}
transitionCheckOptions {
maxRetries = 40
delayBetween = java.time.Duration.ofSeconds 2
maxRetries = 50
delayBetween = java.time.Duration.ofSeconds(3)
}
}
}
Expand All @@ -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,
Expand All @@ -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 = '''
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
Expand All @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
4 changes: 2 additions & 2 deletions gradle/grails-plugin-config.gradle
Original file line number Diff line number Diff line change
@@ -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
}
15 changes: 13 additions & 2 deletions grails-plugin-async/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
Original file line number Diff line number Diff line change
@@ -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)
}
}

0 comments on commit 0ec11ca

Please sign in to comment.