Skip to content

Commit

Permalink
WIP to be squashed, part 2
Browse files Browse the repository at this point in the history
  • Loading branch information
Ladicek committed Jun 5, 2024
1 parent 40875a7 commit 0900413
Show file tree
Hide file tree
Showing 23 changed files with 574 additions and 421 deletions.
10 changes: 10 additions & 0 deletions bom/application/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1957,6 +1957,16 @@
<artifactId>quarkus-vertx-http-dev-ui-resources</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-vertx-kotlin</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-vertx-kotlin-deployment</artifactId>
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>io.quarkus</groupId>
Expand Down
13 changes: 13 additions & 0 deletions devtools/bom-descriptor-json/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2930,6 +2930,19 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-vertx-kotlin</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-virtual-threads</artifactId>
Expand Down
13 changes: 13 additions & 0 deletions docs/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2946,6 +2946,19 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-vertx-kotlin-deployment</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-virtual-threads-deployment</artifactId>
Expand Down
13 changes: 5 additions & 8 deletions extensions/kotlin/deployment/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,6 @@
<groupId>io.quarkus</groupId>
<artifactId>quarkus-kotlin</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-arc-deployment</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-vertx-deployment-spi</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-jackson-spi</artifactId>
Expand All @@ -36,6 +28,11 @@
<artifactId>kotlin-compiler</artifactId>
</dependency>

<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-vertx-kotlin-deployment</artifactId>
<optional>true</optional>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,6 @@

import static io.quarkus.deployment.builditem.nativeimage.NativeImageResourcePatternsBuildItem.builder;

import java.util.function.BiConsumer;

import org.jboss.jandex.MethodInfo;

import io.quarkus.arc.deployment.AdditionalBeanBuildItem;
import io.quarkus.arc.processor.InvokerBuilder;
import io.quarkus.arc.processor.KotlinUtils;
import io.quarkus.bootstrap.classloading.QuarkusClassLoader;
import io.quarkus.deployment.Feature;
import io.quarkus.deployment.annotations.BuildProducer;
Expand All @@ -18,14 +11,10 @@
import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem;
import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassFinalFieldsWritablePredicateBuildItem;
import io.quarkus.jackson.spi.ClassPathJacksonModuleBuildItem;
import io.quarkus.kotlin.runtime.ApplicationCoroutineScope;
import io.quarkus.kotlin.runtime.CoroutineInvoker;
import io.quarkus.vertx.deployment.spi.EventConsumerInvokerCustomizerBuildItem;

public class KotlinProcessor {

private static final String KOTLIN_JACKSON_MODULE = "com.fasterxml.jackson.module.kotlin.KotlinModule";
private static final String KOTLIN_COROUTINE_SCOPE = "kotlinx.coroutines.CoroutineScope";

@BuildStep
FeatureBuildItem feature() {
Expand Down Expand Up @@ -79,34 +68,4 @@ void registerKotlinReflection(final BuildProducer<ReflectiveClassBuildItem> refl
".*.kotlin_builtins")
.build());
}

@BuildStep
void produceCoroutineScope(BuildProducer<AdditionalBeanBuildItem> additionalBean) {
if (!QuarkusClassLoader.isClassPresentAtRuntime(KOTLIN_COROUTINE_SCOPE)) {
return;
}

additionalBean.produce(AdditionalBeanBuildItem.builder()
.addBeanClass(ApplicationCoroutineScope.class)
.setUnremovable()
.build());
}

@BuildStep
void produceInvokerCustomizerForSuspendConsumeEventMethods(
BuildProducer<EventConsumerInvokerCustomizerBuildItem> customizers) {
if (!QuarkusClassLoader.isClassPresentAtRuntime(KOTLIN_COROUTINE_SCOPE)) {
return;
}

customizers.produce(new EventConsumerInvokerCustomizerBuildItem(new BiConsumer<MethodInfo, InvokerBuilder>() {
@Override
public void accept(MethodInfo method, InvokerBuilder invokerBuilder) {
if (KotlinUtils.isKotlinSuspendMethod(method)) {
invokerBuilder.withInvocationWrapper(CoroutineInvoker.class, "inNewCoroutine");
}
}
}));
}

}
126 changes: 25 additions & 101 deletions extensions/kotlin/runtime/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,30 @@
<artifactId>quarkus-kotlin</artifactId>
<name>Quarkus - Kotlin - Runtime</name>
<description>Write your services in Kotlin</description>

