Skip to content

Commit

Permalink
BREAKING: update to Groovy 4.0 (#8010)
Browse files Browse the repository at this point in the history
  • Loading branch information
timyates authored Oct 7, 2022
1 parent d369461 commit ec42b98
Show file tree
Hide file tree
Showing 39 changed files with 307 additions and 187 deletions.
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') {
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
}

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)
);
}
};
Expand Down
Loading

0 comments on commit ec42b98

Please sign in to comment.