From 0f66c20647ae81e5a9625134fddb279ba1629d93 Mon Sep 17 00:00:00 2001 From: stefankoppier Date: Wed, 31 Jul 2024 17:20:23 +0200 Subject: [PATCH 1/6] 2.0.20-RC support --- .github/workflows/compatibility-test.yml | 2 +- .../kotlin/tech/mappie/MappieGradlePlugin.kt | 6 ++- .../.gitignore | 0 .../build.gradle.kts | 2 +- .../gradle/gradle-daemon-jvm.properties | 0 .../gradle/wrapper/gradle-wrapper.jar | Bin .../gradle/wrapper/gradle-wrapper.properties | 0 .../gradlew | 0 .../gradlew.bat | 0 .../settings.gradle.kts | 2 +- .../src/main/kotlin/EnumMapping.kt | 11 ++++++ .../src/main/kotlin/GeneratedEnumMapper.kt | 15 ++++++++ .../src/main/kotlin/ObjectMapper.kt | 36 ++++++++++++++++++ .../src/test/kotlin/EnumMapperTest.kt | 21 ++++++++++ .../kotlin/NestedGeneratedEnumMapperTest.kt | 22 +++++++++++ .../src/test/kotlin/ObjectMapperTest.kt | 13 +++++++ 16 files changed, 126 insertions(+), 4 deletions(-) rename test/{kotlin-2.0.20-Beta1 => kotlin-2.0.20-RC}/.gitignore (100%) rename test/{kotlin-2.0.20-Beta1 => kotlin-2.0.20-RC}/build.gradle.kts (86%) rename test/{kotlin-2.0.20-Beta1 => kotlin-2.0.20-RC}/gradle/gradle-daemon-jvm.properties (100%) rename test/{kotlin-2.0.20-Beta1 => kotlin-2.0.20-RC}/gradle/wrapper/gradle-wrapper.jar (100%) rename test/{kotlin-2.0.20-Beta1 => kotlin-2.0.20-RC}/gradle/wrapper/gradle-wrapper.properties (100%) rename test/{kotlin-2.0.20-Beta1 => kotlin-2.0.20-RC}/gradlew (100%) mode change 100755 => 100644 rename test/{kotlin-2.0.20-Beta1 => kotlin-2.0.20-RC}/gradlew.bat (100%) rename test/{kotlin-2.0.20-Beta1 => kotlin-2.0.20-RC}/settings.gradle.kts (79%) create mode 100644 test/kotlin-2.0.20-RC/src/main/kotlin/EnumMapping.kt create mode 100644 test/kotlin-2.0.20-RC/src/main/kotlin/GeneratedEnumMapper.kt create mode 100644 test/kotlin-2.0.20-RC/src/main/kotlin/ObjectMapper.kt create mode 100644 test/kotlin-2.0.20-RC/src/test/kotlin/EnumMapperTest.kt create mode 100644 test/kotlin-2.0.20-RC/src/test/kotlin/NestedGeneratedEnumMapperTest.kt create mode 100644 test/kotlin-2.0.20-RC/src/test/kotlin/ObjectMapperTest.kt diff --git a/.github/workflows/compatibility-test.yml b/.github/workflows/compatibility-test.yml index 54058995..afe5fed3 100644 --- a/.github/workflows/compatibility-test.yml +++ b/.github/workflows/compatibility-test.yml @@ -16,7 +16,7 @@ jobs: compatibility: strategy: matrix: - version: ['kotlin-1.9.24', 'kotlin-2.0.0', 'kotlin-2.0.20-Beta1', 'java'] + version: ['kotlin-1.9.24', 'kotlin-2.0.0', 'kotlin-2.0.20-RC', 'java'] name: Compatibility permissions: pull-requests: read diff --git a/gradle-plugin/src/main/kotlin/tech/mappie/MappieGradlePlugin.kt b/gradle-plugin/src/main/kotlin/tech/mappie/MappieGradlePlugin.kt index cf2ac36d..c827f9b1 100644 --- a/gradle-plugin/src/main/kotlin/tech/mappie/MappieGradlePlugin.kt +++ b/gradle-plugin/src/main/kotlin/tech/mappie/MappieGradlePlugin.kt @@ -74,6 +74,10 @@ class MappieGradlePlugin : KotlinCompilerPluginSupportPlugin { private companion object { private const val KOTLIN_GRADLE_PLUGIN_NAME = "kotlin-gradle-plugin" - private val SUPPORTED_KOTLIN_VERSIONS = listOf("1.9.24", "2.0.0", "2.0.20-Beta1") + private val SUPPORTED_KOTLIN_VERSIONS = listOf( + "1.9.24", + "2.0.0", + "2.0.20-RC", + ) } } \ No newline at end of file diff --git a/test/kotlin-2.0.20-Beta1/.gitignore b/test/kotlin-2.0.20-RC/.gitignore similarity index 100% rename from test/kotlin-2.0.20-Beta1/.gitignore rename to test/kotlin-2.0.20-RC/.gitignore diff --git a/test/kotlin-2.0.20-Beta1/build.gradle.kts b/test/kotlin-2.0.20-RC/build.gradle.kts similarity index 86% rename from test/kotlin-2.0.20-Beta1/build.gradle.kts rename to test/kotlin-2.0.20-RC/build.gradle.kts index 6ec0df3c..195cb99d 100644 --- a/test/kotlin-2.0.20-Beta1/build.gradle.kts +++ b/test/kotlin-2.0.20-RC/build.gradle.kts @@ -1,5 +1,5 @@ plugins { - id("org.jetbrains.kotlin.jvm") version "2.0.20-Beta1" + id("org.jetbrains.kotlin.jvm") version "2.0.20-RC" id("tech.mappie.plugin") version "+" } diff --git a/test/kotlin-2.0.20-Beta1/gradle/gradle-daemon-jvm.properties b/test/kotlin-2.0.20-RC/gradle/gradle-daemon-jvm.properties similarity index 100% rename from test/kotlin-2.0.20-Beta1/gradle/gradle-daemon-jvm.properties rename to test/kotlin-2.0.20-RC/gradle/gradle-daemon-jvm.properties diff --git a/test/kotlin-2.0.20-Beta1/gradle/wrapper/gradle-wrapper.jar b/test/kotlin-2.0.20-RC/gradle/wrapper/gradle-wrapper.jar similarity index 100% rename from test/kotlin-2.0.20-Beta1/gradle/wrapper/gradle-wrapper.jar rename to test/kotlin-2.0.20-RC/gradle/wrapper/gradle-wrapper.jar diff --git a/test/kotlin-2.0.20-Beta1/gradle/wrapper/gradle-wrapper.properties b/test/kotlin-2.0.20-RC/gradle/wrapper/gradle-wrapper.properties similarity index 100% rename from test/kotlin-2.0.20-Beta1/gradle/wrapper/gradle-wrapper.properties rename to test/kotlin-2.0.20-RC/gradle/wrapper/gradle-wrapper.properties diff --git a/test/kotlin-2.0.20-Beta1/gradlew b/test/kotlin-2.0.20-RC/gradlew old mode 100755 new mode 100644 similarity index 100% rename from test/kotlin-2.0.20-Beta1/gradlew rename to test/kotlin-2.0.20-RC/gradlew diff --git a/test/kotlin-2.0.20-Beta1/gradlew.bat b/test/kotlin-2.0.20-RC/gradlew.bat similarity index 100% rename from test/kotlin-2.0.20-Beta1/gradlew.bat rename to test/kotlin-2.0.20-RC/gradlew.bat diff --git a/test/kotlin-2.0.20-Beta1/settings.gradle.kts b/test/kotlin-2.0.20-RC/settings.gradle.kts similarity index 79% rename from test/kotlin-2.0.20-Beta1/settings.gradle.kts rename to test/kotlin-2.0.20-RC/settings.gradle.kts index 2dbf85e3..846d7d07 100644 --- a/test/kotlin-2.0.20-Beta1/settings.gradle.kts +++ b/test/kotlin-2.0.20-RC/settings.gradle.kts @@ -1,4 +1,4 @@ -rootProject.name = "mappie-test-kotlin-2.0.20-Beta1" +rootProject.name = "mappie-test-kotlin-2.0.20-RC" pluginManagement { repositories { diff --git a/test/kotlin-2.0.20-RC/src/main/kotlin/EnumMapping.kt b/test/kotlin-2.0.20-RC/src/main/kotlin/EnumMapping.kt new file mode 100644 index 00000000..69903de9 --- /dev/null +++ b/test/kotlin-2.0.20-RC/src/main/kotlin/EnumMapping.kt @@ -0,0 +1,11 @@ +import tech.mappie.api.EnumMappie + +enum class InputEnum { + A, B, C, D; +} + +enum class OutputEnum { + A, B, C, D, E; +} + +object EnumMapper : EnumMappie() \ No newline at end of file diff --git a/test/kotlin-2.0.20-RC/src/main/kotlin/GeneratedEnumMapper.kt b/test/kotlin-2.0.20-RC/src/main/kotlin/GeneratedEnumMapper.kt new file mode 100644 index 00000000..98f428ab --- /dev/null +++ b/test/kotlin-2.0.20-RC/src/main/kotlin/GeneratedEnumMapper.kt @@ -0,0 +1,15 @@ +import tech.mappie.api.ObjectMappie + +data class NestedGeneratedInputObject(val enum: InputEnumTwo) + +enum class InputEnumTwo { + A, B, C, D; +} + +data class NestedGeneratedOutputObject(val enum: OutputEnumTwo) + +enum class OutputEnumTwo { + A, B, C, D, E; +} + +object NestedGeneratedInputToOutputMapper : ObjectMappie() \ No newline at end of file diff --git a/test/kotlin-2.0.20-RC/src/main/kotlin/ObjectMapper.kt b/test/kotlin-2.0.20-RC/src/main/kotlin/ObjectMapper.kt new file mode 100644 index 00000000..01d865c0 --- /dev/null +++ b/test/kotlin-2.0.20-RC/src/main/kotlin/ObjectMapper.kt @@ -0,0 +1,36 @@ +import tech.mappie.api.ObjectMappie + +data class InputObject( + val name: String, + val age: Int, + val nested: NestedInput, +) + +data class NestedInput(val boolean: BooleanEnum) { + enum class BooleanEnum { TRUE, FALSE } +} + +data class OutputObject( + val name: String, + val age: Int, + val boolean: Boolean, +) + +object ObjectMapperWithoutVia : ObjectMappie() { + override fun map(from: InputObject) = mapping { + to::boolean fromProperty from.nested::boolean + } +} + +object ObjectMapper : ObjectMappie() { + override fun map(from: InputObject) = mapping { + to::boolean fromProperty from.nested::boolean via BooleanEnumToBooleanMapper + } +} + +object BooleanEnumToBooleanMapper : ObjectMappie() { + override fun map(from: NestedInput.BooleanEnum) = when (from) { + NestedInput.BooleanEnum.TRUE -> !false + NestedInput.BooleanEnum.FALSE -> !true + } +} diff --git a/test/kotlin-2.0.20-RC/src/test/kotlin/EnumMapperTest.kt b/test/kotlin-2.0.20-RC/src/test/kotlin/EnumMapperTest.kt new file mode 100644 index 00000000..b368d6b7 --- /dev/null +++ b/test/kotlin-2.0.20-RC/src/test/kotlin/EnumMapperTest.kt @@ -0,0 +1,21 @@ +import kotlin.test.Test +import kotlin.test.assertEquals + +class EnumMapperTest { + + private val mappings = listOf( + InputEnum.A to OutputEnum.A, + InputEnum.B to OutputEnum.B, + InputEnum.C to OutputEnum.C, + InputEnum.D to OutputEnum.D, + ) + + @Test + fun `map InputEnum to OutputEnum`() { + mappings.forEach { (input, expected) -> + assertEquals( + EnumMapper.map(input), expected + ) + } + } +} \ No newline at end of file diff --git a/test/kotlin-2.0.20-RC/src/test/kotlin/NestedGeneratedEnumMapperTest.kt b/test/kotlin-2.0.20-RC/src/test/kotlin/NestedGeneratedEnumMapperTest.kt new file mode 100644 index 00000000..a0b8d9be --- /dev/null +++ b/test/kotlin-2.0.20-RC/src/test/kotlin/NestedGeneratedEnumMapperTest.kt @@ -0,0 +1,22 @@ +import kotlin.test.Test +import kotlin.test.assertEquals + +class NestedGeneratedEnumMapperTest { + + private val mappings = listOf( + InputEnumTwo.A to OutputEnumTwo.A, + InputEnumTwo.B to OutputEnumTwo.B, + InputEnumTwo.C to OutputEnumTwo.C, + InputEnumTwo.D to OutputEnumTwo.D, + ) + + @Test + fun `map NestedGeneratedInputObject to NestedGeneratedOutputObject`() { + mappings.forEach { (input, expected) -> + assertEquals( + NestedGeneratedInputToOutputMapper.map(NestedGeneratedInputObject(input)), + NestedGeneratedOutputObject(expected) + ) + } + } +} diff --git a/test/kotlin-2.0.20-RC/src/test/kotlin/ObjectMapperTest.kt b/test/kotlin-2.0.20-RC/src/test/kotlin/ObjectMapperTest.kt new file mode 100644 index 00000000..38c9dcb4 --- /dev/null +++ b/test/kotlin-2.0.20-RC/src/test/kotlin/ObjectMapperTest.kt @@ -0,0 +1,13 @@ +import org.junit.jupiter.api.Test +import kotlin.test.assertEquals + +class ObjectMapperTest { + + @Test + fun `map using ObjectMapper`() { + assertEquals( + OutputObject("name", 22, true), + ObjectMapper.map(InputObject("name", 22, NestedInput(NestedInput.BooleanEnum.TRUE))) + ) + } +} \ No newline at end of file From 4f2ad7b8edf7c3e852d14fbbf17998b91663dc83 Mon Sep 17 00:00:00 2001 From: stefankoppier Date: Wed, 31 Jul 2024 17:23:23 +0200 Subject: [PATCH 2/6] 2.0.20-RC support --- test/kotlin-2.0.20-RC/gradlew | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 test/kotlin-2.0.20-RC/gradlew diff --git a/test/kotlin-2.0.20-RC/gradlew b/test/kotlin-2.0.20-RC/gradlew old mode 100644 new mode 100755 From e21a36237ca26e92f5cdf7ffeb3a423fe8ab202b Mon Sep 17 00:00:00 2001 From: stefankoppier Date: Wed, 31 Jul 2024 17:34:27 +0200 Subject: [PATCH 3/6] github actions refactor --- .github/workflows/build.yml | 1 + .github/workflows/compatibility-test.yml | 12 ------------ .../{website_build.yml => website-build.yml} | 0 3 files changed, 1 insertion(+), 12 deletions(-) rename .github/workflows/{website_build.yml => website-build.yml} (100%) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d18beb66..d9b8df32 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -15,6 +15,7 @@ on: jobs: build: + needs: compatibility name: Build and Analysis permissions: pull-requests: read diff --git a/.github/workflows/compatibility-test.yml b/.github/workflows/compatibility-test.yml index afe5fed3..5b0fb550 100644 --- a/.github/workflows/compatibility-test.yml +++ b/.github/workflows/compatibility-test.yml @@ -1,17 +1,5 @@ name: Compatibility Test -on: - push: - branches: - - main - paths: - - '**' - - '!website/**' - pull_request: - types: [opened, synchronize, reopened] - paths: - - '**' - - '!website/**' jobs: compatibility: strategy: diff --git a/.github/workflows/website_build.yml b/.github/workflows/website-build.yml similarity index 100% rename from .github/workflows/website_build.yml rename to .github/workflows/website-build.yml From 730c199d1953643ae0396e84f06d2255bc10b95b Mon Sep 17 00:00:00 2001 From: stefankoppier Date: Wed, 31 Jul 2024 17:36:07 +0200 Subject: [PATCH 4/6] github actions refactor --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d9b8df32..95beb505 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -15,11 +15,11 @@ on: jobs: build: - needs: compatibility name: Build and Analysis permissions: pull-requests: read runs-on: ubuntu-latest + needs: compatibility steps: - name: Checkout uses: actions/checkout@v4 From 6c8445a80850ec5fb99430adcce1ccbc0fe961bf Mon Sep 17 00:00:00 2001 From: stefankoppier Date: Wed, 31 Jul 2024 17:39:34 +0200 Subject: [PATCH 5/6] github actions refactor --- .github/workflows/build.yml | 1 - .github/workflows/compatibility-test.yml | 6 ++++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 95beb505..d18beb66 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -19,7 +19,6 @@ jobs: permissions: pull-requests: read runs-on: ubuntu-latest - needs: compatibility steps: - name: Checkout uses: actions/checkout@v4 diff --git a/.github/workflows/compatibility-test.yml b/.github/workflows/compatibility-test.yml index 5b0fb550..3ea92388 100644 --- a/.github/workflows/compatibility-test.yml +++ b/.github/workflows/compatibility-test.yml @@ -1,5 +1,11 @@ name: Compatibility Test +on: + workflow_run: + workflows: ["Build"] + types: + - requested + jobs: compatibility: strategy: From 4c67c53f2ecc6badc04e9b910fe642d0d8573da7 Mon Sep 17 00:00:00 2001 From: stefankoppier Date: Wed, 31 Jul 2024 17:40:55 +0200 Subject: [PATCH 6/6] Revert --- .github/workflows/compatibility-test.yml | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/.github/workflows/compatibility-test.yml b/.github/workflows/compatibility-test.yml index 3ea92388..afe5fed3 100644 --- a/.github/workflows/compatibility-test.yml +++ b/.github/workflows/compatibility-test.yml @@ -1,11 +1,17 @@ name: Compatibility Test on: - workflow_run: - workflows: ["Build"] - types: - - requested - + push: + branches: + - main + paths: + - '**' + - '!website/**' + pull_request: + types: [opened, synchronize, reopened] + paths: + - '**' + - '!website/**' jobs: compatibility: strategy: