From 93f83fef7babe6570a191b840d78d4e8b1296dd4 Mon Sep 17 00:00:00 2001 From: musketyr Date: Wed, 25 Oct 2023 16:01:12 +0200 Subject: [PATCH] upgaded to Grails 5.x --- .github/workflows/gradle.yml | 9 +-------- .github/workflows/release.yml | 19 ++++--------------- build.gradle | 6 ------ .../grails/example/TestController.groovy | 4 ++-- .../grails/example/DirectlyInjected.groovy | 2 +- .../grails/example/InjectedUsingBridge.groovy | 2 +- ...njectedUsingBridgeWithDifferentName.groovy | 2 +- .../example/InjectedWithQualifier.groovy | 4 ++-- .../Vehicle.groovy.txt | 2 +- gradle.properties | 10 +++++----- .../generator/MicronautDataGenerator.groovy | 2 +- .../MicronuatDataGeneratorConfiguration.java | 2 +- .../DefaultGrailsMicronautBeanProcessor.java | 4 ++-- .../grails/GrailsMicronautBeanProcessor.java | 4 ++-- .../GrailsPropertyTranslatingEnvironment.java | 6 +++--- .../grails/MicronautContextHolder.java | 6 +++--- .../micronaut/grails/MicronautGrailsApp.java | 14 ++++++++------ .../micronaut/grails/TypeAndQualifier.java | 2 +- .../GrailsMicronautBeanProcessorSpec.groovy | 6 +++--- 19 files changed, 42 insertions(+), 64 deletions(-) diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index d9097593..febeedf9 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -9,13 +9,6 @@ jobs: GRADLE_OPTS: "-Xmx6g -Xms4g" CI: true COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }} - strategy: - fail-fast: false - matrix: - versions: - - 'check coveralls -PmicronautVersion=1.3.7 -PspockVersion=2.0-groovy-2.5 -PgroovyVersion=2.5.15 -PgrailsVersion=4.0.4 -Pgorm.version=7.0.6.RELEASE' - - 'check -x :micronaut-grails-domain-library:check -x :micronaut-grails-example:check -PmicronautVersion=2.5.13 -PspockVersion=2.0-groovy-3.0 -PgroovyVersion=3.0.9 -PgrailsVersion=5.1.1 -Pgorm.version=7.1.2' - - 'migrateImports check -PmicronautVersion=3.2.1 -PspockVersion=2.0-groovy-3.0 -PgroovyVersion=3.0.9 -PgrailsVersion=5.1.1 -Pgorm.version=7.1.2' steps: - uses: actions/checkout@v2 - uses: actions/setup-java@v2 @@ -25,7 +18,7 @@ jobs: cache: 'gradle' - uses: eskatos/gradle-command-action@v2 with: - arguments: ${{ matrix.versions }} + arguments: check coveralls - name: Show Reports uses: actions/upload-artifact@v2 if: failure() diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 12736894..6c9ed578 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -30,24 +30,12 @@ jobs: with: fileName: 'secret.pgp' encodedString: ${{ secrets.SIGNING_SECRET_KEY_BASE64 }} - - name: Release Micronaut 1.x - env: - SIGNING_SECRET_KEY_PATH: ${{ steps.write_file.outputs.filePath }} - uses: eskatos/gradle-command-action@v2 - with: - arguments: -x groovydoc publishToSonatype closeAndReleaseSonatypeStagingRepository -Pversion=${{ steps.version.outputs.tag }}-micronaut-1.0 --stacktrace -PmicronautVersion=1.3.7 -PspockVersion=2.0-groovy-2.5 -PgroovyVersion=2.5.15 -PgrailsVersion=4.0.4 -Pgorm.version=7.0.6.RELEASE -Prelease=true - - name: Release Micronaut 2.x - env: - SIGNING_SECRET_KEY_PATH: ${{ steps.write_file.outputs.filePath }} - uses: eskatos/gradle-command-action@v2 - with: - arguments: -x groovydoc publishToSonatype closeAndReleaseSonatypeStagingRepository -Pversion=${{ steps.version.outputs.tag }}-micronaut-2.0 --stacktrace -PmicronautVersion=2.5.13 -PspockVersion=2.0-groovy-3.0 -PgroovyVersion=3.0.9 -PgrailsVersion=5.1.1 -Pgorm.version=7.1.2 -Prelease=true - name: Release Micronaut 3.x env: SIGNING_SECRET_KEY_PATH: ${{ steps.write_file.outputs.filePath }} uses: eskatos/gradle-command-action@v2 with: - arguments: migrateImports gitPublishPush -x groovydoc publishToSonatype closeAndReleaseSonatypeStagingRepository -Pversion=${{ steps.version.outputs.tag }}-micronaut-3.0 --stacktrace -PmicronautVersion=3.2.3 -PspockVersion=2.0-groovy-3.0 -PgroovyVersion=3.0.9 -PgrailsVersion=5.1.1 -Pgorm.version=7.1.2 -Prelease=true -Dorg.ajoberstar.grgit.auth.username=${{ secrets.AGORAPULSE_BOT_PERSONAL_TOKEN }} + arguments: migrateImports gitPublishPush -x groovydoc publishToSonatype closeAndReleaseSonatypeStagingRepository -Pversion=${{ steps.version.outputs.tag }} -Prelease=true -Dorg.ajoberstar.grgit.auth.username=${{ secrets.AGORAPULSE_BOT_PERSONAL_TOKEN }} ping: name: Notify Upstream Repositories runs-on: ubuntu-latest @@ -55,7 +43,8 @@ jobs: strategy: matrix: repository: - - agorapulse/agorapulse-bom + # no need for automatic update of the all BOM as this would break old Grails application if the upgrade fails + # - agorapulse/agorapulse-bom - agorapulse/agorapulse-oss steps: - uses: actions/checkout@v1 @@ -68,4 +57,4 @@ jobs: token: ${{ secrets.AGORAPULSE_BOT_PERSONAL_TOKEN }} repository: ${{ matrix.repository }} event-type: ap-new-version-released-event - client-payload: '{ "group": "com.agorapulse", "module": "micronaut-grails", "version": "${{ steps.version.outputs.tag }}-micronaut-1.0", "property" : "micronaut.grails.version", "github" : ${{ toJson(github) }} }' + client-payload: '{ "group": "com.agorapulse", "module": "micronaut-grails", "version": "${{ steps.version.outputs.tag }}", "property" : "micronaut.grails.version", "github" : ${{ toJson(github) }} }' diff --git a/build.gradle b/build.gradle index 717571de..964618a7 100644 --- a/build.gradle +++ b/build.gradle @@ -195,10 +195,4 @@ subprojects { Project subproject -> codenarc { toolVersion = '2.1.0' } - - config { - bintray { - name = subproject.name - } - } } diff --git a/examples/micronaut-grails-example/grails-app/controllers/micronaut/grails/example/TestController.groovy b/examples/micronaut-grails-example/grails-app/controllers/micronaut/grails/example/TestController.groovy index ccf180f4..3c37a04c 100644 --- a/examples/micronaut-grails-example/grails-app/controllers/micronaut/grails/example/TestController.groovy +++ b/examples/micronaut-grails-example/grails-app/controllers/micronaut/grails/example/TestController.groovy @@ -25,8 +25,8 @@ import com.agorapulse.micronaut.grails.example.InjectedWithQualifier import grails.compiler.GrailsCompileStatic import grails.converters.JSON -import javax.inject.Inject -import javax.inject.Named +import jakarta.inject.Inject +import jakarta.inject.Named @GrailsCompileStatic class TestController { diff --git a/examples/micronaut-grails-example/grails-app/utils/com/agorapulse/micronaut/grails/example/DirectlyInjected.groovy b/examples/micronaut-grails-example/grails-app/utils/com/agorapulse/micronaut/grails/example/DirectlyInjected.groovy index e727aae3..850f118f 100644 --- a/examples/micronaut-grails-example/grails-app/utils/com/agorapulse/micronaut/grails/example/DirectlyInjected.groovy +++ b/examples/micronaut-grails-example/grails-app/utils/com/agorapulse/micronaut/grails/example/DirectlyInjected.groovy @@ -23,7 +23,7 @@ import groovy.transform.CompileStatic import io.micronaut.context.ApplicationContext import io.micronaut.context.annotation.Value -import javax.inject.Singleton +import jakarta.inject.Singleton @Singleton @CompileStatic diff --git a/examples/micronaut-grails-example/grails-app/utils/com/agorapulse/micronaut/grails/example/InjectedUsingBridge.groovy b/examples/micronaut-grails-example/grails-app/utils/com/agorapulse/micronaut/grails/example/InjectedUsingBridge.groovy index 83d58344..e86eb2f5 100644 --- a/examples/micronaut-grails-example/grails-app/utils/com/agorapulse/micronaut/grails/example/InjectedUsingBridge.groovy +++ b/examples/micronaut-grails-example/grails-app/utils/com/agorapulse/micronaut/grails/example/InjectedUsingBridge.groovy @@ -22,7 +22,7 @@ import groovy.transform.CompileStatic import io.micronaut.context.ApplicationContext import io.micronaut.context.annotation.Value -import javax.inject.Singleton +import jakarta.inject.Singleton @Singleton @CompileStatic diff --git a/examples/micronaut-grails-example/grails-app/utils/com/agorapulse/micronaut/grails/example/InjectedUsingBridgeWithDifferentName.groovy b/examples/micronaut-grails-example/grails-app/utils/com/agorapulse/micronaut/grails/example/InjectedUsingBridgeWithDifferentName.groovy index bd84f5f2..d36a7a67 100644 --- a/examples/micronaut-grails-example/grails-app/utils/com/agorapulse/micronaut/grails/example/InjectedUsingBridgeWithDifferentName.groovy +++ b/examples/micronaut-grails-example/grails-app/utils/com/agorapulse/micronaut/grails/example/InjectedUsingBridgeWithDifferentName.groovy @@ -19,7 +19,7 @@ package com.agorapulse.micronaut.grails.example import groovy.transform.CompileStatic -import javax.inject.Singleton +import jakarta.inject.Singleton @Singleton @CompileStatic diff --git a/examples/micronaut-grails-example/grails-app/utils/com/agorapulse/micronaut/grails/example/InjectedWithQualifier.groovy b/examples/micronaut-grails-example/grails-app/utils/com/agorapulse/micronaut/grails/example/InjectedWithQualifier.groovy index f4b47621..0eb46c51 100644 --- a/examples/micronaut-grails-example/grails-app/utils/com/agorapulse/micronaut/grails/example/InjectedWithQualifier.groovy +++ b/examples/micronaut-grails-example/grails-app/utils/com/agorapulse/micronaut/grails/example/InjectedWithQualifier.groovy @@ -19,8 +19,8 @@ package com.agorapulse.micronaut.grails.example import groovy.transform.CompileStatic -import javax.inject.Named -import javax.inject.Singleton +import jakarta.inject.Named +import jakarta.inject.Singleton @Singleton @Named('test') diff --git a/examples/micronaut-grails-example/src/test/resources/micronaut/grails/example/MicronautJdbcGeneratorSpec/Vehicle.groovy.txt b/examples/micronaut-grails-example/src/test/resources/micronaut/grails/example/MicronautJdbcGeneratorSpec/Vehicle.groovy.txt index 565723c4..882424ce 100644 --- a/examples/micronaut-grails-example/src/test/resources/micronaut/grails/example/MicronautJdbcGeneratorSpec/Vehicle.groovy.txt +++ b/examples/micronaut-grails-example/src/test/resources/micronaut/grails/example/MicronautJdbcGeneratorSpec/Vehicle.groovy.txt @@ -1,7 +1,7 @@ package micronaut.grails.example.other.model import groovy.transform.CompileStatic -import javax.annotation.Nullable +import io.micronaut.core.annotation.Nullable import javax.persistence.Entity import javax.persistence.GeneratedValue import javax.persistence.GenerationType diff --git a/gradle.properties b/gradle.properties index 83e2ac0e..b665e330 100644 --- a/gradle.properties +++ b/gradle.properties @@ -18,10 +18,10 @@ slug=agorapulse/micronaut-grails group=com.agorapulse -version = 3.0.0-SNAPSHOT +version = 4.0.0-SNAPSHOT -micronautVersion = 1.3.7 -grailsVersion=4.0.4 +micronautVersion = 3.10.1 +grailsVersion=5.3.3 gruVersion = 0.9.4 druVersion = 0.8.1 groovyVersion = 2.5.8 @@ -34,8 +34,8 @@ dockerApiVersion = 3.2.12 groovyClosureSupportVersion = 0.6.3 kordampVersion=0.46.0 nexusPluginVersion=1.0.0 -grailsTestingSupportVersion=2.1.2 -hibernateVersion=5.6.3.Final +grailsTestingSupportVersion=2.6.1 +hibernateVersion=5.6.11.Final # this should be aligned to Micronaut version # required for AWS CBOR marshalling diff --git a/subprojects/micronaut-grails-jpa-generator/src/main/groovy/com/agorapulse/micronaut/grails/jpa/generator/MicronautDataGenerator.groovy b/subprojects/micronaut-grails-jpa-generator/src/main/groovy/com/agorapulse/micronaut/grails/jpa/generator/MicronautDataGenerator.groovy index 204c5362..247e7dc5 100644 --- a/subprojects/micronaut-grails-jpa-generator/src/main/groovy/com/agorapulse/micronaut/grails/jpa/generator/MicronautDataGenerator.groovy +++ b/subprojects/micronaut-grails-jpa-generator/src/main/groovy/com/agorapulse/micronaut/grails/jpa/generator/MicronautDataGenerator.groovy @@ -335,7 +335,7 @@ abstract class MicronautDataGenerator { Set imports ) { if (unified.nullable) { - imports.add('javax.annotation.Nullable') + imports.add('io.micronaut.core.annotation.Nullable') writer.println(' @Nullable') } else if (!unified.persistentProperty.type.primitive) { imports.add('javax.validation.constraints.NotNull') diff --git a/subprojects/micronaut-grails-jpa-generator/src/main/groovy/com/agorapulse/micronaut/grails/jpa/generator/MicronuatDataGeneratorConfiguration.java b/subprojects/micronaut-grails-jpa-generator/src/main/groovy/com/agorapulse/micronaut/grails/jpa/generator/MicronuatDataGeneratorConfiguration.java index 75fe4adf..6c6ce89b 100644 --- a/subprojects/micronaut-grails-jpa-generator/src/main/groovy/com/agorapulse/micronaut/grails/jpa/generator/MicronuatDataGeneratorConfiguration.java +++ b/subprojects/micronaut-grails-jpa-generator/src/main/groovy/com/agorapulse/micronaut/grails/jpa/generator/MicronuatDataGeneratorConfiguration.java @@ -22,7 +22,7 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import javax.inject.Named; +import jakarta.inject.Named; @Configuration public class MicronuatDataGeneratorConfiguration { diff --git a/subprojects/micronaut-grails/src/main/java/com/agorapulse/micronaut/grails/DefaultGrailsMicronautBeanProcessor.java b/subprojects/micronaut-grails/src/main/java/com/agorapulse/micronaut/grails/DefaultGrailsMicronautBeanProcessor.java index bf0303ea..2d2201a2 100644 --- a/subprojects/micronaut-grails/src/main/java/com/agorapulse/micronaut/grails/DefaultGrailsMicronautBeanProcessor.java +++ b/subprojects/micronaut-grails/src/main/java/com/agorapulse/micronaut/grails/DefaultGrailsMicronautBeanProcessor.java @@ -30,7 +30,7 @@ import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContextAware; -import javax.annotation.Nonnull; +import io.micronaut.core.annotation.NonNull; import java.net.URLClassLoader; import java.util.Arrays; import java.util.Collection; @@ -147,7 +147,7 @@ public void destroy() { } @Override - public void setApplicationContext(@Nonnull ApplicationContext applicationContext) throws BeansException { + public void setApplicationContext(@NonNull ApplicationContext applicationContext) throws BeansException { this.springContext = applicationContext; } } diff --git a/subprojects/micronaut-grails/src/main/java/com/agorapulse/micronaut/grails/GrailsMicronautBeanProcessor.java b/subprojects/micronaut-grails/src/main/java/com/agorapulse/micronaut/grails/GrailsMicronautBeanProcessor.java index 72af1667..581bead8 100644 --- a/subprojects/micronaut-grails/src/main/java/com/agorapulse/micronaut/grails/GrailsMicronautBeanProcessor.java +++ b/subprojects/micronaut-grails/src/main/java/com/agorapulse/micronaut/grails/GrailsMicronautBeanProcessor.java @@ -24,7 +24,7 @@ import org.springframework.context.EnvironmentAware; import org.springframework.core.env.Environment; -import javax.annotation.Nonnull; +import io.micronaut.core.annotation.NonNull; import java.util.List; import java.util.Map; @@ -119,7 +119,7 @@ protected ApplicationContext initializeMicronautContext() { } @Override - public void setEnvironment(@Nonnull Environment environment) { + public void setEnvironment(@NonNull Environment environment) { this.environment = environment; } diff --git a/subprojects/micronaut-grails/src/main/java/com/agorapulse/micronaut/grails/GrailsPropertyTranslatingEnvironment.java b/subprojects/micronaut-grails/src/main/java/com/agorapulse/micronaut/grails/GrailsPropertyTranslatingEnvironment.java index 041d72f2..9700fa78 100644 --- a/subprojects/micronaut-grails/src/main/java/com/agorapulse/micronaut/grails/GrailsPropertyTranslatingEnvironment.java +++ b/subprojects/micronaut-grails/src/main/java/com/agorapulse/micronaut/grails/GrailsPropertyTranslatingEnvironment.java @@ -29,8 +29,8 @@ import org.springframework.core.env.MapPropertySource; import org.springframework.core.env.PropertySource; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; +import io.micronaut.core.annotation.NonNull; +import io.micronaut.core.annotation.Nullable; import java.util.Arrays; import java.util.Collection; import java.util.Collections; @@ -51,7 +51,7 @@ class GrailsPropertyTranslatingEnvironment extends DefaultEnvironment { GrailsPropertyTranslatingEnvironment(Environment environment, PropertyTranslatingCustomizer customizer, List expectedMapProperties) { super(new ApplicationContextConfiguration() { - @Nonnull + @NonNull @Override public List getEnvironments() { return Arrays.asList(environment.getActiveProfiles()); diff --git a/subprojects/micronaut-grails/src/main/java/com/agorapulse/micronaut/grails/MicronautContextHolder.java b/subprojects/micronaut-grails/src/main/java/com/agorapulse/micronaut/grails/MicronautContextHolder.java index b50281c9..a285cc7b 100644 --- a/subprojects/micronaut-grails/src/main/java/com/agorapulse/micronaut/grails/MicronautContextHolder.java +++ b/subprojects/micronaut-grails/src/main/java/com/agorapulse/micronaut/grails/MicronautContextHolder.java @@ -19,8 +19,8 @@ import io.micronaut.context.ApplicationContext; -import javax.annotation.Nonnull; -import javax.inject.Singleton; +import io.micronaut.core.annotation.NonNull; +import jakarta.inject.Singleton; @Singleton public class MicronautContextHolder { @@ -31,7 +31,7 @@ public MicronautContextHolder(ApplicationContext context) { this.context = context; } - @Nonnull + @NonNull public ApplicationContext getContext() { return context; } diff --git a/subprojects/micronaut-grails/src/main/java/com/agorapulse/micronaut/grails/MicronautGrailsApp.java b/subprojects/micronaut-grails/src/main/java/com/agorapulse/micronaut/grails/MicronautGrailsApp.java index c5542843..99123edf 100644 --- a/subprojects/micronaut-grails/src/main/java/com/agorapulse/micronaut/grails/MicronautGrailsApp.java +++ b/subprojects/micronaut-grails/src/main/java/com/agorapulse/micronaut/grails/MicronautGrailsApp.java @@ -34,7 +34,7 @@ import org.springframework.context.ConfigurableApplicationContext; import org.springframework.core.env.ConfigurableEnvironment; -import javax.annotation.Nonnull; +import io.micronaut.core.annotation.NonNull; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -84,7 +84,7 @@ public MicronautGrailsAppContextConfiguration( } @Override - @Nonnull + @NonNull public List getEnvironments() { List environments = new ArrayList<>(); environments.add(ENVIRONMENT); @@ -100,7 +100,7 @@ public Optional getDeduceEnvironments() { return Optional.of(false); } - @Override @Nonnull + @Override @NonNull public ClassLoader getClassLoader() { return applicationClassLoader; } @@ -117,8 +117,8 @@ public MicronautGrailsAppContext(MicronautGrailsAppContextConfiguration micronau } @Override - @Nonnull - protected DefaultEnvironment createEnvironment(@Nonnull ApplicationContextConfiguration c) { + @NonNull + protected DefaultEnvironment createEnvironment(@NonNull ApplicationContextConfiguration c) { DefaultEnvironment environment = (DefaultEnvironment) super.createEnvironment(c); ((MicronautGrailsAppContextConfiguration)c).getConfiguration().configureEnvironment(environment); return environment; @@ -208,6 +208,8 @@ protected void configureEnvironment(ConfigurableEnvironment environment, String[ @Override protected ConfigurableApplicationContext createApplicationContext() { setAllowBeanDefinitionOverriding(true); + setAllowCircularReferences(true); + ConfigurableApplicationContext applicationContext = createSpringApplicationContext(); @@ -243,7 +245,7 @@ protected ConfigurableApplicationContext createApplicationContext() { return applicationContext; } - @Nonnull + @NonNull private MicronautGrailsAutoConfiguration getApplication() { try { return getAllSources() diff --git a/subprojects/micronaut-grails/src/main/java/com/agorapulse/micronaut/grails/TypeAndQualifier.java b/subprojects/micronaut-grails/src/main/java/com/agorapulse/micronaut/grails/TypeAndQualifier.java index 8c2ba9b0..9f3aa108 100644 --- a/subprojects/micronaut-grails/src/main/java/com/agorapulse/micronaut/grails/TypeAndQualifier.java +++ b/subprojects/micronaut-grails/src/main/java/com/agorapulse/micronaut/grails/TypeAndQualifier.java @@ -19,7 +19,7 @@ import io.micronaut.context.Qualifier; -import javax.annotation.Nullable; +import io.micronaut.core.annotation.Nullable; public class TypeAndQualifier { diff --git a/subprojects/micronaut-grails/src/test/groovy/com/agorapulse/micronaut/grails/GrailsMicronautBeanProcessorSpec.groovy b/subprojects/micronaut-grails/src/test/groovy/com/agorapulse/micronaut/grails/GrailsMicronautBeanProcessorSpec.groovy index 6d533359..271cea30 100644 --- a/subprojects/micronaut-grails/src/test/groovy/com/agorapulse/micronaut/grails/GrailsMicronautBeanProcessorSpec.groovy +++ b/subprojects/micronaut-grails/src/test/groovy/com/agorapulse/micronaut/grails/GrailsMicronautBeanProcessorSpec.groovy @@ -33,9 +33,9 @@ import org.springframework.test.context.ContextConfiguration import org.springframework.test.context.TestPropertySource import spock.lang.Specification -import javax.inject.Named -import javax.inject.Scope -import javax.inject.Singleton +import jakarta.inject.Named +import jakarta.inject.Scope +import jakarta.inject.Singleton import java.lang.annotation.Documented import java.lang.annotation.Retention