Skip to content

Commit

Permalink
Fix codestart for kotlin serialization
Browse files Browse the repository at this point in the history
  • Loading branch information
ia3andy committed Oct 24, 2023
1 parent d5602cb commit 1751af3
Show file tree
Hide file tree
Showing 7 changed files with 363 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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}
Expand Down
Original file line number Diff line number Diff line change
@@ -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}
Expand Down
Original file line number Diff line number Diff line change
@@ -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')}
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<properties>
Expand Down Expand Up @@ -44,6 +45,9 @@
<!-- Soon to be replaced by plugin that will pre-configure all necessary annotations -->
<compilerPlugins>
<plugin>all-open</plugin>
{#if kotlinSerialization}
<plugin>kotlinx-serialization</plugin>
{/if}
</compilerPlugins>

<pluginOptions>
Expand All @@ -67,6 +71,13 @@
<artifactId>kotlin-maven-allopen</artifactId>
<version>$\{kotlin.version}</version>
</dependency>
{#if kotlinSerialization}
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-serialization</artifactId>
<version>$\{kotlin.version}</version>
</dependency>
{/if}
</dependencies>
</plugin>
</plugins>
Expand Down
Original file line number Diff line number Diff line change
@@ -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("<plugin>kotlinx-serialization</plugin>"))
.satisfies(checkContains("<artifactId>kotlin-maven-serialization</artifactId>"));
}

@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();
}
}
Original file line number Diff line number Diff line change
@@ -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
}
Original file line number Diff line number Diff line change
@@ -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<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")
}

tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
kotlinOptions.jvmTarget = JavaVersion.VERSION_11.toString()
kotlinOptions.javaParameters = true
}
Loading

0 comments on commit 1751af3

Please sign in to comment.