From 0ec0beca514b09ccce4610ba1d01217fe2fc1651 Mon Sep 17 00:00:00 2001 From: Xavier Gouchet Date: Tue, 3 Oct 2023 18:50:22 +0200 Subject: [PATCH 1/5] Cleanup gradle and Kotlin config --- build.gradle.kts | 3 +-- buildSrc/build.gradle.kts | 5 +++-- inject/build.gradle.kts | 2 +- junit4/build.gradle.kts | 2 +- junit5/build.gradle.kts | 2 +- jvm/build.gradle.kts | 3 ++- semantics/build.gradle.kts | 3 ++- spek/build.gradle.kts | 2 +- 8 files changed, 12 insertions(+), 10 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index b74105e..3e2f3b5 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -11,7 +11,7 @@ buildscript { repositories { google() mavenCentral() - maven { setUrl("http://repo1.maven.org/maven2") } + maven { setUrl("https://repo1.maven.org/maven2") } maven { setUrl("https://plugins.gradle.org/m2/") } maven { setUrl("https://dl.bintray.com/kotlin/dokka") } } @@ -45,7 +45,6 @@ if (localPropertiesFile.exists()) { nexusPublishing { this.repositories { sonatype { -// nexusUrl.set(URI("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/")) nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/")) val sonatypeUsername = project.properties["ossrhUsername"]?.toString() val sonatypePassword = project.properties["ossrhPassword"]?.toString() diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index c164c31..ed4b725 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -1,12 +1,13 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile plugins { + kotlin("jvm") version "1.8.10" `kotlin-dsl` } buildscript { dependencies { - classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.61") + classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.10") } repositories { mavenCentral() @@ -42,4 +43,4 @@ gradlePlugin { implementationClass = "fr.xgouchet.buildsrc.plugin.GithubWikiPlugin" } } -} +} \ No newline at end of file diff --git a/inject/build.gradle.kts b/inject/build.gradle.kts index 4f5eb3f..f69bcd7 100644 --- a/inject/build.gradle.kts +++ b/inject/build.gradle.kts @@ -1,7 +1,7 @@ import fr.xgouchet.buildsrc.settings.commonConfig plugins { - id("org.jetbrains.kotlin.jvm") + kotlin("jvm") id("com.github.ben-manes.versions") id("io.gitlab.arturbosch.detekt") id("org.jlleitschuh.gradle.ktlint") diff --git a/junit4/build.gradle.kts b/junit4/build.gradle.kts index 24dd521..7591ace 100644 --- a/junit4/build.gradle.kts +++ b/junit4/build.gradle.kts @@ -1,7 +1,7 @@ import fr.xgouchet.buildsrc.settings.commonConfig plugins { - id("org.jetbrains.kotlin.jvm") + kotlin("jvm") id("com.github.ben-manes.versions") id("io.gitlab.arturbosch.detekt") id("org.jlleitschuh.gradle.ktlint") diff --git a/junit5/build.gradle.kts b/junit5/build.gradle.kts index aa788db..50d3d32 100644 --- a/junit5/build.gradle.kts +++ b/junit5/build.gradle.kts @@ -1,7 +1,7 @@ import fr.xgouchet.buildsrc.settings.commonConfig plugins { - id("org.jetbrains.kotlin.jvm") + kotlin("jvm") id("com.github.ben-manes.versions") id("io.gitlab.arturbosch.detekt") id("org.jlleitschuh.gradle.ktlint") diff --git a/jvm/build.gradle.kts b/jvm/build.gradle.kts index 84a3fe2..edabda7 100644 --- a/jvm/build.gradle.kts +++ b/jvm/build.gradle.kts @@ -1,7 +1,7 @@ import fr.xgouchet.buildsrc.settings.commonConfig plugins { - id("org.jetbrains.kotlin.jvm") + kotlin("jvm") id("com.github.ben-manes.versions") id("io.gitlab.arturbosch.detekt") id("org.jlleitschuh.gradle.ktlint") @@ -13,6 +13,7 @@ plugins { dependencies { implementation(project(":core")) + implementation(libs.kotlin) testImplementation(project(":inject")) testImplementation(project(":junit5")) diff --git a/semantics/build.gradle.kts b/semantics/build.gradle.kts index f71b6f5..d1a6649 100644 --- a/semantics/build.gradle.kts +++ b/semantics/build.gradle.kts @@ -1,7 +1,7 @@ import fr.xgouchet.buildsrc.settings.commonConfig plugins { - id("org.jetbrains.kotlin.jvm") + kotlin("jvm") id("com.github.ben-manes.versions") id("io.gitlab.arturbosch.detekt") id("org.jlleitschuh.gradle.ktlint") @@ -13,6 +13,7 @@ plugins { dependencies { implementation(project(":core")) + implementation(libs.kotlin) testImplementation(project(":inject")) testImplementation(project(":junit5")) diff --git a/spek/build.gradle.kts b/spek/build.gradle.kts index 7f5c9e8..89aa2db 100644 --- a/spek/build.gradle.kts +++ b/spek/build.gradle.kts @@ -1,7 +1,7 @@ import fr.xgouchet.buildsrc.settings.commonConfig plugins { - id("org.jetbrains.kotlin.jvm") + kotlin("jvm") id("com.github.ben-manes.versions") id("io.gitlab.arturbosch.detekt") id("org.jlleitschuh.gradle.ktlint") From 377a17a00f803fe7c51ea14db79055dd709eb781 Mon Sep 17 00:00:00 2001 From: Xavier Gouchet Date: Tue, 3 Oct 2023 18:53:41 +0200 Subject: [PATCH 2/5] Cleanup unused parameter --- .../elmyr/spek/ForgeLifecycleListenerTest.kt | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/spek/src/test/kotlin/fr/xgouchet/elmyr/spek/ForgeLifecycleListenerTest.kt b/spek/src/test/kotlin/fr/xgouchet/elmyr/spek/ForgeLifecycleListenerTest.kt index 5605064..1b02c5e 100644 --- a/spek/src/test/kotlin/fr/xgouchet/elmyr/spek/ForgeLifecycleListenerTest.kt +++ b/spek/src/test/kotlin/fr/xgouchet/elmyr/spek/ForgeLifecycleListenerTest.kt @@ -109,9 +109,7 @@ internal class ForgeLifecycleListenerTest { } @Test - fun `ignore group without id`( - forge: Forge - ) { + fun `ignore group without id`() { // Given val group = mock() @@ -123,9 +121,7 @@ internal class ForgeLifecycleListenerTest { } @Test - fun `ignore group with invalid id`( - forge: Forge - ) { + fun `ignore group with invalid id`() { // Given val group = MockGroupScope(Date(), null) @@ -203,9 +199,7 @@ internal class ForgeLifecycleListenerTest { } @Test - fun `use provided seed on group start with untyped id`( - forge: Forge - ) { + fun `use provided seed on group start with untyped id`() { // Given val group = MockGroupScope(MockId(fakeGroupName), null) From 4c0cc6b716faaa73e813a16f913ea066d7596f7e Mon Sep 17 00:00:00 2001 From: Xavier Gouchet Date: Tue, 3 Oct 2023 18:54:03 +0200 Subject: [PATCH 3/5] Ensure configurator is instantiated with 0 param constructor --- .../main/kotlin/fr/xgouchet/elmyr/junit5/ForgeExtension.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/junit5/src/main/kotlin/fr/xgouchet/elmyr/junit5/ForgeExtension.kt b/junit5/src/main/kotlin/fr/xgouchet/elmyr/junit5/ForgeExtension.kt index 6174c40..32d44aa 100644 --- a/junit5/src/main/kotlin/fr/xgouchet/elmyr/junit5/ForgeExtension.kt +++ b/junit5/src/main/kotlin/fr/xgouchet/elmyr/junit5/ForgeExtension.kt @@ -237,7 +237,10 @@ class ForgeExtension : if (it.value.java == ForgeConfigurator.NoOp.javaClass) { ForgeConfigurator.NoOp } else { - it.value.java.newInstance() + val constructor = it.value.java.constructors.firstOrNull { + it.parameterCount == 0 + } + constructor?.newInstance() as? ForgeConfigurator ?: ForgeConfigurator.NoOp } } } From ef5191355edd9452df01b0ffe4c8c87d01f41067 Mon Sep 17 00:00:00 2001 From: Xavier Gouchet Date: Tue, 3 Oct 2023 18:55:02 +0200 Subject: [PATCH 4/5] fixup! Cleanup gradle and Kotlin config --- .../fr/xgouchet/buildsrc/settings/KotlinConfig.kt | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/buildSrc/src/main/kotlin/fr/xgouchet/buildsrc/settings/KotlinConfig.kt b/buildSrc/src/main/kotlin/fr/xgouchet/buildsrc/settings/KotlinConfig.kt index 4560d98..58c36d9 100644 --- a/buildSrc/src/main/kotlin/fr/xgouchet/buildsrc/settings/KotlinConfig.kt +++ b/buildSrc/src/main/kotlin/fr/xgouchet/buildsrc/settings/KotlinConfig.kt @@ -1,14 +1,18 @@ package fr.xgouchet.buildsrc.settings -import org.gradle.api.JavaVersion import org.gradle.api.Project +import org.jetbrains.kotlin.gradle.dsl.JvmTarget +import org.jetbrains.kotlin.gradle.dsl.KotlinProjectExtension import org.jetbrains.kotlin.gradle.tasks.KotlinCompile fun Project.kotlinConfig() { - - tasks.withType(KotlinCompile::class.java) { - kotlinOptions { - jvmTarget = JavaVersion.VERSION_17.toString() + tasks.withType(KotlinCompile::class.java).forEach { + it.compilerOptions { + jvmTarget.set(JvmTarget.JVM_17) } } + + extensions.findByType(KotlinProjectExtension::class.java)?.apply { + jvmToolchain(17) + } } From 851c68410e44c59cfbf1bf3c27658bd6c04d637b Mon Sep 17 00:00:00 2001 From: Xavier Gouchet Date: Tue, 3 Oct 2023 18:58:23 +0200 Subject: [PATCH 5/5] Create KSP implementation --- .idea/gradle.xml | 1 + gradle/libs.versions.toml | 2 + ksp/build.gradle.kts | 34 ++ .../xgouchet/elmyr/ksp/ForgerableProcessor.kt | 293 +++++++++++ .../elmyr/ksp/ForgerableProcessorProvider.kt | 17 + ...ols.ksp.processing.SymbolProcessorProvider | 1 + .../ksp/ForgerableProcessorProviderTest.kt | 457 ++++++++++++++++++ settings.gradle.kts | 1 + 8 files changed, 806 insertions(+) create mode 100644 ksp/build.gradle.kts create mode 100644 ksp/src/main/kotlin/fr/xgouchet/elmyr/ksp/ForgerableProcessor.kt create mode 100644 ksp/src/main/kotlin/fr/xgouchet/elmyr/ksp/ForgerableProcessorProvider.kt create mode 100644 ksp/src/main/resources/META-INF/services/com.google.devtools.ksp.processing.SymbolProcessorProvider create mode 100644 ksp/src/test/kotlin/fr/xgouchet/elmyr/ksp/ForgerableProcessorProviderTest.kt diff --git a/.idea/gradle.xml b/.idea/gradle.xml index 0df879f..98f6939 100644 --- a/.idea/gradle.xml +++ b/.idea/gradle.xml @@ -28,6 +28,7 @@