From 6c6281716ac5ee644b6abacf5164dc3e27687503 Mon Sep 17 00:00:00 2001 From: Fabian Mastenbroek Date: Fri, 29 Jul 2022 17:04:06 +0200 Subject: fix(web/runner): Register all available trace formats This change updates the Quarkus extension to register all the available trace formats that are on the class path during processing time. Without this change, the OpenDC web runner is unable to load any of the available trace formats via Quarkus. --- .../build.gradle.kts | 1 + .../web/runner/deployment/OpenDCRunnerProcessor.java | 20 ++++++++++++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) (limited to 'opendc-web') diff --git a/opendc-web/opendc-web-runner-quarkus-deployment/build.gradle.kts b/opendc-web/opendc-web-runner-quarkus-deployment/build.gradle.kts index 24f667cf..d31c4839 100644 --- a/opendc-web/opendc-web-runner-quarkus-deployment/build.gradle.kts +++ b/opendc-web/opendc-web-runner-quarkus-deployment/build.gradle.kts @@ -29,6 +29,7 @@ plugins { dependencies { implementation(projects.opendcWeb.opendcWebRunnerQuarkus) + implementation(projects.opendcTrace.opendcTraceApi) implementation(platform(libs.quarkus.bom)) implementation(libs.quarkus.core.deployment) diff --git a/opendc-web/opendc-web-runner-quarkus-deployment/src/main/java/org/opendc/web/runner/deployment/OpenDCRunnerProcessor.java b/opendc-web/opendc-web-runner-quarkus-deployment/src/main/java/org/opendc/web/runner/deployment/OpenDCRunnerProcessor.java index b9a334ac..1d01aabc 100644 --- a/opendc-web/opendc-web-runner-quarkus-deployment/src/main/java/org/opendc/web/runner/deployment/OpenDCRunnerProcessor.java +++ b/opendc-web/opendc-web-runner-quarkus-deployment/src/main/java/org/opendc/web/runner/deployment/OpenDCRunnerProcessor.java @@ -26,11 +26,17 @@ import io.quarkus.deployment.annotations.BuildProducer; import io.quarkus.deployment.annotations.BuildStep; import io.quarkus.deployment.annotations.Record; import io.quarkus.deployment.builditem.*; +import io.quarkus.deployment.builditem.nativeimage.ServiceProviderBuildItem; +import io.quarkus.deployment.util.ServiceUtil; import io.quarkus.runtime.RuntimeValue; +import org.opendc.trace.spi.TraceFormat; import org.opendc.web.runner.OpenDCRunner; import org.opendc.web.runner.runtime.OpenDCRunnerRecorder; import org.opendc.web.runner.runtime.OpenDCRunnerRuntimeConfig; +import java.io.IOException; +import java.util.Collections; +import java.util.Set; import java.util.function.BooleanSupplier; import static io.quarkus.deployment.annotations.ExecutionTime.RUNTIME_INIT; @@ -51,12 +57,18 @@ public class OpenDCRunnerProcessor { } /** - * Build step to index the necessary dependencies for the OpenDC runner. + * Build step to register the trace formats used by OpenDC. */ @BuildStep - void addDependencies(BuildProducer indexDependency) { - indexDependency.produce(new IndexDependencyBuildItem("org.opendc.trace", "opendc-trace-opendc")); - indexDependency.produce(new IndexDependencyBuildItem("org.opendc.trace", "opendc-trace-bitbrains")); + void registerTraceFormats(BuildProducer services) throws IOException { + String service = "META-INF/services/" + TraceFormat.class.getName(); + + Set implementations = ServiceUtil.classNamesNamedIn(Thread.currentThread().getContextClassLoader(), + service); + + services.produce( + new ServiceProviderBuildItem(TraceFormat.class.getName(), + implementations.toArray(new String[0]))); } /** -- cgit v1.2.3