diff --git a/devtools/gradle/src/main/java/io/quarkus/gradle/QuarkusPlugin.java b/devtools/gradle/src/main/java/io/quarkus/gradle/QuarkusPlugin.java index 0130082fdd675..fb1b6b8618a33 100644 --- a/devtools/gradle/src/main/java/io/quarkus/gradle/QuarkusPlugin.java +++ b/devtools/gradle/src/main/java/io/quarkus/gradle/QuarkusPlugin.java @@ -121,7 +121,7 @@ private void registerTasks(Project project, QuarkusPluginExtension quarkusExt) { Task quarkusBuild = tasks.create(QUARKUS_BUILD_TASK_NAME, QuarkusBuild.class); quarkusBuild.dependsOn(quarkusGenerateCode); - Task quarkusDev = tasks.create(QUARKUS_DEV_TASK_NAME, QuarkusDev.class); + QuarkusDev quarkusDev = tasks.create(QUARKUS_DEV_TASK_NAME, QuarkusDev.class); Task quarkusRemoteDev = tasks.create(QUARKUS_REMOTE_DEV_TASK_NAME, QuarkusRemoteDev.class); Task quarkusTest = tasks.create(QUARKUS_TEST_TASK_NAME, QuarkusTest.class); tasks.create(QUARKUS_TEST_CONFIG_TASK_NAME, QuarkusTestConfig.class); @@ -233,6 +233,7 @@ public void execute(Task test) { }); project.getPlugins().withId("org.jetbrains.kotlin.jvm", plugin -> { + quarkusDev.shouldPropagateJavaCompilerArgs(false); tasks.getByName("compileKotlin").dependsOn(quarkusGenerateCode); tasks.getByName("compileTestKotlin").dependsOn(quarkusGenerateCodeTests); }); diff --git a/devtools/gradle/src/main/java/io/quarkus/gradle/tasks/QuarkusDev.java b/devtools/gradle/src/main/java/io/quarkus/gradle/tasks/QuarkusDev.java index 3c050bb07db45..f28c8bca01aa5 100644 --- a/devtools/gradle/src/main/java/io/quarkus/gradle/tasks/QuarkusDev.java +++ b/devtools/gradle/src/main/java/io/quarkus/gradle/tasks/QuarkusDev.java @@ -74,6 +74,8 @@ public class QuarkusDev extends QuarkusTask { private List compilerArgs = new LinkedList<>(); + private boolean shouldPropagateJavaCompilerArgs = true; + @Inject public QuarkusDev() { super("Development mode: enables hot deployment with background compilation"); @@ -303,7 +305,7 @@ private QuarkusDevModeLauncher newLauncher() throws Exception { builder.targetJavaVersion(javaPluginConvention.getTargetCompatibility().toString()); } - if (getCompilerArgs().isEmpty()) { + if (getCompilerArgs().isEmpty() && shouldPropagateJavaCompilerArgs) { getJavaCompileTask() .map(compileTask -> compileTask.getOptions().getCompilerArgs()) .ifPresent(builder::compilerOptions); @@ -571,4 +573,8 @@ private void addToClassPaths(GradleDevModeLauncher.Builder classPathManifest, Fi classPathManifest.classpathEntry(file); } } + + public void shouldPropagateJavaCompilerArgs(boolean shouldPropagateJavaCompilerArgs) { + this.shouldPropagateJavaCompilerArgs = shouldPropagateJavaCompilerArgs; + } } diff --git a/integration-tests/gradle/src/main/resources/basic-kotlin-application-project/build.gradle b/integration-tests/gradle/src/main/resources/basic-kotlin-application-project/build.gradle new file mode 100644 index 0000000000000..6a3efd26bb298 --- /dev/null +++ b/integration-tests/gradle/src/main/resources/basic-kotlin-application-project/build.gradle @@ -0,0 +1,26 @@ +plugins { + id 'org.jetbrains.kotlin.jvm' + id 'io.quarkus' +} + +repositories { + if (System.properties.containsKey('maven.repo.local')) { + maven { + url System.properties.get('maven.repo.local') + } + } else { + mavenLocal() + } + mavenCentral() +} + +dependencies { + implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8' + implementation enforcedPlatform("${quarkusPlatformGroupId}:${quarkusPlatformArtifactId}:${quarkusPlatformVersion}") + implementation 'io.quarkus:quarkus-resteasy' + implementation 'io.quarkus:quarkus-kotlin' +} + +compileJava { + options.compilerArgs << '-parameters' +} diff --git a/integration-tests/gradle/src/main/resources/basic-kotlin-application-project/gradle.properties b/integration-tests/gradle/src/main/resources/basic-kotlin-application-project/gradle.properties new file mode 100644 index 0000000000000..15d78eaf882e5 --- /dev/null +++ b/integration-tests/gradle/src/main/resources/basic-kotlin-application-project/gradle.properties @@ -0,0 +1,4 @@ +kotlinVersion=1.5.30 + +quarkusPlatformArtifactId=quarkus-bom +quarkusPlatformGroupId=io.quarkus diff --git a/integration-tests/gradle/src/main/resources/basic-kotlin-application-project/settings.gradle b/integration-tests/gradle/src/main/resources/basic-kotlin-application-project/settings.gradle new file mode 100644 index 0000000000000..fb99dc799e1e2 --- /dev/null +++ b/integration-tests/gradle/src/main/resources/basic-kotlin-application-project/settings.gradle @@ -0,0 +1,18 @@ +pluginManagement { + repositories { + if (System.properties.containsKey('maven.repo.local')) { + maven { + url System.properties.get('maven.repo.local') + } + } else { + mavenLocal() + } + mavenCentral() + gradlePluginPortal() + } + plugins { + id 'io.quarkus' version "${quarkusPluginVersion}" + id 'org.jetbrains.kotlin.jvm' version "${kotlinVersion}" + } +} +rootProject.name='code-with-quarkus' diff --git a/integration-tests/gradle/src/main/resources/basic-kotlin-application-project/src/main/kotlin/org/acme/GreetingResource.kt b/integration-tests/gradle/src/main/resources/basic-kotlin-application-project/src/main/kotlin/org/acme/GreetingResource.kt new file mode 100644 index 0000000000000..7634ba1421904 --- /dev/null +++ b/integration-tests/gradle/src/main/resources/basic-kotlin-application-project/src/main/kotlin/org/acme/GreetingResource.kt @@ -0,0 +1,16 @@ +package org.acme + +import javax.ws.rs.GET +import javax.ws.rs.Path +import javax.ws.rs.Produces +import javax.ws.rs.core.MediaType + +@Path("/hello") +class GreetingResource { + + @GET + @Produces(MediaType.TEXT_PLAIN) + fun hello(): String { + return "hello" + } +} \ No newline at end of file diff --git a/integration-tests/gradle/src/test/java/io/quarkus/gradle/devmode/BasicKotlinApplicationModuleDevModeTest.java b/integration-tests/gradle/src/test/java/io/quarkus/gradle/devmode/BasicKotlinApplicationModuleDevModeTest.java new file mode 100644 index 0000000000000..a98c32842b24b --- /dev/null +++ b/integration-tests/gradle/src/test/java/io/quarkus/gradle/devmode/BasicKotlinApplicationModuleDevModeTest.java @@ -0,0 +1,26 @@ +package io.quarkus.gradle.devmode; + +import static org.assertj.core.api.Assertions.assertThat; + +import java.util.UUID; + +import com.google.common.collect.ImmutableMap; + +public class BasicKotlinApplicationModuleDevModeTest extends QuarkusDevGradleTestBase { + + @Override + protected String projectDirectoryName() { + return "basic-kotlin-application-project"; + } + + @Override + protected void testDevMode() throws Exception { + assertThat(getHttpResponse("/hello")).contains("hello"); + + final String uuid = UUID.randomUUID().toString(); + replace("src/main/kotlin/org/acme/GreetingResource.kt", + ImmutableMap.of("return \"hello\"", "return \"" + uuid + "\"")); + + assertUpdatedResponseContains("/hello", uuid); + } +}