<build>
<plugins>
<plugin>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-extension-maven-plugin</artifactId>
<configuration>
<lesserPriorityArtifacts>
<!--
see https://github.com/quarkusio/quarkus/issues/8405
-->
<lesserPriorityArtifact>org.jetbrains.kotlin:kotlin-compiler</lesserPriorityArtifact>
</lesserPriorityArtifacts>
<capabilities>
<provides>io.quarkus.kotlin</provides>
</capabilities>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-core</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-arc</artifactId>
</dependency>
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
Expand All @@ -45,10 +59,6 @@
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-reflect</artifactId>
</dependency>
<dependency>
<groupId>io.vertx</groupId>
<artifactId>vertx-core</artifactId>
</dependency>
<!-- Is this the right place for this? We don't really want users to have to add it-->
<dependency>
<groupId>io.smallrye.reactive</groupId>
Expand All @@ -68,97 +78,11 @@
<groupId>org.jetbrains.kotlinx</groupId>
<artifactId>kotlinx-coroutines-jdk8</artifactId>
</dependency>
</dependencies>

<build>
<sourceDirectory>${project.basedir}/src/main/kotlin</sourceDirectory>
<testSourceDirectory>${project.basedir}/src/test/kotlin</testSourceDirectory>
<plugins>
<plugin>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-extension-maven-plugin</artifactId>
<configuration>
<lesserPriorityArtifacts>
<!--
see https://github.com/quarkusio/quarkus/issues/8405
-->
<lesserPriorityArtifact>org.jetbrains.kotlin:kotlin-compiler</lesserPriorityArtifact>
</lesserPriorityArtifacts>
<capabilities>
<provides>io.quarkus.kotlin</provides>
</capabilities>
</configuration>
</plugin>

<plugin>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-plugin</artifactId>
<version>${kotlin.version}</version>
<executions>
<execution>
<id>compile</id>
<goals>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>test-compile</id>
<goals>
<goal>test-compile</goal>
</goals>
</execution>
</executions>
<configuration>
<jvmTarget>${maven.compiler.target}</jvmTarget>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<annotationProcessorPaths>
<path>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-extension-processor</artifactId>
<version>${project.version}</version>
</path>
</annotationProcessorPaths>
</configuration>
<executions>
<!-- Replacing default-compile as it is treated specially by maven -->
<execution>
<id>default-compile</id>
<phase>none</phase>
</execution>
<!-- Replacing default-testCompile as it is treated specially by maven -->
<execution>
<id>default-testCompile</id>
<phase>none</phase>
</execution>
<execution>
<id>java-compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>java-test-compile</id>
<phase>test-compile</phase>
<goals>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<configuration>
<failOnError>false</failOnError>
</configuration>
</plugin>
</plugins>
</build>

<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-vertx-kotlin</artifactId>
<optional>true</optional>
</dependency>
</dependencies>
</project>
52 changes: 52 additions & 0 deletions extensions/vertx/kotlin/deployment/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>quarkus-vertx-kotlin-parent</artifactId>
<groupId>io.quarkus</groupId>
<version>999-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>quarkus-vertx-kotlin-deployment</artifactId>
<name>Quarkus - Vert.x - Kotlin - Deployment</name>

<dependencies>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-vertx-kotlin</artifactId>
</dependency>

<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-arc-deployment</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-vertx-deployment-spi</artifactId>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<annotationProcessorPaths>
<path>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-extension-processor</artifactId>
<version>${project.version}</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
<plugin>
<groupId>de.thetaphi</groupId>
<artifactId>forbiddenapis</artifactId>
</plugin>
</plugins>
</build>

</project>
Loading

0 comments on commit 0900413

Please sign in to comment.