Skip to content

Commit

Permalink
Merge pull request #19812 from glefloch/fix/18166
Browse files Browse the repository at this point in the history
Do not propagate java compiler argument in kotlin compilation provider
  • Loading branch information
glefloch authored Sep 1, 2021
2 parents ca4c507 + d0d2d57 commit 5c9db47
Show file tree
Hide file tree
Showing 7 changed files with 99 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ public class QuarkusDev extends QuarkusTask {

private List<String> compilerArgs = new LinkedList<>();

private boolean shouldPropagateJavaCompilerArgs = true;

@Inject
public QuarkusDev() {
super("Development mode: enables hot deployment with background compilation");
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -571,4 +573,8 @@ private void addToClassPaths(GradleDevModeLauncher.Builder classPathManifest, Fi
classPathManifest.classpathEntry(file);
}
}

public void shouldPropagateJavaCompilerArgs(boolean shouldPropagateJavaCompilerArgs) {
this.shouldPropagateJavaCompilerArgs = shouldPropagateJavaCompilerArgs;
}
}
Original file line number Diff line number Diff line change
@@ -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'
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
kotlinVersion=1.5.30

quarkusPlatformArtifactId=quarkus-bom
quarkusPlatformGroupId=io.quarkus
Original file line number Diff line number Diff line change
@@ -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'
Original file line number Diff line number Diff line change
@@ -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"
}
}
Original file line number Diff line number Diff line change
@@ -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);
}
}

0 comments on commit 5c9db47

Please sign in to comment.