From c5d5eaf6b810e5be31671c8883d34a1cd957b8fa Mon Sep 17 00:00:00 2001 From: Gavin Ray Date: Sun, 17 Jul 2022 20:45:25 -0400 Subject: [PATCH] Actually make Kotlin 1.7 work, for really-reals. --- bom/application/pom.xml | 2 +- build-parent/pom.xml | 4 +- devtools/gradle/gradle-model/build.gradle | 3 +- .../GradleApplicationModelBuilder.java | 41 +++++++++++++++---- devtools/gradle/gradle.properties | 3 +- independent-projects/arc/tests/pom.xml | 2 +- 6 files changed, 41 insertions(+), 14 deletions(-) diff --git a/bom/application/pom.xml b/bom/application/pom.xml index fbbf4e3f737e9..fad4e8dcd6f13 100644 --- a/bom/application/pom.xml +++ b/bom/application/pom.xml @@ -148,7 +148,7 @@ 3.11.0 2.11.2 1.4.2 - 1.6.21 + 1.7.10 1.6.4 1.3.3 5.12.3 diff --git a/build-parent/pom.xml b/build-parent/pom.xml index 264d4a5fa98d5..2100206b44b7d 100644 --- a/build-parent/pom.xml +++ b/build-parent/pom.xml @@ -20,8 +20,8 @@ 3.8.1 - 1.6.21 - 1.6.21 + 1.7.10 + 1.7.10 2.13.8 4.7.1 diff --git a/devtools/gradle/gradle-model/build.gradle b/devtools/gradle/gradle-model/build.gradle index aa365bd8f87f1..24c3f0dc47e33 100644 --- a/devtools/gradle/gradle-model/build.gradle +++ b/devtools/gradle/gradle-model/build.gradle @@ -1,5 +1,6 @@ dependencies { implementation "io.quarkus:quarkus-core-deployment:${version}" + implementation "org.jetbrains.kotlin:kotlin-gradle-plugin-api:${kotlin_version}" testImplementation "io.quarkus:quarkus-devtools-testing:${version}" } @@ -27,4 +28,4 @@ publishing { from components.java } } -} \ No newline at end of file +} diff --git a/devtools/gradle/gradle-model/src/main/java/io/quarkus/gradle/tooling/GradleApplicationModelBuilder.java b/devtools/gradle/gradle-model/src/main/java/io/quarkus/gradle/tooling/GradleApplicationModelBuilder.java index 70beafce4e434..1b4bfe395c92b 100644 --- a/devtools/gradle/gradle-model/src/main/java/io/quarkus/gradle/tooling/GradleApplicationModelBuilder.java +++ b/devtools/gradle/gradle-model/src/main/java/io/quarkus/gradle/tooling/GradleApplicationModelBuilder.java @@ -30,6 +30,7 @@ import org.gradle.api.tasks.compile.AbstractCompile; import org.gradle.language.jvm.tasks.ProcessResources; import org.gradle.tooling.provider.model.ParameterizedToolingModelBuilder; +import org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile; import io.quarkus.bootstrap.BootstrapConstants; import io.quarkus.bootstrap.model.ApplicationModel; @@ -436,6 +437,7 @@ private static void initProjectModule(Project project, WorkspaceModule.Mutable m final List sourceDirs = new ArrayList<>(1); final List resourceDirs = new ArrayList<>(1); + project.getTasks().withType(AbstractCompile.class, t -> { if (!t.getEnabled()) { return; @@ -448,19 +450,45 @@ private static void initProjectModule(Project project, WorkspaceModule.Mutable m if (!allClassesDirs.contains(destDir)) { return; } - final List srcDirs = new ArrayList<>(1); source.visit(a -> { // we are looking for the root dirs containing sources if (a.getRelativePath().getSegments().length == 1) { final File srcDir = a.getFile().getParentFile(); - if (srcDirs.add(srcDir)) { + DefaultSourceDir sources = new DefaultSourceDir(srcDir.toPath(), destDir.toPath(), + Collections.singletonMap("compiler", t.getName())); + sourceDirs.add(sources); + } + }); + }); + + // This "try/catch" is needed because of the way the "quarkus-cli" Gradle tests work. Without it, the tests fail. + try { + Class.forName("org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile"); + project.getTasks().withType(KotlinJvmCompile.class, t -> { + if (!t.getEnabled()) { + return; + } + final FileTree source = t.getSources().getAsFileTree(); + if (source.isEmpty()) { + return; + } + final File destDir = t.getDestinationDirectory().getAsFile().get(); + if (!allClassesDirs.contains(destDir)) { + return; + } + source.visit(a -> { + // we are looking for the root dirs containing sources + if (a.getRelativePath().getSegments().length == 1) { + final File srcDir = a.getFile().getParentFile(); DefaultSourceDir sources = new DefaultSourceDir(srcDir.toPath(), destDir.toPath(), Collections.singletonMap("compiler", t.getName())); sourceDirs.add(sources); } - } + }); }); - }); + } catch (ClassNotFoundException e) { + // ignore + } final File resourcesOutputDir = sourceSet.getOutput().getResourcesDir(); @@ -476,14 +504,11 @@ private static void initProjectModule(Project project, WorkspaceModule.Mutable m return; } final Path destDir = t.getDestinationDir().toPath(); - final List srcDirs = new ArrayList<>(1); source.getAsFileTree().visit(a -> { // we are looking for the root dirs containing sources if (a.getRelativePath().getSegments().length == 1) { final File srcDir = a.getFile().getParentFile(); - if (srcDirs.add(srcDir)) { - resourceDirs.add(new DefaultSourceDir(srcDir.toPath(), destDir)); - } + resourceDirs.add(new DefaultSourceDir(srcDir.toPath(), destDir)); } }); }); diff --git a/devtools/gradle/gradle.properties b/devtools/gradle/gradle.properties index a70146c0ed233..4a334fad3fbc4 100644 --- a/devtools/gradle/gradle.properties +++ b/devtools/gradle/gradle.properties @@ -1 +1,2 @@ -version = 999-SNAPSHOT \ No newline at end of file +version = 999-SNAPSHOT +kotlin_version = 1.7.10 diff --git a/independent-projects/arc/tests/pom.xml b/independent-projects/arc/tests/pom.xml index 95aa555f84c7f..077f87a693616 100644 --- a/independent-projects/arc/tests/pom.xml +++ b/independent-projects/arc/tests/pom.xml @@ -48,7 +48,7 @@ org.jetbrains.kotlin kotlin-stdlib - 1.6.21 + 1.7.10 test