diff --git a/independent-projects/tools/base-codestarts/src/main/resources/codestarts/quarkus/buildtool/gradle-kotlin-dsl/kotlin/build.tpl.qute.gradle.kts b/independent-projects/tools/base-codestarts/src/main/resources/codestarts/quarkus/buildtool/gradle-kotlin-dsl/kotlin/build.tpl.qute.gradle.kts index ac4043c53faed..ae190bc324039 100644 --- a/independent-projects/tools/base-codestarts/src/main/resources/codestarts/quarkus/buildtool/gradle-kotlin-dsl/kotlin/build.tpl.qute.gradle.kts +++ b/independent-projects/tools/base-codestarts/src/main/resources/codestarts/quarkus/buildtool/gradle-kotlin-dsl/kotlin/build.tpl.qute.gradle.kts @@ -1,8 +1,12 @@ +{#let kotlinSerialization = input.selected-extensions-ga.contains('io.quarkus:quarkus-resteasy-reactive-kotlin-serialization') or input.selected-extensions-ga.contains('io.quarkus:quarkus-rest-client-reactive-kotlin-serialization')} {#include build-layout} {#plugins} plugins { kotlin("jvm") version "{kotlin.version}" kotlin("plugin.allopen") version "{kotlin.version}" + {#if kotlinSerialization} + kotlin("plugin.serialization") version "{kotlin.version}" + {/if} id("{quarkus.gradle-plugin.id}") } {/plugins} diff --git a/independent-projects/tools/base-codestarts/src/main/resources/codestarts/quarkus/buildtool/gradle/kotlin/build.tpl.qute.gradle b/independent-projects/tools/base-codestarts/src/main/resources/codestarts/quarkus/buildtool/gradle/kotlin/build.tpl.qute.gradle index 84fbbd20f1242..617d9bcb5d63c 100644 --- a/independent-projects/tools/base-codestarts/src/main/resources/codestarts/quarkus/buildtool/gradle/kotlin/build.tpl.qute.gradle +++ b/independent-projects/tools/base-codestarts/src/main/resources/codestarts/quarkus/buildtool/gradle/kotlin/build.tpl.qute.gradle @@ -1,8 +1,12 @@ +{#let kotlinSerialization = input.selected-extensions-ga.contains('io.quarkus:quarkus-resteasy-reactive-kotlin-serialization') or input.selected-extensions-ga.contains('io.quarkus:quarkus-rest-client-reactive-kotlin-serialization')} {#include build-layout} {#plugins} plugins { id 'org.jetbrains.kotlin.jvm' version "{kotlin.version}" id "org.jetbrains.kotlin.plugin.allopen" version "{kotlin.version}" + {#if kotlinSerialization} + id 'org.jetbrains.kotlin.plugin.serialization' version "{kotlin.version}" + {/if} id '{quarkus.gradle-plugin.id}' } {/plugins} diff --git a/independent-projects/tools/base-codestarts/src/main/resources/codestarts/quarkus/buildtool/maven/kotlin/pom.tpl.qute.xml b/independent-projects/tools/base-codestarts/src/main/resources/codestarts/quarkus/buildtool/maven/kotlin/pom.tpl.qute.xml index 8ebaeba5f5e0b..5e75764f9d538 100644 --- a/independent-projects/tools/base-codestarts/src/main/resources/codestarts/quarkus/buildtool/maven/kotlin/pom.tpl.qute.xml +++ b/independent-projects/tools/base-codestarts/src/main/resources/codestarts/quarkus/buildtool/maven/kotlin/pom.tpl.qute.xml @@ -1,3 +1,4 @@ +{#let kotlinSerialization = input.selected-extensions-ga.contains('io.quarkus:quarkus-resteasy-reactive-kotlin-serialization') or input.selected-extensions-ga.contains('io.quarkus:quarkus-rest-client-reactive-kotlin-serialization')} @@ -44,6 +45,9 @@ all-open + {#if kotlinSerialization} + kotlinx-serialization + {/if} @@ -67,6 +71,13 @@ kotlin-maven-allopen $\{kotlin.version} + {#if kotlinSerialization} + + org.jetbrains.kotlin + kotlin-maven-serialization + $\{kotlin.version} + + {/if} diff --git a/integration-tests/devtools/src/test/java/io/quarkus/devtools/codestarts/quarkus/KotlinSerializationCodestartTest.java b/integration-tests/devtools/src/test/java/io/quarkus/devtools/codestarts/quarkus/KotlinSerializationCodestartTest.java new file mode 100644 index 0000000000000..1c481c354963a --- /dev/null +++ b/integration-tests/devtools/src/test/java/io/quarkus/devtools/codestarts/quarkus/KotlinSerializationCodestartTest.java @@ -0,0 +1,63 @@ +package io.quarkus.devtools.codestarts.quarkus; + +import static io.quarkus.devtools.codestarts.quarkus.QuarkusCodestartCatalog.Language.KOTLIN; +import static io.quarkus.devtools.testing.SnapshotTesting.checkContains; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; + +import io.quarkus.devtools.project.BuildTool; +import io.quarkus.devtools.testing.codestarts.QuarkusCodestartTest; +import io.quarkus.maven.dependency.ArtifactKey; + +public class KotlinSerializationCodestartTest { + @RegisterExtension + public static QuarkusCodestartTest codestartMavenTest = QuarkusCodestartTest.builder() + .extension(ArtifactKey.fromString("io.quarkus:quarkus-resteasy-reactive-kotlin-serialization")) + .languages(KOTLIN) + .buildTool(BuildTool.MAVEN) + .build(); + + @RegisterExtension + public static QuarkusCodestartTest codestartGradleTest = QuarkusCodestartTest.builder() + .extension(ArtifactKey.fromString("io.quarkus:quarkus-resteasy-reactive-kotlin-serialization")) + .languages(KOTLIN) + .buildTool(BuildTool.GRADLE) + .build(); + + @RegisterExtension + public static QuarkusCodestartTest codestartGradleKotlinTest = QuarkusCodestartTest.builder() + .extension(ArtifactKey.fromString("io.quarkus:quarkus-resteasy-reactive-kotlin-serialization")) + .languages(KOTLIN) + .buildTool(BuildTool.GRADLE_KOTLIN_DSL) + .build(); + + @Test + void testMavenContent() throws Throwable { + codestartMavenTest.assertThatGeneratedFileMatchSnapshot(KOTLIN, "pom.xml") + .satisfies(checkContains("kotlinx-serialization")) + .satisfies(checkContains("kotlin-maven-serialization")); + } + + @Test + void testGradleContent() throws Throwable { + codestartGradleTest.assertThatGeneratedFileMatchSnapshot(KOTLIN, "build.gradle") + .satisfies(checkContains("id 'org.jetbrains.kotlin.plugin.serialization' version ")); + } + + @Test + void testGradleKotlinContent() throws Throwable { + codestartGradleKotlinTest.assertThatGeneratedFileMatchSnapshot(KOTLIN, "build.gradle.kts") + .satisfies(checkContains("kotlin(\"plugin.serialization\") version ")); + } + + @Test + void buildAllProjectsMaven() throws Throwable { + codestartMavenTest.buildAllProjects(); + } + + @Test + void buildAllProjectsGradle() throws Throwable { + codestartGradleTest.buildAllProjects(); + } +} diff --git a/integration-tests/devtools/src/test/resources/__snapshots__/KotlinSerializationCodestartTest/testGradleContent/build.gradle b/integration-tests/devtools/src/test/resources/__snapshots__/KotlinSerializationCodestartTest/testGradleContent/build.gradle new file mode 100644 index 0000000000000..3f9d893cda2bc --- /dev/null +++ b/integration-tests/devtools/src/test/resources/__snapshots__/KotlinSerializationCodestartTest/testGradleContent/build.gradle @@ -0,0 +1,48 @@ +plugins { + id 'org.jetbrains.kotlin.jvm' version "1.4.28-MOCK" + id "org.jetbrains.kotlin.plugin.allopen" version "1.4.28-MOCK" + id 'org.jetbrains.kotlin.plugin.serialization' version "1.4.28-MOCK" + id 'io.quarkus' +} + +repositories { + mavenCentral() + mavenLocal() +} + +dependencies { + implementation enforcedPlatform("${quarkusPlatformGroupId}:${quarkusPlatformArtifactId}:${quarkusPlatformVersion}") + implementation 'io.quarkus:quarkus-resteasy-reactive-kotlin-serialization' + implementation 'io.quarkus:quarkus-kotlin' + implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8' + implementation 'io.quarkus:quarkus-arc' + implementation 'io.quarkus:quarkus-resteasy-reactive' + testImplementation 'io.quarkus:quarkus-junit5' + testImplementation 'io.rest-assured:rest-assured' +} + +group 'org.test' +version '1.0.0-codestart' + +java { + sourceCompatibility = JavaVersion.VERSION_11 + targetCompatibility = JavaVersion.VERSION_11 +} + +test { + systemProperty "java.util.logging.manager", "org.jboss.logmanager.LogManager" +} +allOpen { + annotation("jakarta.ws.rs.Path") + annotation("jakarta.enterprise.context.ApplicationScoped") + annotation("io.quarkus.test.junit.QuarkusTest") +} + +compileKotlin { + kotlinOptions.jvmTarget = JavaVersion.VERSION_11 + kotlinOptions.javaParameters = true +} + +compileTestKotlin { + kotlinOptions.jvmTarget = JavaVersion.VERSION_11 +} diff --git a/integration-tests/devtools/src/test/resources/__snapshots__/KotlinSerializationCodestartTest/testGradleKotlinContent/build.gradle.kts b/integration-tests/devtools/src/test/resources/__snapshots__/KotlinSerializationCodestartTest/testGradleKotlinContent/build.gradle.kts new file mode 100644 index 0000000000000..31266fea135b0 --- /dev/null +++ b/integration-tests/devtools/src/test/resources/__snapshots__/KotlinSerializationCodestartTest/testGradleKotlinContent/build.gradle.kts @@ -0,0 +1,48 @@ +plugins { + kotlin("jvm") version "1.4.28-MOCK" + kotlin("plugin.allopen") version "1.4.28-MOCK" + kotlin("plugin.serialization") version "1.4.28-MOCK" + id("io.quarkus") +} + +repositories { + mavenCentral() + mavenLocal() +} + +val quarkusPlatformGroupId: String by project +val quarkusPlatformArtifactId: String by project +val quarkusPlatformVersion: String by project + +dependencies { + implementation(enforcedPlatform("${quarkusPlatformGroupId}:${quarkusPlatformArtifactId}:${quarkusPlatformVersion}")) + implementation("io.quarkus:quarkus-resteasy-reactive-kotlin-serialization") + implementation("io.quarkus:quarkus-kotlin") + implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8") + implementation("io.quarkus:quarkus-arc") + implementation("io.quarkus:quarkus-resteasy-reactive") + testImplementation("io.quarkus:quarkus-junit5") + testImplementation("io.rest-assured:rest-assured") +} + +group = "org.test" +version = "1.0.0-codestart" + +java { + sourceCompatibility = JavaVersion.VERSION_11 + targetCompatibility = JavaVersion.VERSION_11 +} + +tasks.withType { + systemProperty("java.util.logging.manager", "org.jboss.logmanager.LogManager") +} +allOpen { + annotation("jakarta.ws.rs.Path") + annotation("jakarta.enterprise.context.ApplicationScoped") + annotation("io.quarkus.test.junit.QuarkusTest") +} + +tasks.withType { + kotlinOptions.jvmTarget = JavaVersion.VERSION_11.toString() + kotlinOptions.javaParameters = true +} diff --git a/integration-tests/devtools/src/test/resources/__snapshots__/KotlinSerializationCodestartTest/testMavenContent/pom.xml b/integration-tests/devtools/src/test/resources/__snapshots__/KotlinSerializationCodestartTest/testMavenContent/pom.xml new file mode 100644 index 0000000000000..a4504b965ed60 --- /dev/null +++ b/integration-tests/devtools/src/test/resources/__snapshots__/KotlinSerializationCodestartTest/testMavenContent/pom.xml @@ -0,0 +1,185 @@ + + + 4.0.0 + org.test + test-codestart + 1.0.0-codestart + + 3.8.1-MOCK + 1.4.28-MOCK + 11 + UTF-8 + UTF-8 + quarkus-mock-bom + io.quarkus + 999-MOCK + true + 3.0.0-MOCK + + + + + ${quarkus.platform.group-id} + ${quarkus.platform.artifact-id} + ${quarkus.platform.version} + pom + import + + + + + + io.quarkus + quarkus-resteasy-reactive-kotlin-serialization + + + io.quarkus + quarkus-kotlin + + + io.quarkus + quarkus-arc + + + io.quarkus + quarkus-resteasy-reactive + + + io.quarkus + quarkus-junit5 + test + + + io.rest-assured + rest-assured + test + + + org.jetbrains.kotlin + kotlin-stdlib-jdk8 + + + io.rest-assured + kotlin-extensions + test + + + + src/main/kotlin + src/test/kotlin + + + ${quarkus.platform.group-id} + quarkus-mock-maven-plugin + ${quarkus.platform.version} + true + + + + build + generate-code + generate-code-tests + + + + + + maven-compiler-plugin + ${compiler-plugin.version} + + + -parameters + + + + + maven-surefire-plugin + ${surefire-plugin.version} + + + org.jboss.logmanager.LogManager + ${maven.home} + + + + + maven-failsafe-plugin + ${surefire-plugin.version} + + + + integration-test + verify + + + + ${project.build.directory}/${project.build.finalName}-runner + org.jboss.logmanager.LogManager + ${maven.home} + + + + + + + org.jetbrains.kotlin + kotlin-maven-plugin + ${kotlin.version} + + + compile + + compile + + + + test-compile + + test-compile + + + + + + org.jetbrains.kotlin + kotlin-maven-allopen + ${kotlin.version} + + + org.jetbrains.kotlin + kotlin-maven-serialization + ${kotlin.version} + + + + true + 11 + + all-open + kotlinx-serialization + + + + + + + + + + + + + native + + + native + + + + false + native + + + +