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

Update to Groovy 4.0 #8010

Merged
merged 33 commits into from
Oct 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
7cd6033
Switch to Groovy 4
timyates Sep 15, 2022
f4a9205
Comment out Geb for now as it doesn't support Groovy 4
timyates Sep 15, 2022
b0a409d
Workaround bug(?) in Groovy
timyates Sep 15, 2022
a96fa0d
Accept api changes
timyates Sep 15, 2022
6db1c36
Fix VisitorContextUtilsSpec
timyates Sep 15, 2022
f175865
Workaround same bug(?) in Groovy
timyates Sep 15, 2022
d8bad79
Another Groovy change?
timyates Sep 15, 2022
e95de04
Workaround same bug(?) in Groovy
timyates Sep 15, 2022
ba924e3
I think this test was wrong...
timyates Sep 15, 2022
ed0101f
Workaround same bug(?) in Groovy
timyates Sep 15, 2022
cad3504
Workaround same bug(?) in Groovy
timyates Sep 15, 2022
74a608b
Workaround same bug(?) in Groovy
timyates Sep 15, 2022
cdc1cff
Workaround same bug(?) in Groovy
timyates Sep 15, 2022
ce46c39
Open JDK modules so Groovy running Kapt works
timyates Sep 20, 2022
80eb7b5
I think the Kapt/Spock issue is a bug in Groovy
timyates Sep 20, 2022
e3fe1e8
Merge branch '4.0.x' into groovy-4.0
timyates Sep 20, 2022
bc225b9
Open java.base/sun.security.x509 for secondary server test with Groov…
timyates Sep 20, 2022
e9c1e49
Don't open, add bouncycastle provider
timyates Sep 20, 2022
fd8d885
Fix GroovyClassElement for change in behavior for Groovy 4.0.x
timyates Sep 20, 2022
eb6655b
Remove requires now we provide bouncycastle
timyates Sep 21, 2022
3eb90e2
Fix dependency substitution for the internal build plugin
timyates Sep 21, 2022
e6d2bdc
Move Geb tests to a separate module
timyates Sep 21, 2022
6527aa0
Exclude groovy from Gorm dependency
timyates Sep 22, 2022
25998ef
Reinstate Kotlin inject test and add-opens required modules
timyates Sep 22, 2022
4193060
Only open for java 17+
timyates Sep 22, 2022
0a16e5c
Merge branch '4.0.x' into groovy-4.0
timyates Sep 22, 2022
b3d528b
Stop throwing assertion errors for Notes with Groovy 4/java 17
timyates Sep 22, 2022
dfdfd3b
Remove comments
timyates Sep 22, 2022
d1d8346
Mention Groovy 4 in breaks.adoc
timyates Sep 22, 2022
43155fd
Add Geb dependencies to catalog
timyates Sep 22, 2022
254d83c
Move Geb specifics into Geb convention plugin
timyates Sep 23, 2022
bf97d12
Switch to lower-kebab case
timyates Sep 23, 2022
540f498
Merge branch '4.0.x' into groovy-4.0
sdelamo Oct 7, 2022
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
7 changes: 7 additions & 0 deletions buildSrc/settings.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
dependencyResolutionManagement {
versionCatalogs {
create("libs") {
from(files("../gradle/libs.versions.toml"))
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,15 @@ tasks.withType(Jar).configureEach {
preserveFileTimestamps = false
}

configurations.all {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
if (details.requested.group == 'org.codehaus.groovy') {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So while this will work to build and execute this module, this won't be propagated to consumers.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that's ok... It's only stopping the micronaut-build internal plugin pulling in the codehaus dependency here

Once micronaut-build is updated, I believe we can get rid of this

details.useTarget("org.apache.groovy:${details.requested.name}:${details.requested.version}")
details.because "Plugin 'io.micronaut.build.internal.common' isn't Groovy 4 yet and it's pulling in old versions"
}
}
}

dependencies {
annotationProcessor libs.bundles.asm
annotationProcessor(libs.micronaut.docs.map {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
import io.micronaut.build.internal.ext.MicronautCoreExtension
import io.micronaut.build.internal.ext.DefaultMicronautCoreExtension

plugins {
id "io.micronaut.build.internal.base"
id "groovy"
id "java-library"
}

micronautBuild {
enableBom = false
enableProcessing = false
}

group = projectGroupId

def micronautBuild = (ExtensionAware) project.extensions.getByName("micronautBuild")
def micronautCore = micronautBuild.extensions.create(MicronautCoreExtension, "core", DefaultMicronautCoreExtension, extensions.findByType(VersionCatalogsExtension))
micronautCore.documented.convention(true)

if (System.getProperty('geb.env')) {
apply plugin:"com.energizedwork.webdriver-binaries"

webdriverBinaries {
chromedriver "${chromedriverVersion}"
geckodriver "${geckodriverVersion}"
}
}

tasks.withType(Test).configureEach {
useJUnitPlatform()
jvmArgs '-Xmx2048m'
systemProperty "micronaut.cloud.platform", "OTHER"
if (JavaVersion.current().isCompatibleWith(JavaVersion.VERSION_15)) {
jvmArgs "--enable-preview"
}
}

tasks.named("test") {
systemProperty "geb.env", System.getProperty('geb.env')
systemProperty "webdriver.chrome.driver", System.getProperty('webdriver.chrome.driver')
systemProperty "webdriver.gecko.driver", System.getProperty('webdriver.gecko.driver')
}

tasks.withType(JavaCompile).configureEach {
options.fork = true
options.compilerArgs.add("-Amicronaut.processing.group=$project.group")
options.compilerArgs.add("-Amicronaut.processing.module=micronaut-$project.name")
options.compilerArgs.add("-Amicronaut.processing.omit.confprop.injectpoints=true")
options.forkOptions.memoryMaximumSize = "2g"
}

tasks.withType(GroovyCompile).configureEach {
options.fork = true
options.compilerArgs.add("-Amicronaut.processing.group=$project.group")
options.compilerArgs.add("-Amicronaut.processing.module=micronaut-$project.name")
groovyOptions.forkOptions.memoryMaximumSize = "2g"
}

// This is for reproducible builds
tasks.withType(Jar).configureEach {
reproducibleFileOrder = true
preserveFileTimestamps = false
}

dependencies {
annotationProcessor libs.bundles.asm
annotationProcessor(libs.micronaut.docs.map {
if (micronautCore.documented.get()) {
it
} else {
null
}
}) {
transitive = false
}

api libs.managed.slf4j
compileOnly libs.caffeine
compileOnly libs.bundles.asm

testAnnotationProcessor project(":http-validation")
testAnnotationProcessor libs.bundles.asm

testImplementation libs.caffeine
testImplementation libs.bundles.asm

// Geb currently requires Groovy 3, and Spock for Groovy 3
testImplementation libs.geb.spock
testImplementation libs.spock.for.geb
testImplementation libs.geb.groovy.test
testImplementation libs.selenium.driver.htmlunit
testImplementation libs.selenium.remote.driver
testImplementation libs.selenium.api
testImplementation libs.selenium.support

testRuntimeOnly libs.htmlunit
testRuntimeOnly libs.selenium.driver.chrome
testRuntimeOnly libs.selenium.driver.firefox
}
6 changes: 5 additions & 1 deletion config/accepted-api-changes.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
[

{
"type": "io.micronaut.http.client.netty.DefaultHttpClient$HttpClientInitializer",
"member": "Constructor io.micronaut.http.client.netty.DefaultHttpClient$HttpClientInitializer(io.micronaut.http.client.netty.DefaultHttpClient,io.netty.handler.ssl.SslContext,java.lang.String,int,boolean,boolean,boolean,java.util.function.Consumer)",
"reason": "4.0.0 Release. All bets are off"
},
{
"type": "io.micronaut.ast.groovy.visitor.AbstractGroovyElement",
"member": "Class io.micronaut.ast.groovy.visitor.AbstractGroovyElement",
Expand Down
16 changes: 0 additions & 16 deletions gradle/geb.gradle

This file was deleted.

22 changes: 14 additions & 8 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ bcpkix = "1.70"
blaze = "1.6.7"
caffeine = "2.9.3"
compile-testing = "0.19"

geb = "3.4.1"
geb-groovy = "3.0.12"
geb-spock = "2.2-groovy-3.0"

hibernate = "5.5.9.Final"
hibernate-validator = "6.1.6.Final"
htmlSanityCheck = "1.1.6"
Expand Down Expand Up @@ -48,7 +52,7 @@ managed-gorm-hibernate = "7.3.0"
managed-graal-sdk = "22.0.0.2"
managed-graal = "22.2.0"
managed-graal-svm = "22.0.0.2"
managed-groovy = "3.0.13"
managed-groovy = "4.0.5"
managed-h2 = "2.1.210"
managed-hystrix = "1.5.18"
managed-jakarta-annotation-api = "2.1.1"
Expand Down Expand Up @@ -134,7 +138,7 @@ managed-reactor = "3.4.23"
managed-rxjava1 = "1.3.8"
managed-rxjava1-interop = "0.13.7"
managed-slf4j = "1.7.36"
managed-spock = "2.0-groovy-3.0"
managed-spock = "2.2-groovy-4.0"
managed-spotbugs = "4.7.1"
managed-spring = "5.3.23"
managed-springboot = "2.7.0"
Expand Down Expand Up @@ -186,7 +190,7 @@ boms-micronaut-r2dbc = { module = "io.micronaut.r2dbc:micronaut-r2dbc-bom", vers
boms-micronaut-flyway = { module = "io.micronaut.flyway:micronaut-flyway-bom", version.ref = "managed-micronaut-flyway" }
boms-micronaut-test-resources = { module = "io.micronaut.testresources:micronaut-test-resources-bom", version.ref = "managed-micronaut-test-resources" }

boms-groovy = { module = "org.codehaus.groovy:groovy-bom", version.ref = "managed-groovy" }
boms-groovy = { module = "org.apache.groovy:groovy-bom", version.ref = "managed-groovy" }
boms-jackson = { module = "com.fasterxml.jackson:jackson-bom", version.ref = "managed-jackson" }
boms-junit5 = { module = "org.junit:junit-bom", version.ref = "managed-junit5" }
boms-kotlin = { module = "org.jetbrains.kotlin:kotlin-bom", version.ref = "managed-kotlin" }
Expand Down Expand Up @@ -227,10 +231,10 @@ managed-gorm-hibernate = { module = "org.grails:grails-datastore-gorm-hibernate5
managed-graal = { module = "org.graalvm.nativeimage:svm", version.ref = "managed-graal-svm" }
managed-graal-sdk = { module = "org.graalvm.sdk:graal-sdk", version.ref = "managed-graal-sdk" }

managed-groovy = { module = "org.codehaus.groovy:groovy", version.ref = "managed-groovy" }
managed-groovy-json = { module = "org.codehaus.groovy:groovy-json", version.ref = "managed-groovy" }
managed-groovy-sql = { module = "org.codehaus.groovy:groovy-sql", version.ref = "managed-groovy" }
managed-groovy-templates = { module = "org.codehaus.groovy:groovy-templates", version.ref = "managed-groovy" }
managed-groovy = { module = "org.apache.groovy:groovy", version.ref = "managed-groovy" }
managed-groovy-json = { module = "org.apache.groovy:groovy-json", version.ref = "managed-groovy" }
managed-groovy-sql = { module = "org.apache.groovy:groovy-sql", version.ref = "managed-groovy" }
managed-groovy-templates = { module = "org.apache.groovy:groovy-templates", version.ref = "managed-groovy" }

managed-h2 = { module = "com.h2database:h2", version.ref = "managed-h2" }

Expand Down Expand Up @@ -365,8 +369,10 @@ caffeine = { module = "com.github.ben-manes.caffeine:caffeine", version.ref = "c
compile-testing = { module = "com.google.testing.compile:compile-testing", version.ref = "compile-testing" }

geb-spock = { module = "org.gebish:geb-spock", version.ref = "geb" }
spock-for-geb = { module = "org.spockframework:spock-core", version.ref = "geb-spock" }
geb-groovy-test = { module = "org.codehaus.groovy:groovy-test", version.ref = "geb-groovy" }

groovy-test-junit5 = { module = "org.codehaus.groovy:groovy-test-junit5", version.ref = "managed-groovy" }
groovy-test-junit5 = { module = "org.apache.groovy:groovy-test-junit5", version.ref = "managed-groovy" }

hibernate = { module = "org.hibernate:hibernate-core", version.ref = "hibernate" }
hibernate-validator = { module = "org.hibernate:hibernate-validator", version.ref = "hibernate-validator" }
Expand Down
9 changes: 0 additions & 9 deletions gradle/webdriverbinaries.gradle

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class SocketAddressSpec extends Specification {
ConversionService converter = ctx.getBean(ConversionService)

when:
Optional<SocketAddress> address = converter.convert("1.2.3.4:8080", SocketAddress.class)
Optional<SocketAddress> address = converter.convert("1.2.3.4:8080", SocketAddress)

then:
address.isPresent()
Expand All @@ -22,7 +22,7 @@ class SocketAddressSpec extends Specification {
((InetSocketAddress) address.get()).getPort() == 8080

when:
address = converter.convert("https://foo.bar:8081", SocketAddress.class)
address = converter.convert("https://foo.bar:8081", SocketAddress)

then:
address.isPresent()
Expand All @@ -31,7 +31,7 @@ class SocketAddressSpec extends Specification {
((InetSocketAddress) address.get()).getPort() == 8081

when:
ConversionContext conversionContext = ArgumentConversionContext.of(SocketAddress.class)
ConversionContext conversionContext = ConversionContext.of(SocketAddress)
address = converter.convert("abc:456456456456", conversionContext)

then:
Expand Down
1 change: 1 addition & 0 deletions http-server-netty/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ dependencies {
testImplementation(libs.managed.micronaut.xml) {
exclude module:'micronaut-inject'
exclude module:'micronaut-http'
exclude module:'micronaut-bom'
}
testImplementation libs.managed.jackson.databind

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ class HttpResponseSpec extends AbstractMicronautSpec {

void "test server header"() {
given:
EmbeddedServer server = ApplicationContext.run(EmbeddedServer, ['micronaut.server.serverHeader': 'Foo!', (SPEC_NAME_PROPERTY):getClass().simpleName])
EmbeddedServer server = ApplicationContext.run(EmbeddedServer, ['micronaut.server.server-header': 'Foo!', (SPEC_NAME_PROPERTY):getClass().simpleName])
def ctx = server.getApplicationContext()
HttpClient client = ctx.createBean(HttpClient, server.getURL())

Expand Down Expand Up @@ -216,7 +216,7 @@ class HttpResponseSpec extends AbstractMicronautSpec {

void "test date header turned off"() {
given:
EmbeddedServer server = ApplicationContext.run(EmbeddedServer, ['micronaut.server.dateHeader': false, (SPEC_NAME_PROPERTY):getClass().simpleName])
EmbeddedServer server = ApplicationContext.run(EmbeddedServer, ['micronaut.server.date-header': false, (SPEC_NAME_PROPERTY):getClass().simpleName])
ApplicationContext ctx = server.getApplicationContext()
HttpClient client = ctx.createBean(HttpClient, server.getURL())

Expand All @@ -234,9 +234,9 @@ class HttpResponseSpec extends AbstractMicronautSpec {

void "test keep alive connection header is not set by default for > 499 response"() {
when:
EmbeddedServer server = applicationContext.run(EmbeddedServer, [(SPEC_NAME_PROPERTY):getClass().simpleName])
EmbeddedServer server = ApplicationContext.run(EmbeddedServer, ['micronaut.server.date-header': false, (SPEC_NAME_PROPERTY):getClass().simpleName])
ApplicationContext ctx = server.getApplicationContext()
HttpClient client = applicationContext.createBean(HttpClient, embeddedServer.getURL())
HttpClient client = ctx.createBean(HttpClient, server.getURL())

Flux.from(client.exchange(
HttpRequest.GET('/test-header/fail')
Expand All @@ -256,14 +256,16 @@ class HttpResponseSpec extends AbstractMicronautSpec {
void "test connection header is defaulted to keep-alive when configured to true for > 499 response"() {
when:
DefaultHttpClientConfiguration config = new DefaultHttpClientConfiguration()

// The client will explicitly request "Connection: close" unless using a connection pool, so set it up
config.connectionPoolConfiguration.enabled = true
EmbeddedServer server = applicationContext.run(EmbeddedServer, [

EmbeddedServer server = ApplicationContext.run(EmbeddedServer, [
(SPEC_NAME_PROPERTY):getClass().simpleName,
'micronaut.server.netty.keepAliveOnServerError':true
])
def ctx = server.getApplicationContext()
HttpClient client = applicationContext.createBean(HttpClient, embeddedServer.getURL(), config)
HttpClient client = ctx.createBean(HttpClient, embeddedServer.getURL(), config)

Flux.from(client.exchange(
HttpRequest.GET('/test-header/fail')
Expand Down Expand Up @@ -301,6 +303,6 @@ class HttpResponseSpec extends AbstractMicronautSpec {

@Override
Map<String, Object> getConfiguration() {
super.getConfiguration() << ['micronaut.server.dateHeader': false]
super.getConfiguration() << ['micronaut.server.date-header': false]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,11 @@
package io.micronaut.http.server.netty.jackson

import com.fasterxml.jackson.core.JsonFactory
import com.fasterxml.jackson.core.util.BufferRecycler
import com.fasterxml.jackson.databind.ObjectMapper
import io.micronaut.context.ApplicationContext
import io.micronaut.context.DefaultApplicationContext
import io.micronaut.context.env.MapPropertySource
import io.micronaut.docs.context.annotation.primary.ColorPicker
import io.micronaut.http.HttpRequest
import io.micronaut.http.HttpResponse
import io.micronaut.http.HttpStatus
import io.micronaut.context.env.PropertySource
import spock.lang.Specification

/**
Expand All @@ -34,7 +30,6 @@ import spock.lang.Specification
class JsonFactorySetupSpec extends Specification {

void "verify default jackson setup with JsonFactory bean"() {

given:
ApplicationContext applicationContext = new DefaultApplicationContext("test").start()

Expand All @@ -49,7 +44,7 @@ class JsonFactorySetupSpec extends Specification {
void "verify JsonFactory properties are injected into the bean"() {
given:
ApplicationContext applicationContext = new DefaultApplicationContext("test")
applicationContext.environment.addPropertySource(MapPropertySource.of(
applicationContext.environment.addPropertySource((MapPropertySource) PropertySource.of(
'jackson.factory.use-thread-local-for-buffer-recycling': false
))
applicationContext.start()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package io.micronaut.http.server.netty.jackson
import io.micronaut.context.ApplicationContext
import io.micronaut.context.DefaultApplicationContext
import io.micronaut.context.env.MapPropertySource
import io.micronaut.context.env.PropertySource
import io.micronaut.jackson.JacksonConfiguration
import spock.lang.Specification

Expand All @@ -43,7 +44,7 @@ class JsonViewSetupSpec extends Specification {

given:
ApplicationContext applicationContext = new DefaultApplicationContext("test")
applicationContext.environment.addPropertySource(MapPropertySource.of(
applicationContext.environment.addPropertySource((MapPropertySource) PropertySource.of(
'jackson.json-view.enabled': true
))
applicationContext.start()
Expand Down
1 change: 1 addition & 0 deletions inject-groovy-test/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ dependencies {
exclude module:'groovy-all'
}
api project(":context")
api libs.jetbrains.annotations
sdelamo marked this conversation as resolved.
Show resolved Hide resolved
}

tasks.named("sourcesJar") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -906,7 +906,7 @@ public Optional<MethodElement> getReadMethod() {
private String getGetterName(String propertyName, ClassElement type) {
return NameUtils.getterNameFor(
propertyName,
type.equals(PrimitiveElement.BOOLEAN) || type.getName().equals(Boolean.class.getName())
type.equals(PrimitiveElement.BOOLEAN)
sdelamo marked this conversation as resolved.
Show resolved Hide resolved
);
}
};
Expand Down
Loading