summaryrefslogtreecommitdiff
path: root/opendc-web/opendc-web-ui-quarkus-deployment/src/main/java
diff options
context:
space:
mode:
authorFabian Mastenbroek <mail.fabianm@gmail.com>2022-10-06 13:13:10 +0200
committerFabian Mastenbroek <mail.fabianm@gmail.com>2022-10-06 14:46:56 +0200
commit47357afd16f928260db34d4dd3e686fb9ee7c5ff (patch)
tree950ba678869ec868c26ab3b95b57e4cabadb23c7 /opendc-web/opendc-web-ui-quarkus-deployment/src/main/java
parent402a8f55342c4565431c2a2e7287a70592f3fe33 (diff)
build: Switch to Spotless for formatting
This change updates the build configuration to use Spotless for code formating of both Kotlin and Java.
Diffstat (limited to 'opendc-web/opendc-web-ui-quarkus-deployment/src/main/java')
-rw-r--r--opendc-web/opendc-web-ui-quarkus-deployment/src/main/java/org/opendc/web/ui/deployment/AuthConfiguration.java1
-rw-r--r--opendc-web/opendc-web-ui-quarkus-deployment/src/main/java/org/opendc/web/ui/deployment/OpenDCUiConfig.java1
-rw-r--r--opendc-web/opendc-web-ui-quarkus-deployment/src/main/java/org/opendc/web/ui/deployment/OpenDCUiProcessor.java115
-rw-r--r--opendc-web/opendc-web-ui-quarkus-deployment/src/main/java/org/opendc/web/ui/deployment/OpenDCUiRoutingBuildItem.java3
4 files changed, 59 insertions, 61 deletions
diff --git a/opendc-web/opendc-web-ui-quarkus-deployment/src/main/java/org/opendc/web/ui/deployment/AuthConfiguration.java b/opendc-web/opendc-web-ui-quarkus-deployment/src/main/java/org/opendc/web/ui/deployment/AuthConfiguration.java
index 2e4d9198..82e02549 100644
--- a/opendc-web/opendc-web-ui-quarkus-deployment/src/main/java/org/opendc/web/ui/deployment/AuthConfiguration.java
+++ b/opendc-web/opendc-web-ui-quarkus-deployment/src/main/java/org/opendc/web/ui/deployment/AuthConfiguration.java
@@ -24,7 +24,6 @@ package org.opendc.web.ui.deployment;
import io.quarkus.runtime.annotations.ConfigGroup;
import io.quarkus.runtime.annotations.ConfigItem;
-
import java.util.Optional;
/**
diff --git a/opendc-web/opendc-web-ui-quarkus-deployment/src/main/java/org/opendc/web/ui/deployment/OpenDCUiConfig.java b/opendc-web/opendc-web-ui-quarkus-deployment/src/main/java/org/opendc/web/ui/deployment/OpenDCUiConfig.java
index 50c1fbe3..d630dbac 100644
--- a/opendc-web/opendc-web-ui-quarkus-deployment/src/main/java/org/opendc/web/ui/deployment/OpenDCUiConfig.java
+++ b/opendc-web/opendc-web-ui-quarkus-deployment/src/main/java/org/opendc/web/ui/deployment/OpenDCUiConfig.java
@@ -24,7 +24,6 @@ package org.opendc.web.ui.deployment;
import io.quarkus.runtime.annotations.ConfigItem;
import io.quarkus.runtime.annotations.ConfigRoot;
-
import java.util.Optional;
/**
diff --git a/opendc-web/opendc-web-ui-quarkus-deployment/src/main/java/org/opendc/web/ui/deployment/OpenDCUiProcessor.java b/opendc-web/opendc-web-ui-quarkus-deployment/src/main/java/org/opendc/web/ui/deployment/OpenDCUiProcessor.java
index 54782ace..093a9bfa 100644
--- a/opendc-web/opendc-web-ui-quarkus-deployment/src/main/java/org/opendc/web/ui/deployment/OpenDCUiProcessor.java
+++ b/opendc-web/opendc-web-ui-quarkus-deployment/src/main/java/org/opendc/web/ui/deployment/OpenDCUiProcessor.java
@@ -41,9 +41,6 @@ import io.quarkus.vertx.http.deployment.webjar.WebJarResourcesFilter;
import io.quarkus.vertx.http.deployment.webjar.WebJarResultsBuildItem;
import io.vertx.core.Handler;
import io.vertx.ext.web.RoutingContext;
-import org.opendc.web.ui.runtime.OpenDCUiRecorder;
-import org.opendc.web.ui.runtime.OpenDCUiRuntimeConfig;
-
import java.io.*;
import java.util.ArrayList;
import java.util.Iterator;
@@ -51,6 +48,8 @@ import java.util.function.BooleanSupplier;
import java.util.function.Function;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import org.opendc.web.ui.runtime.OpenDCUiRecorder;
+import org.opendc.web.ui.runtime.OpenDCUiRuntimeConfig;
/**
* Build processor for the OpenDC web UI Quarkus extension.
@@ -76,25 +75,25 @@ public class OpenDCUiProcessor {
* Build the WebJar that is used to serve the Next.js resources.
*/
@BuildStep(onlyIf = IsIncluded.class)
- public WebJarBuildItem buildWebJar(OpenDCUiConfig config,
- HttpRootPathBuildItem httpRootPathBuildItem) {
+ public WebJarBuildItem buildWebJar(OpenDCUiConfig config, HttpRootPathBuildItem httpRootPathBuildItem) {
return WebJarBuildItem.builder()
- .artifactKey(OPENDC_UI_WEBJAR_ARTIFACT_KEY)
- .root(OPENDC_UI_WEBJAR_STATIC_RESOURCES_PATH)
- .onlyCopyNonArtifactFiles(false)
- .useDefaultQuarkusBranding(false)
- .filter(new InsertVariablesResourcesFilter(config, httpRootPathBuildItem))
- .build();
+ .artifactKey(OPENDC_UI_WEBJAR_ARTIFACT_KEY)
+ .root(OPENDC_UI_WEBJAR_STATIC_RESOURCES_PATH)
+ .onlyCopyNonArtifactFiles(false)
+ .useDefaultQuarkusBranding(false)
+ .filter(new InsertVariablesResourcesFilter(config, httpRootPathBuildItem))
+ .build();
}
-
/**
* Build the Next.js routes based on the route manifest generated by it.
*/
@BuildStep(onlyIf = IsIncluded.class)
- public OpenDCUiRoutingBuildItem buildRoutes(CurateOutcomeBuildItem curateOutcomeBuildItem) throws IOException {
+ public OpenDCUiRoutingBuildItem buildRoutes(CurateOutcomeBuildItem curateOutcomeBuildItem) throws IOException {
ResolvedDependency dependency = getAppArtifact(curateOutcomeBuildItem, OPENDC_UI_WEBJAR_ARTIFACT_KEY);
- PathVisit visit = dependency.getContentTree().apply(OPENDC_UI_WEBJAR_STATIC_RESOURCES_PATH + "/routes-manifest.json", v -> v);
+ PathVisit visit = dependency
+ .getContentTree()
+ .apply(OPENDC_UI_WEBJAR_STATIC_RESOURCES_PATH + "/routes-manifest.json", v -> v);
if (visit == null) {
throw new FileNotFoundException("Cannot find routes-manifest.json");
@@ -103,7 +102,7 @@ public class OpenDCUiProcessor {
JsonNode routeManifest = objectMapper.readTree(visit.getUrl());
var pages = new ArrayList<OpenDCUiRoutingBuildItem.Page>();
- for (Iterator<JsonNode> it = routeManifest.get("staticRoutes").elements(); it.hasNext();) {
+ for (Iterator<JsonNode> it = routeManifest.get("staticRoutes").elements(); it.hasNext(); ) {
JsonNode route = it.next();
String page = route.get("page").asText();
@@ -112,7 +111,7 @@ public class OpenDCUiProcessor {
pages.add(new OpenDCUiRoutingBuildItem.Page(page, page));
}
- for (Iterator<JsonNode> it = routeManifest.get("dynamicRoutes").elements(); it.hasNext();) {
+ for (Iterator<JsonNode> it = routeManifest.get("dynamicRoutes").elements(); it.hasNext(); ) {
JsonNode route = it.next();
String page = route.get("page").asText();
@@ -122,7 +121,7 @@ public class OpenDCUiProcessor {
}
var redirects = new ArrayList<OpenDCUiRoutingBuildItem.Redirect>();
- for (Iterator<JsonNode> it = routeManifest.get("redirects").elements(); it.hasNext();) {
+ for (Iterator<JsonNode> it = routeManifest.get("redirects").elements(); it.hasNext(); ) {
JsonNode redirect = it.next();
if (redirect.has("internal")) {
continue;
@@ -148,16 +147,18 @@ public class OpenDCUiProcessor {
*/
@BuildStep(onlyIf = IsIncluded.class)
@Record(ExecutionTime.RUNTIME_INIT)
- public void registerOpenDCUiHandler(OpenDCUiRecorder recorder,
- BuildProducer<RouteBuildItem> routes,
- HttpRootPathBuildItem httpRootPathBuildItem,
- WebJarResultsBuildItem webJarResultsBuildItem,
- OpenDCUiRoutingBuildItem openDCUiBuildItem,
- OpenDCUiRuntimeConfig runtimeConfig,
- OpenDCUiConfig buildConfig,
- ShutdownContextBuildItem shutdownContext) {
-
- WebJarResultsBuildItem.WebJarResult result = webJarResultsBuildItem.byArtifactKey(OPENDC_UI_WEBJAR_ARTIFACT_KEY);
+ public void registerOpenDCUiHandler(
+ OpenDCUiRecorder recorder,
+ BuildProducer<RouteBuildItem> routes,
+ HttpRootPathBuildItem httpRootPathBuildItem,
+ WebJarResultsBuildItem webJarResultsBuildItem,
+ OpenDCUiRoutingBuildItem openDCUiBuildItem,
+ OpenDCUiRuntimeConfig runtimeConfig,
+ OpenDCUiConfig buildConfig,
+ ShutdownContextBuildItem shutdownContext) {
+
+ WebJarResultsBuildItem.WebJarResult result =
+ webJarResultsBuildItem.byArtifactKey(OPENDC_UI_WEBJAR_ARTIFACT_KEY);
if (result == null) {
return;
}
@@ -167,41 +168,41 @@ public class OpenDCUiProcessor {
/* Construct dynamic routes */
for (var redirect : openDCUiBuildItem.getRedirects()) {
- String destination = basePath.equals("/") ? redirect.getDestination() : basePath + redirect.getDestination();
-
- routes.produce(httpRootPathBuildItem.routeBuilder()
- .route(basePath + redirect.getPath())
- .handler(recorder.redirectHandler(destination, redirect.getStatusCode(), runtimeConfig))
- .build());
+ String destination =
+ basePath.equals("/") ? redirect.getDestination() : basePath + redirect.getDestination();
+
+ routes.produce(httpRootPathBuildItem
+ .routeBuilder()
+ .route(basePath + redirect.getPath())
+ .handler(recorder.redirectHandler(destination, redirect.getStatusCode(), runtimeConfig))
+ .build());
}
for (var page : openDCUiBuildItem.getPages()) {
- routes.produce(httpRootPathBuildItem.routeBuilder()
- .route(basePath + page.getPath())
- .handler(recorder.pageHandler(finalDestination, page.getName(), runtimeConfig))
- .build());
+ routes.produce(httpRootPathBuildItem
+ .routeBuilder()
+ .route(basePath + page.getPath())
+ .handler(recorder.pageHandler(finalDestination, page.getName(), runtimeConfig))
+ .build());
}
/* Construct static routes */
Handler<RoutingContext> staticHandler = recorder.staticHandler(
- finalDestination,
- basePath,
- result.getWebRootConfigurations(),
- runtimeConfig,
- shutdownContext
- );
-
- routes.produce(httpRootPathBuildItem.routeBuilder()
- .route(buildConfig.path)
- .displayOnNotFoundPage("OpenDC UI")
- .routeConfigKey("quarkus.opendc-ui.path")
- .handler(staticHandler)
- .build());
-
- routes.produce(httpRootPathBuildItem.routeBuilder()
- .route(buildConfig.path + "*")
- .handler(staticHandler)
- .build());
+ finalDestination, basePath, result.getWebRootConfigurations(), runtimeConfig, shutdownContext);
+
+ routes.produce(httpRootPathBuildItem
+ .routeBuilder()
+ .route(buildConfig.path)
+ .displayOnNotFoundPage("OpenDC UI")
+ .routeConfigKey("quarkus.opendc-ui.path")
+ .handler(staticHandler)
+ .build());
+
+ routes.produce(httpRootPathBuildItem
+ .routeBuilder()
+ .route(buildConfig.path + "*")
+ .handler(staticHandler)
+ .build());
}
/**
@@ -216,7 +217,6 @@ public class OpenDCUiProcessor {
private final OpenDCUiConfig config;
private final HttpRootPathBuildItem httpRootPathBuildItem;
-
public InsertVariablesResourcesFilter(OpenDCUiConfig config, HttpRootPathBuildItem httpRootPathBuildItem) {
this.config = config;
this.httpRootPathBuildItem = httpRootPathBuildItem;
@@ -304,7 +304,8 @@ public class OpenDCUiProcessor {
}
private static ResolvedDependency getAppArtifact(CurateOutcomeBuildItem curateOutcomeBuildItem, GACT artifactKey) {
- for (ResolvedDependency dep : curateOutcomeBuildItem.getApplicationModel().getDependencies()) {
+ for (ResolvedDependency dep :
+ curateOutcomeBuildItem.getApplicationModel().getDependencies()) {
if (dep.getKey().equals(artifactKey)) {
return dep;
}
diff --git a/opendc-web/opendc-web-ui-quarkus-deployment/src/main/java/org/opendc/web/ui/deployment/OpenDCUiRoutingBuildItem.java b/opendc-web/opendc-web-ui-quarkus-deployment/src/main/java/org/opendc/web/ui/deployment/OpenDCUiRoutingBuildItem.java
index 7e0f9408..6cf44893 100644
--- a/opendc-web/opendc-web-ui-quarkus-deployment/src/main/java/org/opendc/web/ui/deployment/OpenDCUiRoutingBuildItem.java
+++ b/opendc-web/opendc-web-ui-quarkus-deployment/src/main/java/org/opendc/web/ui/deployment/OpenDCUiRoutingBuildItem.java
@@ -23,7 +23,6 @@
package org.opendc.web.ui.deployment;
import io.quarkus.builder.item.SimpleBuildItem;
-
import java.util.List;
/**
@@ -57,7 +56,7 @@ public final class OpenDCUiRoutingBuildItem extends SimpleBuildItem {
}
public boolean hasCustom404() {
- return this.custom404;
+ return this.custom404;
}
/**