From b9de326718b8f2e8dab901801b205473e6c1c742 Mon Sep 17 00:00:00 2001 From: Alexey Trofimov Date: Sat, 28 Dec 2024 16:40:08 +0700 Subject: [PATCH] Kotlin DSL Gradle 8.12 Update libs Fixed tests for windows --- build-logic/build.gradle.kts | 12 +++ .../settings.gradle.kts | 2 +- ...onaut.build.internal.sourcegen-base.gradle | 0 ...aut.build.internal.sourcegen-module.gradle | 10 +++ ....build.internal.sourcegen-testsuite.gradle | 4 - build.gradle | 14 --- build.gradle.kts | 17 ++++ buildSrc/build.gradle | 14 --- ...aut.build.internal.sourcegen-module.gradle | 10 --- gradle.properties | 13 ++- gradle/libs.versions.toml | 25 +++--- gradle/wrapper/gradle-wrapper.properties | 2 +- gradlew | 3 +- settings.gradle.kts | 3 +- sourcegen-bytecode-writer/build.gradle.kts | 8 +- .../expression/CastExpressionWriter.java | 2 +- .../bytecode/ByteCodeWriterTest.java | 90 +++++++++---------- .../sourcegen/bytecode/DecompilerUtils.java | 2 +- sourcegen-generator-bytecode/build.gradle.kts | 3 +- sourcegen-generator-java/build.gradle.kts | 9 +- sourcegen-generator-kotlin/build.gradle.kts | 13 ++- sourcegen-generator/build.gradle.kts | 1 + test-suite-bytecode/build.gradle.kts | 8 +- test-suite-groovy/build.gradle.kts | 9 +- test-suite-java/build.gradle.kts | 12 ++- test-suite-kotlin/build.gradle.kts | 12 ++- 26 files changed, 151 insertions(+), 147 deletions(-) create mode 100644 build-logic/build.gradle.kts rename buildSrc/settings.gradle => build-logic/settings.gradle.kts (83%) rename {buildSrc => build-logic}/src/main/groovy/io.micronaut.build.internal.sourcegen-base.gradle (100%) create mode 100644 build-logic/src/main/groovy/io.micronaut.build.internal.sourcegen-module.gradle rename {buildSrc => build-logic}/src/main/groovy/io.micronaut.build.internal.sourcegen-testsuite.gradle (63%) delete mode 100644 build.gradle create mode 100644 build.gradle.kts delete mode 100644 buildSrc/build.gradle delete mode 100644 buildSrc/src/main/groovy/io.micronaut.build.internal.sourcegen-module.gradle diff --git a/build-logic/build.gradle.kts b/build-logic/build.gradle.kts new file mode 100644 index 00000000..16aa147d --- /dev/null +++ b/build-logic/build.gradle.kts @@ -0,0 +1,12 @@ +plugins { + id("groovy-gradle-plugin") +} + +repositories { + gradlePluginPortal() + mavenCentral() +} + +dependencies { + implementation(libs.micronaut.gradle.plugin) +} diff --git a/buildSrc/settings.gradle b/build-logic/settings.gradle.kts similarity index 83% rename from buildSrc/settings.gradle rename to build-logic/settings.gradle.kts index 6f31e6ef..b5a0fabf 100644 --- a/buildSrc/settings.gradle +++ b/build-logic/settings.gradle.kts @@ -1,6 +1,6 @@ dependencyResolutionManagement { versionCatalogs { - libs { + create("libs") { from(files("../gradle/libs.versions.toml")) } } diff --git a/buildSrc/src/main/groovy/io.micronaut.build.internal.sourcegen-base.gradle b/build-logic/src/main/groovy/io.micronaut.build.internal.sourcegen-base.gradle similarity index 100% rename from buildSrc/src/main/groovy/io.micronaut.build.internal.sourcegen-base.gradle rename to build-logic/src/main/groovy/io.micronaut.build.internal.sourcegen-base.gradle diff --git a/build-logic/src/main/groovy/io.micronaut.build.internal.sourcegen-module.gradle b/build-logic/src/main/groovy/io.micronaut.build.internal.sourcegen-module.gradle new file mode 100644 index 00000000..55a50f58 --- /dev/null +++ b/build-logic/src/main/groovy/io.micronaut.build.internal.sourcegen-module.gradle @@ -0,0 +1,10 @@ +plugins { + id("io.micronaut.build.internal.sourcegen-base") + id("io.micronaut.build.internal.module") +} + +micronautBuild { + binaryCompatibility { + enabled.set(false) + } +} diff --git a/buildSrc/src/main/groovy/io.micronaut.build.internal.sourcegen-testsuite.gradle b/build-logic/src/main/groovy/io.micronaut.build.internal.sourcegen-testsuite.gradle similarity index 63% rename from buildSrc/src/main/groovy/io.micronaut.build.internal.sourcegen-testsuite.gradle rename to build-logic/src/main/groovy/io.micronaut.build.internal.sourcegen-testsuite.gradle index a6447165..27290242 100644 --- a/buildSrc/src/main/groovy/io.micronaut.build.internal.sourcegen-testsuite.gradle +++ b/build-logic/src/main/groovy/io.micronaut.build.internal.sourcegen-testsuite.gradle @@ -10,7 +10,3 @@ tasks.withType(Test).configureEach { tasks.withType(Checkstyle).configureEach { enabled = false } - -if (System.getenv("SONAR_TOKEN") != null) { - tasks.configureEach { if (it.name == "testCodeCoverageReport") { enabled = false } } -} diff --git a/build.gradle b/build.gradle deleted file mode 100644 index cd42f40f..00000000 --- a/build.gradle +++ /dev/null @@ -1,14 +0,0 @@ -plugins { - id 'io.micronaut.build.internal.sourcegen-base' - id "io.micronaut.build.internal.docs" - id "io.micronaut.build.internal.quality-reporting" -} - -if (System.getenv("SONAR_TOKEN") != null) { - tasks.configureEach { if (it.name == "testCodeCoverageReport") { enabled = false } } -} -afterEvaluate { - configurations.javadocAggregatorBase.dependencies.removeIf { - it.name.startsWith('test-suite') - } -} diff --git a/build.gradle.kts b/build.gradle.kts new file mode 100644 index 00000000..24f13496 --- /dev/null +++ b/build.gradle.kts @@ -0,0 +1,17 @@ +plugins { + id("io.micronaut.build.internal.sourcegen-base") + id("io.micronaut.build.internal.docs") + id("io.micronaut.build.internal.quality-reporting") +} + +if (System.getenv("SONAR_TOKEN") != null) { + tasks.named("testCodeCoverageReport") { enabled = false } +} + +afterEvaluate { + configurations.javadocAggregatorBase.configure { + dependencies.removeIf { + it.name.startsWith("test-suite") + } + } +} diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle deleted file mode 100644 index 0314a9a0..00000000 --- a/buildSrc/build.gradle +++ /dev/null @@ -1,14 +0,0 @@ -plugins { - id 'groovy-gradle-plugin' -} - -repositories { - gradlePluginPortal() - mavenCentral() -} - -dependencies { - implementation (libs.micronaut.gradle.plugin) - implementation (libs.kotlin.gradle.plugin) - implementation (libs.kotlin.gradle.allopen) -} diff --git a/buildSrc/src/main/groovy/io.micronaut.build.internal.sourcegen-module.gradle b/buildSrc/src/main/groovy/io.micronaut.build.internal.sourcegen-module.gradle deleted file mode 100644 index 033a9dc0..00000000 --- a/buildSrc/src/main/groovy/io.micronaut.build.internal.sourcegen-module.gradle +++ /dev/null @@ -1,10 +0,0 @@ -plugins { - id 'io.micronaut.build.internal.sourcegen-base' - id "io.micronaut.build.internal.module" -} - -micronautBuild { - binaryCompatibility { - enabled.set(false) - } -} diff --git a/gradle.properties b/gradle.properties index c2836e76..8d93391d 100644 --- a/gradle.properties +++ b/gradle.properties @@ -7,12 +7,9 @@ projectUrl=https://micronaut.io githubSlug=micronaut-projects/micronaut-sourcegen developers=Denis Stepanov -# Micronaut core branch for BOM pull requests -githubCoreBranch=3.8.x - -# bomProperty=micronautXXXVersion -# If needed, set additional properties -# bomProperties=hibernateVersion,tomcatJdbcVersion - +org.gradle.jvmargs=-Xmx2g -Dfile.encoding=UTF-8 +org.gradle.configuration-cache=false +org.gradle.configuration-cache.parallel=false org.gradle.caching=true -org.gradle.jvmargs=-Xmx1g +org.gradle.parallel=true +kotlin.stdlib.default.dependency=false diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index dc976b2a..6127b7f6 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,22 +1,22 @@ [versions] -micronaut = "4.7.10" -micronaut-platform = "4.6.3" -micronaut-docs = "2.0.0" -micronaut-test = "4.1.0" -micronaut-data = "4.9.6" -micronaut-validation = "4.8.0" -micronaut-gradle-plugin = "4.4.4" managed-kotlinpoet = "2.0.0" + google-truth = "1.4.4" google-compile-testing = "0.21.0" google-jimfs = "1.3.0" -kotlin = '1.9.25' -ksp = '1.9.24-1.0.20' asm = "9.7.1" -intellij-java-decompiler = "242.23726.103" +intellij-java-decompiler = "243.22562.218" + +micronaut = "4.7.10" +micronaut-platform = "4.7.3" +micronaut-docs = "2.0.0" +micronaut-test = "4.6.2" +micronaut-data = "4.10.5" +micronaut-validation = "4.8.0" +micronaut-gradle-plugin = "4.4.4" [libraries] -# Core +# Micronaut micronaut-core = { module = 'io.micronaut:micronaut-core-bom', version.ref = 'micronaut' } micronaut-data = { module = 'io.micronaut.data:micronaut-data-bom', version.ref = 'micronaut-data' } micronaut-validation = { module = "io.micronaut.validation:micronaut-validation-bom", version.ref = "micronaut-validation" } @@ -32,9 +32,6 @@ asm-tree = { module = "org.ow2.asm:asm-tree", version.ref = "asm" } google-truth = { module = "com.google.truth:truth", version.ref = "google-truth" } google-compile-testing = { module = "com.google.testing.compile:compile-testing", version.ref = "google-compile-testing" } google-jimfs = { module = "com.google.jimfs:jimfs", version.ref = "google-jimfs" } -junit-jupiter-engine = { module = "org.junit.jupiter:junit-jupiter-engine" } micronaut-gradle-plugin = { module = "io.micronaut.gradle:micronaut-gradle-plugin", version.ref="micronaut-gradle-plugin" } -kotlin-gradle-plugin = { module = 'org.jetbrains.kotlin:kotlin-gradle-plugin', version.ref = 'kotlin' } -kotlin-gradle-allopen = { module = 'org.jetbrains.kotlin:kotlin-allopen', version.ref = 'kotlin' } intellij-java-decompiler = { module = 'com.jetbrains.intellij.java:java-decompiler-engine', version.ref = 'intellij-java-decompiler' } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index e2847c82..cea7a793 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/gradlew b/gradlew index f5feea6d..f3b75f3b 100755 --- a/gradlew +++ b/gradlew @@ -86,8 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s -' "$PWD" ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum diff --git a/settings.gradle.kts b/settings.gradle.kts index be6f4eb5..25d4727e 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -5,6 +5,8 @@ pluginManagement { } } +includeBuild("build-logic") + plugins { id("io.micronaut.build.shared.settings") version "7.2.3" } @@ -40,4 +42,3 @@ dependencyResolutionManagement { mavenCentral() } } - diff --git a/sourcegen-bytecode-writer/build.gradle.kts b/sourcegen-bytecode-writer/build.gradle.kts index 59b03bc9..7915fbc3 100644 --- a/sourcegen-bytecode-writer/build.gradle.kts +++ b/sourcegen-bytecode-writer/build.gradle.kts @@ -10,14 +10,18 @@ repositories { dependencies { api(projects.sourcegenModel) - compileOnly(mn.micronaut.core.processor) api(libs.asm) api(libs.asm.commons) api(libs.asm.util) + + compileOnly(mn.micronaut.core.processor) + testImplementation(mn.micronaut.core.processor) - testImplementation(libs.junit.jupiter.engine) + testImplementation(mnTest.junit.jupiter.api) testImplementation(libs.intellij.java.decompiler) testImplementation(projects.testSuiteCustomGenerators) + + testRuntimeOnly(mnTest.junit.jupiter.engine) } tasks.withType { diff --git a/sourcegen-bytecode-writer/src/main/java/io/micronaut/sourcegen/bytecode/expression/CastExpressionWriter.java b/sourcegen-bytecode-writer/src/main/java/io/micronaut/sourcegen/bytecode/expression/CastExpressionWriter.java index baa2e8e7..42d97876 100644 --- a/sourcegen-bytecode-writer/src/main/java/io/micronaut/sourcegen/bytecode/expression/CastExpressionWriter.java +++ b/sourcegen-bytecode-writer/src/main/java/io/micronaut/sourcegen/bytecode/expression/CastExpressionWriter.java @@ -28,6 +28,7 @@ import org.objectweb.asm.commons.GeneratorAdapter; final class CastExpressionWriter implements ExpressionWriter { + private final ExpressionDef.Cast castExpressionDef; public CastExpressionWriter(ExpressionDef.Cast castExpressionDef) { @@ -128,7 +129,6 @@ private static ClassTypeDef getSuperclass(ObjectDef objectDef) { return null; } - private static void checkCast(GeneratorAdapter generatorAdapter, MethodContext context, TypeDef from, TypeDef to) { TypeDef toType = ObjectDef.getContextualType(context.objectDef(), to); if (!toType.makeNullable().equals(from.makeNullable())) { diff --git a/sourcegen-bytecode-writer/src/test/java/io/micronaut/sourcegen/bytecode/ByteCodeWriterTest.java b/sourcegen-bytecode-writer/src/test/java/io/micronaut/sourcegen/bytecode/ByteCodeWriterTest.java index 4edcece8..f3e91c77 100644 --- a/sourcegen-bytecode-writer/src/test/java/io/micronaut/sourcegen/bytecode/ByteCodeWriterTest.java +++ b/sourcegen-bytecode-writer/src/test/java/io/micronaut/sourcegen/bytecode/ByteCodeWriterTest.java @@ -13,7 +13,6 @@ import io.micronaut.sourcegen.model.StatementDef; import io.micronaut.sourcegen.model.TypeDef; import io.micronaut.sourcegen.model.VariableDef; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.objectweb.asm.ClassWriter; import org.objectweb.asm.util.CheckClassAdapter; @@ -28,6 +27,7 @@ import java.util.Map; import static io.micronaut.sourcegen.bytecode.DecompilerUtils.decompileToJava; +import static org.junit.jupiter.api.Assertions.assertEquals; class ByteCodeWriterTest { @@ -44,11 +44,11 @@ void testNullCondition() { ))) .build(); - StringWriter bytecodeWriter = new StringWriter(); + var bytecodeWriter = new StringWriter(); byte[] bytes = generateFile(ifPredicateDef, bytecodeWriter); String bytecode = bytecodeWriter.toString(); - Assertions.assertEquals(""" + assertEquals(""" // class version 61.0 (61) // access flags 0x0 // signature Ljava/lang/Object; @@ -77,7 +77,7 @@ class example/IfPredicate { } """, bytecode); - Assertions.assertEquals(""" + assertEquals(""" package example; class IfPredicate { @@ -103,7 +103,7 @@ void testBoxing() { byte[] bytes = generateFile(ifPredicateDef, bytecodeWriter); String bytecode = bytecodeWriter.toString(); - Assertions.assertEquals(""" + assertEquals(""" // class version 61.0 (61) // access flags 0x0 // signature Ljava/lang/Object; @@ -129,7 +129,7 @@ class example/IfPredicate { } """, bytecode); - Assertions.assertEquals(""" + assertEquals(""" package example; class IfPredicate { @@ -155,7 +155,7 @@ void testUnboxing() { byte[] bytes = generateFile(ifPredicateDef, bytecodeWriter); String bytecode = bytecodeWriter.toString(); - Assertions.assertEquals(""" + assertEquals(""" // class version 61.0 (61) // access flags 0x0 // signature Ljava/lang/Object; @@ -181,7 +181,7 @@ class example/IfPredicate { """, bytecode); - Assertions.assertEquals(""" + assertEquals(""" package example; class IfPredicate { @@ -197,7 +197,7 @@ void testEnum() { EnumDef myEnum = EnumDef.builder("MyEnum").addEnumConstant("A").addEnumConstant("B").addEnumConstant("C").build(); String bytecode = toBytecode(myEnum); - Assertions.assertEquals(""" + assertEquals(""" // class version 61.0 (61) // access flags 0x4010 // signature Ljava/lang/Enum; @@ -334,7 +334,7 @@ void testSynchronized() { byte[] bytes = generateFile(classDef, bytecodeWriter); String bytecode = bytecodeWriter.toString(); - Assertions.assertEquals(""" + assertEquals(""" // class version 61.0 (61) // access flags 0x0 // signature Ljava/lang/Object; @@ -403,7 +403,7 @@ class test/MyClass { """, bytecode); - Assertions.assertEquals(""" + assertEquals(""" package test; import io.micronaut.context.BeanResolutionContext; @@ -462,7 +462,7 @@ void testFinally() { byte[] bytes = generateFile(classDef, bytecodeWriter); String bytecode = bytecodeWriter.toString(); - Assertions.assertEquals(""" + assertEquals(""" // class version 61.0 (61) // access flags 0x0 // signature Ljava/lang/Object; @@ -529,7 +529,7 @@ class test/MyClass { } """, bytecode); - Assertions.assertEquals(""" + assertEquals(""" package test; class MyClass { @@ -590,7 +590,7 @@ void testFinally2 () { byte[] bytes = generateFile(classDef, bytecodeWriter); String bytecode = bytecodeWriter.toString(); - Assertions.assertEquals(""" + assertEquals(""" // class version 61.0 (61) // access flags 0x0 // signature Ljava/lang/Object; @@ -647,7 +647,7 @@ class test/MyClass { } """, bytecode); - Assertions.assertEquals(""" + assertEquals(""" package test; class MyClass { @@ -699,7 +699,7 @@ void testTableSwitchWithDuplicateStatements() { byte[] bytes = generateFile(classDef, bytecodeWriter); String bytecode = bytecodeWriter.toString(); - Assertions.assertEquals(""" + assertEquals(""" // class version 61.0 (61) // access flags 0x0 // signature Ljava/lang/Object; @@ -743,7 +743,7 @@ public swap(I)I } """, bytecode); - Assertions.assertEquals(""" + assertEquals(""" package test; class MyClass { @@ -796,7 +796,7 @@ void testTableLookupWithDuplicateStatements() { byte[] bytes = generateFile(classDef, bytecodeWriter); String bytecode = bytecodeWriter.toString(); - Assertions.assertEquals(""" + assertEquals(""" // class version 61.0 (61) // access flags 0x0 // signature Ljava/lang/Object; @@ -840,7 +840,7 @@ public swap(I)I } """, bytecode); - Assertions.assertEquals(""" + assertEquals(""" package test; class MyClass { @@ -880,7 +880,7 @@ void testInnerClass() { byte[] bytes = generateFile(classDef, bytecodeWriter); String bytecode = bytecodeWriter.toString(); - Assertions.assertEquals(""" + assertEquals(""" // class version 61.0 (61) // access flags 0x0 // signature Ljava/lang/Object; @@ -904,7 +904,7 @@ class test/MyClass { } """, bytecode); - Assertions.assertEquals(""" + assertEquals(""" package test; class MyClass { @@ -923,7 +923,7 @@ void testInnerEnum() { byte[] bytes = generateFile(enumDef, bytecodeWriter); String bytecode = bytecodeWriter.toString(); - Assertions.assertEquals(""" + assertEquals(""" // class version 61.0 (61) // access flags 0x4011 // signature Ljava/lang/Enum; @@ -1035,7 +1035,7 @@ public final static enum Lexample/MyEnumWithInnerTypes; C } """, bytecode); - Assertions.assertEquals(""" + assertEquals(""" package example; public enum MyEnumWithInnerTypes { @@ -1073,7 +1073,7 @@ void testLocalVariable() { byte[] bytes = generateFile(classDef, bytecodeWriter); String bytecode = bytecodeWriter.toString(); - Assertions.assertEquals(""" + assertEquals(""" // class version 61.0 (61) // access flags 0x0 // signature Ljava/lang/Object; @@ -1110,7 +1110,7 @@ class example/Test { } """, bytecode); - Assertions.assertEquals(""" + assertEquals(""" package example; class Test { @@ -1135,7 +1135,7 @@ void testMultipleCasts() { byte[] bytes = generateFile(classDef, bytecodeWriter); String bytecode = bytecodeWriter.toString(); - Assertions.assertEquals(""" + assertEquals(""" // class version 61.0 (61) // access flags 0x0 // signature Ljava/lang/Object; @@ -1160,7 +1160,7 @@ class example/Test { } """, bytecode); - Assertions.assertEquals(""" + assertEquals(""" package example; class Test { @@ -1184,7 +1184,7 @@ void testNullCast() { byte[] bytes = generateFile(classDef, bytecodeWriter); String bytecode = bytecodeWriter.toString(); - Assertions.assertEquals(""" + assertEquals(""" // class version 61.0 (61) // access flags 0x0 // signature Ljava/lang/Object; @@ -1208,7 +1208,7 @@ class example/Test { } """, bytecode); - Assertions.assertEquals(""" + assertEquals(""" package example; class Test { @@ -1236,7 +1236,7 @@ void testTrueFalseConditions() { byte[] bytes = generateFile(classDef, bytecodeWriter); String bytecode = bytecodeWriter.toString(); - Assertions.assertEquals(""" + assertEquals(""" // class version 61.0 (61) // access flags 0x0 // signature Ljava/lang/Object; @@ -1277,7 +1277,7 @@ class example/Test { } """, bytecode); - Assertions.assertEquals(""" + assertEquals(""" package example; class Test { @@ -1305,7 +1305,7 @@ void testTrueFalseConditions2() { byte[] bytes = generateFile(classDef, bytecodeWriter); String bytecode = bytecodeWriter.toString(); - Assertions.assertEquals(""" + assertEquals(""" // class version 61.0 (61) // access flags 0x0 // signature Ljava/lang/Object; @@ -1346,7 +1346,7 @@ class example/Test { } """, bytecode); - Assertions.assertEquals(""" + assertEquals(""" package example; class Test { @@ -1414,7 +1414,7 @@ void testPrimitives() { StringWriter bytecodeWriter = new StringWriter(); byte[] bytes = generateFile(classDef, bytecodeWriter); - Assertions.assertEquals(""" + assertEquals(""" package example; class Test { @@ -1475,7 +1475,7 @@ void testCastingNull() { String bytecode = bytecodeWriter.toString(); - Assertions.assertEquals(""" + assertEquals(""" // class version 61.0 (61) // access flags 0x0 // signature Ljava/lang/Object; @@ -1506,7 +1506,7 @@ class example/Test { } """, bytecode); - Assertions.assertEquals(""" + assertEquals(""" package example; class Test { @@ -1541,7 +1541,7 @@ void testCastingClassDefWithSuperclass() { String bytecode = bytecodeWriter.toString(); - Assertions.assertEquals(""" + assertEquals(""" // class version 61.0 (61) // access flags 0x0 // signature Ljava/lang/Object; @@ -1564,7 +1564,7 @@ class example/Test { } """, bytecode); - Assertions.assertEquals(""" + assertEquals(""" package example; import java.util.List; @@ -1593,7 +1593,7 @@ void testCastingThisClassDefWithSuperclass() { String bytecode = bytecodeWriter.toString(); - Assertions.assertEquals(""" + assertEquals(""" // class version 61.0 (61) // access flags 0x0 // signature Ljava/util/AbstractList; @@ -1616,7 +1616,7 @@ class example/Test extends java/util/AbstractList { } """, bytecode); - Assertions.assertEquals(""" + assertEquals(""" package example; import java.util.AbstractList; @@ -1652,7 +1652,7 @@ void testCastingEnum() { String bytecode = bytecodeWriter.toString(); - Assertions.assertEquals(""" + assertEquals(""" // class version 61.0 (61) // access flags 0x0 // signature Ljava/lang/Object; @@ -1673,7 +1673,7 @@ class example/Test { } """, bytecode); - Assertions.assertEquals(""" + assertEquals(""" package example; class Test { @@ -1691,9 +1691,9 @@ private String toBytecode(ObjectDef objectDef) { } private byte[] generateFile(ObjectDef objectDef, StringWriter stringWriter) { - ClassWriter classWriter = new ClassWriter(ClassWriter.COMPUTE_MAXS | ClassWriter.COMPUTE_FRAMES); - CheckClassAdapter checkClassAdapter = new CheckClassAdapter(classWriter); - TraceClassVisitor tcv = new TraceClassVisitor(checkClassAdapter, new PrintWriter(stringWriter)); + var classWriter = new ClassWriter(ClassWriter.COMPUTE_MAXS | ClassWriter.COMPUTE_FRAMES); + var checkClassAdapter = new CheckClassAdapter(classWriter); + var tcv = new TraceClassVisitor(checkClassAdapter, new PrintWriter(stringWriter)); new ByteCodeWriter(false, false).writeObject(tcv, objectDef); diff --git a/sourcegen-bytecode-writer/src/test/java/io/micronaut/sourcegen/bytecode/DecompilerUtils.java b/sourcegen-bytecode-writer/src/test/java/io/micronaut/sourcegen/bytecode/DecompilerUtils.java index 18448563..8f6bb079 100644 --- a/sourcegen-bytecode-writer/src/test/java/io/micronaut/sourcegen/bytecode/DecompilerUtils.java +++ b/sourcegen-bytecode-writer/src/test/java/io/micronaut/sourcegen/bytecode/DecompilerUtils.java @@ -38,7 +38,7 @@ private String getAbsolutePath(String path) { @Override public void saveClassFile(String s, String s1, String s2, String s3, int[] ints) { - result[0] = s3; + result[0] = s3.replace("\r\n", "\n"); } @Override diff --git a/sourcegen-generator-bytecode/build.gradle.kts b/sourcegen-generator-bytecode/build.gradle.kts index 080b6e1a..809202d0 100644 --- a/sourcegen-generator-bytecode/build.gradle.kts +++ b/sourcegen-generator-bytecode/build.gradle.kts @@ -5,7 +5,8 @@ plugins { dependencies { api(projects.sourcegenGenerator) api(projects.sourcegenBytecodeWriter) - testImplementation(libs.junit.jupiter.engine) + + testRuntimeOnly(mnTest.junit.jupiter.engine) } tasks.withType { diff --git a/sourcegen-generator-java/build.gradle.kts b/sourcegen-generator-java/build.gradle.kts index 70dcd1fd..c4d43b36 100644 --- a/sourcegen-generator-java/build.gradle.kts +++ b/sourcegen-generator-java/build.gradle.kts @@ -4,20 +4,19 @@ plugins { dependencies { implementation(projects.sourcegenGenerator) + testImplementation(libs.google.truth) testImplementation(libs.google.compile.testing) testImplementation(libs.google.jimfs) testImplementation(mnTest.mockito.core) } -tasks.withType(Test::class.java).configureEach { +tasks.withType { useJUnit() - predictiveSelection { - enabled = false - } + develocity.predictiveTestSelection.enabled = false } -tasks.withType(Checkstyle::class.java).configureEach { +tasks.withType { exclude("**/javapoet/**") } diff --git a/sourcegen-generator-kotlin/build.gradle.kts b/sourcegen-generator-kotlin/build.gradle.kts index 53c41f17..ec3bbe3b 100644 --- a/sourcegen-generator-kotlin/build.gradle.kts +++ b/sourcegen-generator-kotlin/build.gradle.kts @@ -1,6 +1,6 @@ plugins { id("io.micronaut.build.internal.sourcegen-module") - id("org.jetbrains.kotlin.jvm") + alias(mn.plugins.kotlin.jvm) } dependencies { @@ -9,12 +9,11 @@ dependencies { implementation(libs.managed.kotlinpoet.javapoet) testImplementation(mnTest.micronaut.test.junit5) - testImplementation(libs.junit.jupiter.engine) + + testRuntimeOnly(mnTest.junit.jupiter.engine) } -tasks.withType(Test::class).configureEach { - useJUnit() - predictiveSelection { - enabled = false - } +tasks.withType { + useJUnitPlatform() + develocity.predictiveTestSelection.enabled = false } diff --git a/sourcegen-generator/build.gradle.kts b/sourcegen-generator/build.gradle.kts index ba0601dc..9ebbb20f 100644 --- a/sourcegen-generator/build.gradle.kts +++ b/sourcegen-generator/build.gradle.kts @@ -5,6 +5,7 @@ plugins { dependencies { api(projects.sourcegenModel) api(mn.micronaut.core.processor) + implementation(projects.sourcegenAnnotations) testImplementation(mn.micronaut.inject.java.test) diff --git a/test-suite-bytecode/build.gradle.kts b/test-suite-bytecode/build.gradle.kts index 9280cf36..bb858c2f 100644 --- a/test-suite-bytecode/build.gradle.kts +++ b/test-suite-bytecode/build.gradle.kts @@ -6,11 +6,15 @@ dependencies { annotationProcessor(mn.micronaut.inject.java) annotationProcessor(projects.sourcegenGeneratorBytecode) annotationProcessor(projects.testSuiteCustomGenerators) + implementation(projects.sourcegenAnnotations) implementation(projects.testSuiteCustomAnnotations) - testImplementation(mnTest.micronaut.test.junit5) - testImplementation(libs.junit.jupiter.engine) + testAnnotationProcessor(mn.micronaut.inject.java) + + testImplementation(mnTest.micronaut.test.junit5) + + testRuntimeOnly(mnTest.junit.jupiter.engine) } // //tasks { diff --git a/test-suite-groovy/build.gradle.kts b/test-suite-groovy/build.gradle.kts index f1830bb9..6bfcf89f 100644 --- a/test-suite-groovy/build.gradle.kts +++ b/test-suite-groovy/build.gradle.kts @@ -1,6 +1,6 @@ plugins { id("io.micronaut.build.internal.sourcegen-testsuite") - id("groovy") + groovy } dependencies { @@ -12,12 +12,9 @@ dependencies { // implementation(projects.sourcegenGeneratorJava) // implementation(projects.sourcegenGenerator) -// annotationProcessor(mn.micronaut.inject.groovy) -// annotationProcessor(projects.sourcegenGeneratorJava) -// annotationProcessor(projects.sourcegenGenerator) - implementation(projects.sourcegenAnnotations) testImplementation(mnTest.micronaut.test.junit5) - testImplementation(libs.junit.jupiter.engine) + + testRuntimeOnly(mnTest.junit.jupiter.engine) } diff --git a/test-suite-java/build.gradle.kts b/test-suite-java/build.gradle.kts index 3c73395d..e7b2e7e7 100644 --- a/test-suite-java/build.gradle.kts +++ b/test-suite-java/build.gradle.kts @@ -4,24 +4,29 @@ plugins { } micronaut { + version.set(libs.versions.micronaut.platform) processing { // test incremental compile incremental(true) } - version.set(libs.versions.micronaut.platform) } + dependencies { annotationProcessor(projects.sourcegenGeneratorJava) annotationProcessor(projects.testSuiteCustomGenerators) annotationProcessor(mnData.micronaut.data.processor) annotationProcessor(mnValidation.micronaut.validation.processor) + implementation(mnValidation.micronaut.validation) implementation(projects.sourcegenAnnotations) implementation(projects.testSuiteCustomAnnotations) implementation(mnData.micronaut.data.model) - testImplementation(mnTest.micronaut.test.junit5) - testImplementation(libs.junit.jupiter.engine) + testAnnotationProcessor(mn.micronaut.inject.java.test) + + testImplementation(mnTest.micronaut.test.junit5) + + testRuntimeOnly(mnTest.junit.jupiter.engine) } // //tasks { @@ -30,4 +35,3 @@ dependencies { // options.forkOptions.jvmArgs = listOf("-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005") // } //} - diff --git a/test-suite-kotlin/build.gradle.kts b/test-suite-kotlin/build.gradle.kts index 4a0e840b..e6c429c6 100644 --- a/test-suite-kotlin/build.gradle.kts +++ b/test-suite-kotlin/build.gradle.kts @@ -1,8 +1,8 @@ plugins { id("io.micronaut.build.internal.sourcegen-testsuite") - id("org.jetbrains.kotlin.jvm") - id("com.google.devtools.ksp") version mn.versions.ksp - id("org.jetbrains.kotlin.plugin.allopen") + alias(mn.plugins.kotlin.jvm) + alias(mn.plugins.kotlin.allopen) + alias(mn.plugins.ksp) } dependencies { @@ -10,10 +10,14 @@ dependencies { ksp(projects.sourcegenGeneratorKotlin) ksp(projects.testSuiteCustomGenerators) ksp(mnValidation.micronaut.validation.processor) + implementation(mnValidation.micronaut.validation) + implementation(mn.kotlin.stdlib) implementation(mn.micronaut.inject.kotlin) implementation(projects.sourcegenAnnotations) implementation(projects.testSuiteCustomAnnotations) + testImplementation(mnTest.micronaut.test.junit5) - testImplementation(libs.junit.jupiter.engine) + + testRuntimeOnly(mnTest.junit.jupiter.engine) }