Skip to content

Commit

Permalink
Actually make Kotlin 1.7 work, for really-reals.
Browse files Browse the repository at this point in the history
  • Loading branch information
GavinRay97 authored and gastaldi committed Aug 2, 2022
1 parent 4afbe11 commit c5d5eaf
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 14 deletions.
2 changes: 1 addition & 1 deletion bom/application/pom.xml
Expand Up @@ -148,7 +148,7 @@
<aws-lambda-java-events.version>3.11.0</aws-lambda-java-events.version>
<aws-xray.version>2.11.2</aws-xray.version>
<azure-functions-java-library.version>1.4.2</azure-functions-java-library.version>
<kotlin.version>1.6.21</kotlin.version>
<kotlin.version>1.7.10</kotlin.version>
<kotlin.coroutine.version>1.6.4</kotlin.coroutine.version>
<kotlin-serialization.version>1.3.3</kotlin-serialization.version>
<kubernetes-client.version>5.12.3</kubernetes-client.version> <!-- Please check with Java Operator SDK team before updating -->
Expand Down
4 changes: 2 additions & 2 deletions build-parent/pom.xml
Expand Up @@ -20,8 +20,8 @@
<!-- These properties are needed in order for them to be resolvable by the generated projects -->
<!-- Quarkus uses jboss-parent and it comes with 3.8.1-jboss-1, we don't want that in the templates -->
<compiler-plugin.version>3.8.1</compiler-plugin.version>
<kotlin.version>1.6.21</kotlin.version>
<dokka.version>1.6.21</dokka.version>
<kotlin.version>1.7.10</kotlin.version>
<dokka.version>1.7.10</dokka.version>
<scala.version>2.13.8</scala.version>
<scala-maven-plugin.version>4.7.1</scala-maven-plugin.version>
<!-- not pretty but this is used in the codestarts and we don't want to break compatibility -->
Expand Down
3 changes: 2 additions & 1 deletion 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}"
}

Expand Down Expand Up @@ -27,4 +28,4 @@ publishing {
from components.java
}
}
}
}
Expand Up @@ -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;
Expand Down Expand Up @@ -436,6 +437,7 @@ private static void initProjectModule(Project project, WorkspaceModule.Mutable m

final List<SourceDir> sourceDirs = new ArrayList<>(1);
final List<SourceDir> resourceDirs = new ArrayList<>(1);

project.getTasks().withType(AbstractCompile.class, t -> {
if (!t.getEnabled()) {
return;
Expand All @@ -448,19 +450,45 @@ private static void initProjectModule(Project project, WorkspaceModule.Mutable m
if (!allClassesDirs.contains(destDir)) {
return;
}
final List<File> 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();

Expand All @@ -476,14 +504,11 @@ private static void initProjectModule(Project project, WorkspaceModule.Mutable m
return;
}
final Path destDir = t.getDestinationDir().toPath();
final List<File> 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));
}
});
});
Expand Down
3 changes: 2 additions & 1 deletion devtools/gradle/gradle.properties
@@ -1 +1,2 @@
version = 999-SNAPSHOT
version = 999-SNAPSHOT
kotlin_version = 1.7.10
2 changes: 1 addition & 1 deletion independent-projects/arc/tests/pom.xml
Expand Up @@ -48,7 +48,7 @@
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib</artifactId>
<version>1.6.21</version>
<version>1.7.10</version>
<scope>test</scope>
</dependency>

Expand Down

0 comments on commit c5d5eaf

Please sign in to comment.