Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: render WireMock Dev Service in Dev UI #72

Merged
merged 1 commit into from
Nov 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,20 @@
import com.github.tomakehurst.wiremock.core.WireMockConfiguration;

import io.quarkus.deployment.annotations.BuildStep;
import io.quarkus.deployment.annotations.Consume;
import io.quarkus.deployment.builditem.CuratedApplicationShutdownBuildItem;
import io.quarkus.deployment.builditem.DevServicesResultBuildItem;
import io.quarkus.deployment.builditem.DevServicesResultBuildItem.RunningDevService;
import io.quarkus.deployment.builditem.FeatureBuildItem;
import io.quarkus.deployment.builditem.LaunchModeBuildItem;
import io.quarkus.deployment.builditem.LiveReloadBuildItem;
import io.quarkus.deployment.dev.devservices.DevServiceDescriptionBuildItem;
import io.quarkus.deployment.dev.devservices.GlobalDevServicesConfig;

class WireMockServerProcessor {
private static final Logger LOGGER = Logger.getLogger(WireMockServerProcessor.class);
private static final String FEATURE_NAME = "wiremock";
private static final String DEV_SERVICE_NAME = "wiremock-server";
private static final String DEV_SERVICE_NAME = "WireMock";
private static final String CONFIG_TEMPLATE = "%%dev,test.%s.%s";
static volatile RunningDevService devService;

Expand Down Expand Up @@ -53,11 +55,16 @@ DevServicesResultBuildItem setup(LaunchModeBuildItem launchMode, LiveReloadBuild
return devService.toBuildItem();
}

@BuildStep(onlyIf = { WireMockServerEnabled.class, GlobalDevServicesConfig.Enabled.class })
@Consume(DevServicesResultBuildItem.class)
DevServiceDescriptionBuildItem renderDevServiceDevUICard(WireMockServerConfig config) {
return new DevServiceDescriptionBuildItem(DEV_SERVICE_NAME, null, devService.getConfig());
}

private static RunningDevService startWireMockDevService(WireMockServerConfig config) {

LOGGER.debugf("Starting WireMock server with port [%s] and path [%s]", config.port(), config.filesMapping());
final WireMockConfiguration configuration = options()
.port(config.port())
final WireMockConfiguration configuration = options().port(config.port())
.usingFilesUnderDirectory(config.filesMapping())
.globalTemplating(config.globalResponseTemplating());
final WireMockServer server = new WireMockServer(configuration);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
name: "WireMock"
artifact: ${project.groupId}:${project.artifactId}:${project.version}
description: WireMock DevService for tests and local development
description: WireMock Dev Service for tests and local development
metadata:
short-name: "wiremock"
keywords:
Expand Down