diff --git a/bom/application/pom.xml b/bom/application/pom.xml index 6b7ee60e037a3..f5adf756bf483 100644 --- a/bom/application/pom.xml +++ b/bom/application/pom.xml @@ -1898,7 +1898,7 @@ io.quarkus - quarkus-vertx-kotlin + quarkus-vertx-deployment-spi ${project.version} diff --git a/extensions/kotlin/deployment/pom.xml b/extensions/kotlin/deployment/pom.xml index 6e931d801d627..46070fe8c2877 100644 --- a/extensions/kotlin/deployment/pom.xml +++ b/extensions/kotlin/deployment/pom.xml @@ -18,6 +18,14 @@ io.quarkus quarkus-kotlin + + io.quarkus + quarkus-arc-deployment + + + io.quarkus + quarkus-vertx-deployment-spi + io.quarkus quarkus-jackson-spi diff --git a/extensions/kotlin/deployment/src/main/java/io/quarkus/kotlin/deployment/KotlinProcessor.java b/extensions/kotlin/deployment/src/main/java/io/quarkus/kotlin/deployment/KotlinProcessor.java index 340f4de9888ac..4f67df86a5b3e 100644 --- a/extensions/kotlin/deployment/src/main/java/io/quarkus/kotlin/deployment/KotlinProcessor.java +++ b/extensions/kotlin/deployment/src/main/java/io/quarkus/kotlin/deployment/KotlinProcessor.java @@ -2,6 +2,13 @@ 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; @@ -11,10 +18,14 @@ 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() { @@ -68,4 +79,34 @@ void registerKotlinReflection(final BuildProducer refl ".*.kotlin_builtins") .build()); } + + @BuildStep + void produceCoroutineScope(BuildProducer additionalBean) { + if (!QuarkusClassLoader.isClassPresentAtRuntime(KOTLIN_COROUTINE_SCOPE)) { + return; + } + + additionalBean.produce(AdditionalBeanBuildItem.builder() + .addBeanClass(ApplicationCoroutineScope.class) + .setUnremovable() + .build()); + } + + @BuildStep + void produceInvokerCustomizerForSuspendConsumeEventMethods( + BuildProducer customizers) { + if (!QuarkusClassLoader.isClassPresentAtRuntime(KOTLIN_COROUTINE_SCOPE)) { + return; + } + + customizers.produce(new EventConsumerInvokerCustomizerBuildItem(new BiConsumer() { + @Override + public void accept(MethodInfo method, InvokerBuilder invokerBuilder) { + if (KotlinUtils.isKotlinSuspendMethod(method)) { + invokerBuilder.withInvocationWrapper(CoroutineInvoker.class, "inNewCoroutine"); + } + } + })); + } + } diff --git a/extensions/kotlin/runtime/pom.xml b/extensions/kotlin/runtime/pom.xml index a92dd5751b376..b5820188b1515 100644 --- a/extensions/kotlin/runtime/pom.xml +++ b/extensions/kotlin/runtime/pom.xml @@ -13,30 +13,16 @@ quarkus-kotlin Quarkus - Kotlin - Runtime Write your services in Kotlin - - - - io.quarkus - quarkus-extension-maven-plugin - - - - org.jetbrains.kotlin:kotlin-compiler - - - io.quarkus.kotlin - - - - - + io.quarkus quarkus-core + + io.quarkus + quarkus-arc + org.jetbrains annotations @@ -59,6 +45,10 @@ org.jetbrains.kotlin kotlin-reflect + + io.vertx + vertx-core + io.smallrye.reactive @@ -79,4 +69,96 @@ kotlinx-coroutines-jdk8 + + + ${project.basedir}/src/main/kotlin + ${project.basedir}/src/test/kotlin + + + io.quarkus + quarkus-extension-maven-plugin + + + + org.jetbrains.kotlin:kotlin-compiler + + + io.quarkus.kotlin + + + + + + org.jetbrains.kotlin + kotlin-maven-plugin + ${kotlin.version} + + + compile + + compile + + + + test-compile + + test-compile + + + + + ${maven.compiler.target} + + + + org.apache.maven.plugins + maven-compiler-plugin + + + + io.quarkus + quarkus-extension-processor + ${project.version} + + + + + + + default-compile + none + + + + default-testCompile + none + + + java-compile + compile + + compile + + + + java-test-compile + test-compile + + testCompile + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + + false + + + + + diff --git a/extensions/vertx/kotlin/src/main/kotlin/io/quarkus/vertx/kotlin/runtime/ApplicationCoroutineScope.kt b/extensions/kotlin/runtime/src/main/kotlin/io/quarkus/kotlin/runtime/ApplicationCoroutineScope.kt similarity index 92% rename from extensions/vertx/kotlin/src/main/kotlin/io/quarkus/vertx/kotlin/runtime/ApplicationCoroutineScope.kt rename to extensions/kotlin/runtime/src/main/kotlin/io/quarkus/kotlin/runtime/ApplicationCoroutineScope.kt index 7a9719fdbeb86..4429a5d671fd7 100644 --- a/extensions/vertx/kotlin/src/main/kotlin/io/quarkus/vertx/kotlin/runtime/ApplicationCoroutineScope.kt +++ b/extensions/kotlin/runtime/src/main/kotlin/io/quarkus/kotlin/runtime/ApplicationCoroutineScope.kt @@ -1,4 +1,4 @@ -package io.quarkus.vertx.kotlin.runtime +package io.quarkus.kotlin.runtime import jakarta.annotation.PreDestroy import jakarta.inject.Singleton diff --git a/extensions/vertx/kotlin/src/main/kotlin/io/quarkus/vertx/kotlin/runtime/CoroutineInvoker.kt b/extensions/kotlin/runtime/src/main/kotlin/io/quarkus/kotlin/runtime/CoroutineInvoker.kt similarity index 96% rename from extensions/vertx/kotlin/src/main/kotlin/io/quarkus/vertx/kotlin/runtime/CoroutineInvoker.kt rename to extensions/kotlin/runtime/src/main/kotlin/io/quarkus/kotlin/runtime/CoroutineInvoker.kt index 48e5a26f084f0..a777db5903533 100644 --- a/extensions/vertx/kotlin/src/main/kotlin/io/quarkus/vertx/kotlin/runtime/CoroutineInvoker.kt +++ b/extensions/kotlin/runtime/src/main/kotlin/io/quarkus/kotlin/runtime/CoroutineInvoker.kt @@ -1,4 +1,4 @@ -package io.quarkus.vertx.kotlin.runtime +package io.quarkus.kotlin.runtime import io.quarkus.arc.Arc import io.vertx.core.Vertx diff --git a/extensions/vertx/kotlin/src/main/kotlin/io/quarkus/vertx/kotlin/runtime/VertxDispatcher.kt b/extensions/kotlin/runtime/src/main/kotlin/io/quarkus/kotlin/runtime/VertxDispatcher.kt similarity index 94% rename from extensions/vertx/kotlin/src/main/kotlin/io/quarkus/vertx/kotlin/runtime/VertxDispatcher.kt rename to extensions/kotlin/runtime/src/main/kotlin/io/quarkus/kotlin/runtime/VertxDispatcher.kt index 67cee1bfab8b8..51b56f460557a 100644 --- a/extensions/vertx/kotlin/src/main/kotlin/io/quarkus/vertx/kotlin/runtime/VertxDispatcher.kt +++ b/extensions/kotlin/runtime/src/main/kotlin/io/quarkus/kotlin/runtime/VertxDispatcher.kt @@ -1,4 +1,4 @@ -package io.quarkus.vertx.kotlin.runtime +package io.quarkus.kotlin.runtime import io.quarkus.arc.Arc import io.vertx.core.Context diff --git a/extensions/vertx/deployment-spi/pom.xml b/extensions/vertx/deployment-spi/pom.xml new file mode 100644 index 0000000000000..719736a3d4e08 --- /dev/null +++ b/extensions/vertx/deployment-spi/pom.xml @@ -0,0 +1,26 @@ + + + + quarkus-vertx-parent + io.quarkus + 999-SNAPSHOT + + 4.0.0 + + quarkus-vertx-deployment-spi + Quarkus - Vert.x - Deployment - SPI + + + + io.quarkus + quarkus-core-deployment + + + io.quarkus.arc + arc-processor + + + + diff --git a/extensions/vertx/deployment-spi/src/main/java/io/quarkus/vertx/deployment/spi/EventConsumerInvokerCustomizerBuildItem.java b/extensions/vertx/deployment-spi/src/main/java/io/quarkus/vertx/deployment/spi/EventConsumerInvokerCustomizerBuildItem.java new file mode 100644 index 0000000000000..20f4f993409d2 --- /dev/null +++ b/extensions/vertx/deployment-spi/src/main/java/io/quarkus/vertx/deployment/spi/EventConsumerInvokerCustomizerBuildItem.java @@ -0,0 +1,24 @@ +package io.quarkus.vertx.deployment.spi; + +import java.util.function.BiConsumer; + +import org.jboss.jandex.MethodInfo; + +import io.quarkus.arc.processor.InvokerBuilder; +import io.quarkus.builder.item.MultiBuildItem; + +/** + * This build item should be considered private and should not be used outside of core Quarkus. + * It can be changed without notice. + */ +public final class EventConsumerInvokerCustomizerBuildItem extends MultiBuildItem { + private final BiConsumer invokerCustomizer; + + public EventConsumerInvokerCustomizerBuildItem(BiConsumer invokerCustomizer) { + this.invokerCustomizer = invokerCustomizer; + } + + public BiConsumer getInvokerCustomizer() { + return invokerCustomizer; + } +} diff --git a/extensions/vertx/deployment/pom.xml b/extensions/vertx/deployment/pom.xml index b716507a6b230..3caa22b6d250b 100644 --- a/extensions/vertx/deployment/pom.xml +++ b/extensions/vertx/deployment/pom.xml @@ -37,6 +37,10 @@ io.quarkus quarkus-jackson-spi + + io.quarkus + quarkus-vertx-deployment-spi + io.quarkus quarkus-junit5-internal @@ -62,16 +66,6 @@ vertx-web-client test - - org.jetbrains.kotlin - kotlin-stdlib - test - - - org.jetbrains.kotlinx - kotlinx-coroutines-core - test - @@ -95,80 +89,4 @@ - - - kotlin-tests - - - !no-kotlin-tests - - - - - - - org.jetbrains.kotlin - kotlin-maven-plugin - - - compile - - compile - - - - ${project.basedir}/src/main/kotlin - ${project.basedir}/src/main/java - - - - - test-compile - - test-compile - - - - ${project.basedir}/src/test/kotlin - ${project.basedir}/src/test/java - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - - - - default-compile - none - - - - default-testCompile - none - - - java-compile - compile - - compile - - - - java-test-compile - test-compile - - testCompile - - - - - - - - - diff --git a/extensions/vertx/deployment/src/main/java/io/quarkus/vertx/deployment/VertxProcessor.java b/extensions/vertx/deployment/src/main/java/io/quarkus/vertx/deployment/VertxProcessor.java index ea374962a1d72..729fdacce1766 100644 --- a/extensions/vertx/deployment/src/main/java/io/quarkus/vertx/deployment/VertxProcessor.java +++ b/extensions/vertx/deployment/src/main/java/io/quarkus/vertx/deployment/VertxProcessor.java @@ -60,7 +60,7 @@ import io.quarkus.gizmo.ClassOutput; import io.quarkus.vertx.ConsumeEvent; import io.quarkus.vertx.core.deployment.CoreVertxBuildItem; -import io.quarkus.vertx.kotlin.runtime.CoroutineInvoker; +import io.quarkus.vertx.deployment.spi.EventConsumerInvokerCustomizerBuildItem; import io.quarkus.vertx.runtime.EventConsumerInfo; import io.quarkus.vertx.runtime.VertxEventBusConsumerRecorder; import io.quarkus.vertx.runtime.VertxProducer; @@ -139,6 +139,7 @@ public UnremovableBeanBuildItem unremovableBeans() { void collectEventConsumers( BeanRegistrationPhaseBuildItem beanRegistrationPhase, InvokerFactoryBuildItem invokerFactory, + List invokerCustomizers, BuildProducer messageConsumerBusinessMethods, BuildProducer errors) { // We need to collect all business methods annotated with @ConsumeEvent first @@ -207,8 +208,8 @@ void collectEventConsumers( builder.withReturnValueTransformer(Uni.class, "subscribeAsCompletionStage"); } - if (KotlinUtils.isKotlinSuspendMethod(method)) { - builder.withInvocationWrapper(CoroutineInvoker.class, "inNewCoroutine"); + for (EventConsumerInvokerCustomizerBuildItem invokerCustomizer : invokerCustomizers) { + invokerCustomizer.getInvokerCustomizer().accept(method, builder); } InvokerInfo invoker = builder.build(); @@ -229,18 +230,6 @@ AutoAddScopeBuildItem autoAddScope() { .reason("Found event consumer business methods").build(); } - @BuildStep - void produceCoroutineScope(BuildProducer additionalBean) { - if (!QuarkusClassLoader.isClassPresentAtRuntime("kotlinx.coroutines.CoroutineScope")) { - return; - } - - additionalBean.produce(AdditionalBeanBuildItem.builder() - .addBeanClass("io.quarkus.vertx.kotlin.runtime.ApplicationCoroutineScope") - .setUnremovable() - .build()); - } - @BuildStep void registerVerticleClasses(CombinedIndexBuildItem indexBuildItem, BuildProducer reflectiveClass) { diff --git a/extensions/vertx/kotlin/pom.xml b/extensions/vertx/kotlin/pom.xml deleted file mode 100644 index 9d00dbfd46889..0000000000000 --- a/extensions/vertx/kotlin/pom.xml +++ /dev/null @@ -1,110 +0,0 @@ - - - - io.quarkus - quarkus-vertx-parent - 999-SNAPSHOT - - 4.0.0 - - quarkus-vertx-kotlin - Quarkus - Vert.x - Kotlin - - - - io.quarkus - quarkus-arc - - - io.vertx - vertx-core - - - org.jetbrains.kotlin - kotlin-stdlib - true - - - org.jetbrains.kotlinx - kotlinx-coroutines-core - true - - - - - ${project.basedir}/src/main/kotlin - ${project.basedir}/src/test/kotlin - - - org.jetbrains.kotlin - kotlin-maven-plugin - ${kotlin.version} - - - compile - - compile - - - - test-compile - - test-compile - - - - - ${maven.compiler.target} - - - - org.apache.maven.plugins - maven-compiler-plugin - - - - io.quarkus - quarkus-extension-processor - ${project.version} - - - - - - - default-compile - none - - - - default-testCompile - none - - - java-compile - compile - - compile - - - - java-test-compile - test-compile - - testCompile - - - - - - org.apache.maven.plugins - maven-javadoc-plugin - - false - - - - - diff --git a/extensions/vertx/pom.xml b/extensions/vertx/pom.xml index 59efbc67c06f1..d6ae6c6bf9d23 100644 --- a/extensions/vertx/pom.xml +++ b/extensions/vertx/pom.xml @@ -15,7 +15,7 @@ pom deployment - kotlin + deployment-spi latebound-mdc-provider runtime diff --git a/extensions/vertx/runtime/pom.xml b/extensions/vertx/runtime/pom.xml index 6f94170d5f43f..6809e3614a3e8 100644 --- a/extensions/vertx/runtime/pom.xml +++ b/extensions/vertx/runtime/pom.xml @@ -46,10 +46,6 @@ io.quarkus quarkus-virtual-threads - - io.quarkus - quarkus-vertx-kotlin - io.quarkus quarkus-vertx-latebound-mdc-provider diff --git a/integration-tests/kotlin-vertx/pom.xml b/integration-tests/kotlin-vertx/pom.xml new file mode 100644 index 0000000000000..d614c4f1e00bb --- /dev/null +++ b/integration-tests/kotlin-vertx/pom.xml @@ -0,0 +1,87 @@ + + + 4.0.0 + + + quarkus-integration-tests-parent + io.quarkus + 999-SNAPSHOT + + + quarkus-integration-test-kotlin-vertx + Quarkus - Integration Tests - Kotlin Vert.x + + + + io.quarkus + quarkus-arc-deployment + + + io.quarkus + quarkus-kotlin-deployment + + + io.quarkus + quarkus-vertx-deployment + + + org.jetbrains.kotlin + kotlin-stdlib + + + org.jetbrains.kotlinx + kotlinx-coroutines-core + + + io.quarkus + quarkus-junit5-internal + test + + + org.assertj + assertj-core + test + + + + + src/main/kotlin + src/test/kotlin + + + org.jetbrains.kotlin + kotlin-maven-plugin + + + compile + compile + + compile + + + + test-compile + test-compile + + test-compile + + + + + + io.quarkus + quarkus-maven-plugin + + + + build + + + + + + + + diff --git a/extensions/vertx/deployment/src/test/kotlin/io/quarkus/vertx/kotlin/KotlinConsumeEventTest.kt b/integration-tests/kotlin-vertx/src/test/kotlin/io/quarkus/it/kotlin/vertx/KotlinConsumeEventTest.kt similarity index 99% rename from extensions/vertx/deployment/src/test/kotlin/io/quarkus/vertx/kotlin/KotlinConsumeEventTest.kt rename to integration-tests/kotlin-vertx/src/test/kotlin/io/quarkus/it/kotlin/vertx/KotlinConsumeEventTest.kt index 8790cf3d61d54..f578f658d3696 100644 --- a/extensions/vertx/deployment/src/test/kotlin/io/quarkus/vertx/kotlin/KotlinConsumeEventTest.kt +++ b/integration-tests/kotlin-vertx/src/test/kotlin/io/quarkus/it/kotlin/vertx/KotlinConsumeEventTest.kt @@ -1,4 +1,4 @@ -package io.quarkus.vertx.kotlin +package io.quarkus.it.kotlin.vertx import io.quarkus.test.QuarkusUnitTest import io.quarkus.vertx.ConsumeEvent diff --git a/extensions/vertx/deployment/src/test/kotlin/io/quarkus/vertx/kotlin/KotlinSuspendConsumeEventTest.kt b/integration-tests/kotlin-vertx/src/test/kotlin/io/quarkus/it/kotlin/vertx/KotlinSuspendConsumeEventTest.kt similarity index 99% rename from extensions/vertx/deployment/src/test/kotlin/io/quarkus/vertx/kotlin/KotlinSuspendConsumeEventTest.kt rename to integration-tests/kotlin-vertx/src/test/kotlin/io/quarkus/it/kotlin/vertx/KotlinSuspendConsumeEventTest.kt index 5d5b549afd7a3..cc49aab6e0d3f 100644 --- a/extensions/vertx/deployment/src/test/kotlin/io/quarkus/vertx/kotlin/KotlinSuspendConsumeEventTest.kt +++ b/integration-tests/kotlin-vertx/src/test/kotlin/io/quarkus/it/kotlin/vertx/KotlinSuspendConsumeEventTest.kt @@ -1,4 +1,4 @@ -package io.quarkus.vertx.kotlin +package io.quarkus.it.kotlin.vertx import io.quarkus.test.QuarkusUnitTest import io.quarkus.vertx.ConsumeEvent diff --git a/integration-tests/pom.xml b/integration-tests/pom.xml index 0a63ea27ed39a..dd93e4cea51ff 100644 --- a/integration-tests/pom.xml +++ b/integration-tests/pom.xml @@ -296,6 +296,7 @@ scala kotlin kotlin-serialization + kotlin-vertx mongodb-panache mongodb-panache-kotlin mongodb-rest-data-panache