From 7f695ffa975a68f8b6737e7f262167031f6b83b1 Mon Sep 17 00:00:00 2001 From: Phillip Kruger Date: Tue, 16 Apr 2024 11:40:37 +1000 Subject: [PATCH] Rename webjars-locator to web-dependency-locator Signed-off-by: Phillip Kruger --- bom/application/pom.xml | 14 +++- devtools/bom-descriptor-json/pom.xml | 2 +- docs/pom.xml | 2 +- docs/src/main/asciidoc/http-reference.adoc | 82 ++++++++++++------- docs/src/main/asciidoc/web.adoc | 2 +- extensions/pom.xml | 2 +- .../deployment/pom.xml | 8 +- .../deployment/ImportMapBuildItem.java | 2 +- .../WebDependencyLocatorConfig.java} | 6 +- .../WebDependencyLocatorProcessor.java} | 14 ++-- .../deployment/devui/WebDependencyAsset.java} | 10 +-- .../WebDependencyLibrariesBuildItem.java | 23 ++++++ .../devui/WebDependencyLibrary.java | 32 ++++++++ ...DependencyLocatorDevModeApiProcessor.java} | 79 +++++++++--------- .../WebDependencyLocatorDevUIProcessor.java} | 28 +++---- .../qwc-web-dependency-locator-importmap.js} | 4 +- .../qwc-web-dependency-locator-libraries.js} | 20 ++--- .../locator/test/ImportMapTest.java | 4 +- .../locator/test/PostResource.java | 2 +- .../WebDependencyLocatorDevModeTest.java} | 4 +- .../WebDependencyLocatorRootPathTest.java} | 4 +- .../test/WebDependencyLocatorTest.java} | 4 +- .../WebDependencyLocatorTestSupport.java} | 4 +- .../pom.xml | 4 +- .../runtime/pom.xml | 8 +- .../WebDependencyLocatorRecorder.java} | 25 +++--- .../resources/META-INF/quarkus-extension.yaml | 8 +- .../devui/WebJarLibrariesBuildItem.java | 23 ------ .../deployment/devui/WebJarLibrary.java | 32 -------- relocations/generaterelocations.java | 5 ++ relocations/pom.xml | 2 + .../pom.xml | 22 +++++ relocations/quarkus-webjars-locator/pom.xml | 22 +++++ 33 files changed, 295 insertions(+), 208 deletions(-) rename extensions/{webjars-locator => web-dependency-locator}/deployment/pom.xml (93%) rename extensions/{webjars-locator/deployment/src/main/java/io/quarkus/webjar => web-dependency-locator/deployment/src/main/java/io/quarkus/webdependency}/locator/deployment/ImportMapBuildItem.java (85%) rename extensions/{webjars-locator/deployment/src/main/java/io/quarkus/webjar/locator/deployment/WebJarLocatorConfig.java => web-dependency-locator/deployment/src/main/java/io/quarkus/webdependency/locator/deployment/WebDependencyLocatorConfig.java} (72%) rename extensions/{webjars-locator/deployment/src/main/java/io/quarkus/webjar/locator/deployment/WebJarLocatorStandaloneBuildStep.java => web-dependency-locator/deployment/src/main/java/io/quarkus/webdependency/locator/deployment/WebDependencyLocatorProcessor.java} (94%) rename extensions/{webjars-locator/deployment/src/main/java/io/quarkus/webjar/locator/deployment/devui/WebJarAsset.java => web-dependency-locator/deployment/src/main/java/io/quarkus/webdependency/locator/deployment/devui/WebDependencyAsset.java} (70%) create mode 100644 extensions/web-dependency-locator/deployment/src/main/java/io/quarkus/webdependency/locator/deployment/devui/WebDependencyLibrariesBuildItem.java create mode 100644 extensions/web-dependency-locator/deployment/src/main/java/io/quarkus/webdependency/locator/deployment/devui/WebDependencyLibrary.java rename extensions/{webjars-locator/deployment/src/main/java/io/quarkus/webjar/locator/deployment/devui/WebJarLocatorDevModeApiProcessor.java => web-dependency-locator/deployment/src/main/java/io/quarkus/webdependency/locator/deployment/devui/WebDependencyLocatorDevModeApiProcessor.java} (59%) rename extensions/{webjars-locator/deployment/src/main/java/io/quarkus/webjar/locator/deployment/devui/WebJarLocatorDevUIProcessor.java => web-dependency-locator/deployment/src/main/java/io/quarkus/webdependency/locator/deployment/devui/WebDependencyLocatorDevUIProcessor.java} (54%) rename extensions/{webjars-locator/deployment/src/main/resources/dev-ui/qwc-webjar-locator-importmap.js => web-dependency-locator/deployment/src/main/resources/dev-ui/qwc-web-dependency-locator-importmap.js} (87%) rename extensions/{webjars-locator/deployment/src/main/resources/dev-ui/qwc-webjar-locator-webjar-libraries.js => web-dependency-locator/deployment/src/main/resources/dev-ui/qwc-web-dependency-locator-libraries.js} (80%) rename extensions/{webjars-locator/deployment/src/test/java/io/quarkus/webjar => web-dependency-locator/deployment/src/test/java/io/quarkus/webdependency}/locator/test/ImportMapTest.java (91%) rename extensions/{webjars-locator/deployment/src/test/java/io/quarkus/webjar => web-dependency-locator/deployment/src/test/java/io/quarkus/webdependency}/locator/test/PostResource.java (88%) rename extensions/{webjars-locator/deployment/src/test/java/io/quarkus/webjar/locator/test/WebJarLocatorDevModeTest.java => web-dependency-locator/deployment/src/test/java/io/quarkus/webdependency/locator/test/WebDependencyLocatorDevModeTest.java} (97%) rename extensions/{webjars-locator/deployment/src/test/java/io/quarkus/webjar/locator/test/WebJarLocatorRootPathTest.java => web-dependency-locator/deployment/src/test/java/io/quarkus/webdependency/locator/test/WebDependencyLocatorRootPathTest.java} (95%) rename extensions/{webjars-locator/deployment/src/test/java/io/quarkus/webjar/locator/test/WebJarLocatorTest.java => web-dependency-locator/deployment/src/test/java/io/quarkus/webdependency/locator/test/WebDependencyLocatorTest.java} (95%) rename extensions/{webjars-locator/deployment/src/test/java/io/quarkus/webjar/locator/test/WebJarLocatorTestSupport.java => web-dependency-locator/deployment/src/test/java/io/quarkus/webdependency/locator/test/WebDependencyLocatorTestSupport.java} (76%) rename extensions/{webjars-locator => web-dependency-locator}/pom.xml (84%) rename extensions/{webjars-locator => web-dependency-locator}/runtime/pom.xml (84%) rename extensions/{webjars-locator/runtime/src/main/java/io/quarkus/webjar/locator/runtime/WebJarLocatorRecorder.java => web-dependency-locator/runtime/src/main/java/io/quarkus/webdependency/locator/runtime/WebDependencyLocatorRecorder.java} (69%) rename extensions/{webjars-locator => web-dependency-locator}/runtime/src/main/resources/META-INF/quarkus-extension.yaml (51%) delete mode 100644 extensions/webjars-locator/deployment/src/main/java/io/quarkus/webjar/locator/deployment/devui/WebJarLibrariesBuildItem.java delete mode 100644 extensions/webjars-locator/deployment/src/main/java/io/quarkus/webjar/locator/deployment/devui/WebJarLibrary.java create mode 100644 relocations/quarkus-webjars-locator-deployment/pom.xml create mode 100644 relocations/quarkus-webjars-locator/pom.xml diff --git a/bom/application/pom.xml b/bom/application/pom.xml index 841bbd2f06c1f..0328d5e8631d9 100644 --- a/bom/application/pom.xml +++ b/bom/application/pom.xml @@ -3125,12 +3125,12 @@ io.quarkus - quarkus-webjars-locator + quarkus-web-dependency-locator ${project.version} io.quarkus - quarkus-webjars-locator-deployment + quarkus-web-dependency-locator-deployment ${project.version} @@ -6670,6 +6670,16 @@ quarkus-smallrye-reactive-messaging-rabbitmq-deployment ${project.version} + + io.quarkus + quarkus-webjars-locator + ${project.version} + + + io.quarkus + quarkus-webjars-locator-deployment + ${project.version} + diff --git a/devtools/bom-descriptor-json/pom.xml b/devtools/bom-descriptor-json/pom.xml index 426891e36c7da..69722b1317e61 100644 --- a/devtools/bom-descriptor-json/pom.xml +++ b/devtools/bom-descriptor-json/pom.xml @@ -2867,7 +2867,7 @@ io.quarkus - quarkus-webjars-locator + quarkus-web-dependency-locator ${project.version} pom test diff --git a/docs/pom.xml b/docs/pom.xml index e70a317eb71e5..89070a2c285f9 100644 --- a/docs/pom.xml +++ b/docs/pom.xml @@ -2883,7 +2883,7 @@ io.quarkus - quarkus-webjars-locator-deployment + quarkus-web-dependency-locator-deployment ${project.version} pom test diff --git a/docs/src/main/asciidoc/http-reference.adoc b/docs/src/main/asciidoc/http-reference.adoc index 5201ebbc4df5e..736b0649dc77d 100644 --- a/docs/src/main/asciidoc/http-reference.adoc +++ b/docs/src/main/asciidoc/http-reference.adoc @@ -10,8 +10,9 @@ include::_attributes.adoc[] :numbered: :sectnums: :sectnumlevels: 4 -:topics: http,web,webjars,vertx,servlet,undertow +:topics: http,web,webjars,mvnpm,vertx,servlet,undertow :extensions: io.quarkus:quarkus-vertx-http +:web-locator-ga: quarkus-web-dependency-locator This document clarifies different HTTP functionalities available in Quarkus. @@ -32,74 +33,95 @@ was chosen as it is the standard location for resources in `jar` files as define Quarkus can be used without Servlet, following this convention allows existing code that places its resources in this location to function correctly. -[[from-mvnpm]] -=== From mvnpm +=== From web dependencies like webjars or mvnpm -If you are using https://mvnpm.org/[mvnpm], as for the following JQuery dependency: +==== WebJars +If you are using https://www.webjars.org[WebJars], like the following JQuery one: [source,xml,role="primary asciidoc-tabs-target-sync-cli asciidoc-tabs-target-sync-maven"] .pom.xml ---- - org.mvnpm - bootstrap - 5.3.3 - runtime + org.webjars + jquery + 3.1.1 ---- [source,gradle,role="secondary asciidoc-tabs-target-sync-gradle"] .build.gradle ---- -runtimeOnly("org.mvnpm:bootstrap:5.3.3") ----- - -You can import it in your HTML like this: -[source,html] ----- - +implementation("org.webjars:jquery:3.1.1") ---- - -[[from-webjars]] -=== From WebJars - -If you are using webjars, like the following JQuery one: +and rather write `/webjars/jquery/jquery.min.js` instead of `/webjars/jquery/3.1.1/jquery.min.js` +in your HTML files, you can add the `{web-locator-ga}` extension to your project. +To use it, add the following to your project's dependencies: [source,xml,role="primary asciidoc-tabs-target-sync-cli asciidoc-tabs-target-sync-maven"] .pom.xml ---- - org.webjars - jquery - 3.1.1 + io.quarkus + {web-locator-ga} ---- [source,gradle,role="secondary asciidoc-tabs-target-sync-gradle"] .build.gradle ---- -implementation("org.webjars:jquery:3.1.1") +implementation("io.quarkus:{web-locator-ga}") ---- -and rather write `/webjars/jquery/jquery.min.js` instead of `/webjars/jquery/3.1.1/jquery.min.js` -in your HTML files, you can add the `quarkus-webjars-locator` extension to your project. -To use it, add the following to your project's dependencies: +==== Mvnpm + +If you are using https://mvnpm.org[mvnpm], like the following Lit one: [source,xml,role="primary asciidoc-tabs-target-sync-cli asciidoc-tabs-target-sync-maven"] .pom.xml ---- - io.quarkus - quarkus-webjars-locator + org.mvnpm + lit + 3.1.2 ---- [source,gradle,role="secondary asciidoc-tabs-target-sync-gradle"] .build.gradle ---- -implementation("io.quarkus:quarkus-webjars-locator") +implementation("org.mvnpm:lit:3.1.2") +---- + +you can use the `{web-locator-ga}` as described above to reference the resource without the version, however with mvnpm you can +also use https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script/type/importmap[importmaps]. + +The importmap is generated by the `{web-locator-ga}` extension, and available at `/_importmap/generated_importmap.js`. +This mean adding the following to your `index.html` will allow you to import web libraries by name: + +[source,html] ---- + + + + + + My app + + <1> + + + + + +---- +<1> Use the generated importmap +<2> Import web libraries +<3> Import your own files, this can be done by adding `quarkus.web-dependency-locator.import-mappings.app/ = /app/` to the config. Any key-value pair can be added. + === From a local directory diff --git a/docs/src/main/asciidoc/web.adoc b/docs/src/main/asciidoc/web.adoc index 1f58a62ef29fb..932f265e1d194 100644 --- a/docs/src/main/asciidoc/web.adoc +++ b/docs/src/main/asciidoc/web.adoc @@ -28,7 +28,7 @@ You can find more information in the xref:http-reference#serving-static-resource However, if you want to insert scripts, styles, and libraries in your web pages, you have 3 options: a. Consume libraries from public CDNs such as cdnjs, unpkg, jsDelivr and more, or copy them to your `META-INF/resources` directory. -b. Use runtime web dependencies such as mvnpm.org or webjars, when added to your pom.xml or build.gradle they can be directly xref:http-reference#from-mvnpm[accessed from your web pages]. +b. Use runtime web dependencies such as mvnpm.org or webjars, when added to your pom.xml or build.gradle they can be directly xref:http-reference#mvnpm[accessed from your web pages]. c. Package your scripts (js, ts), styles (css, scss), and web dependencies together using a bundler (see xref:#bundling[below]). NOTE: *We recommend using a bundler for production* as it offers better control, consistency, security, and performance. The good news is that Quarkus makes it really easy and fast with the https://docs.quarkiverse.io/quarkus-web-bundler/dev/[Quarkus Web Bundler extension]. diff --git a/extensions/pom.xml b/extensions/pom.xml index ccd152cf03acc..64169dfa035a7 100644 --- a/extensions/pom.xml +++ b/extensions/pom.xml @@ -38,7 +38,7 @@ undertow websockets websockets-next - webjars-locator + web-dependency-locator resteasy-reactive reactive-routes apache-httpclient diff --git a/extensions/webjars-locator/deployment/pom.xml b/extensions/web-dependency-locator/deployment/pom.xml similarity index 93% rename from extensions/webjars-locator/deployment/pom.xml rename to extensions/web-dependency-locator/deployment/pom.xml index c7e61954ff64b..3c540aa3dcdd5 100644 --- a/extensions/webjars-locator/deployment/pom.xml +++ b/extensions/web-dependency-locator/deployment/pom.xml @@ -3,14 +3,14 @@ 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"> - quarkus-webjars-locator-parent + quarkus-web-dependency-locator-parent io.quarkus 999-SNAPSHOT 4.0.0 - quarkus-webjars-locator-deployment - Quarkus - WebJar Locator - Deployment + quarkus-web-dependency-locator-deployment + Quarkus - Web Dependency Locator - Deployment @@ -30,7 +30,7 @@ io.quarkus - quarkus-webjars-locator + quarkus-web-dependency-locator io.mvnpm diff --git a/extensions/webjars-locator/deployment/src/main/java/io/quarkus/webjar/locator/deployment/ImportMapBuildItem.java b/extensions/web-dependency-locator/deployment/src/main/java/io/quarkus/webdependency/locator/deployment/ImportMapBuildItem.java similarity index 85% rename from extensions/webjars-locator/deployment/src/main/java/io/quarkus/webjar/locator/deployment/ImportMapBuildItem.java rename to extensions/web-dependency-locator/deployment/src/main/java/io/quarkus/webdependency/locator/deployment/ImportMapBuildItem.java index 9b951366ab031..bef3aa6a6b9ba 100644 --- a/extensions/webjars-locator/deployment/src/main/java/io/quarkus/webjar/locator/deployment/ImportMapBuildItem.java +++ b/extensions/web-dependency-locator/deployment/src/main/java/io/quarkus/webdependency/locator/deployment/ImportMapBuildItem.java @@ -1,4 +1,4 @@ -package io.quarkus.webjar.locator.deployment; +package io.quarkus.webdependency.locator.deployment; import io.quarkus.builder.item.SimpleBuildItem; diff --git a/extensions/webjars-locator/deployment/src/main/java/io/quarkus/webjar/locator/deployment/WebJarLocatorConfig.java b/extensions/web-dependency-locator/deployment/src/main/java/io/quarkus/webdependency/locator/deployment/WebDependencyLocatorConfig.java similarity index 72% rename from extensions/webjars-locator/deployment/src/main/java/io/quarkus/webjar/locator/deployment/WebJarLocatorConfig.java rename to extensions/web-dependency-locator/deployment/src/main/java/io/quarkus/webdependency/locator/deployment/WebDependencyLocatorConfig.java index 2676e483b2c79..6592ea84704d1 100644 --- a/extensions/webjars-locator/deployment/src/main/java/io/quarkus/webjar/locator/deployment/WebJarLocatorConfig.java +++ b/extensions/web-dependency-locator/deployment/src/main/java/io/quarkus/webdependency/locator/deployment/WebDependencyLocatorConfig.java @@ -1,4 +1,4 @@ -package io.quarkus.webjar.locator.deployment; +package io.quarkus.webdependency.locator.deployment; import java.util.Map; @@ -6,10 +6,10 @@ import io.quarkus.runtime.annotations.ConfigRoot; /** - * Build time configuration for WebJar Locator. + * Build time configuration for Web Dependency Locator. */ @ConfigRoot -public class WebJarLocatorConfig { +public class WebDependencyLocatorConfig { /** * If the version reroute is enabled. diff --git a/extensions/webjars-locator/deployment/src/main/java/io/quarkus/webjar/locator/deployment/WebJarLocatorStandaloneBuildStep.java b/extensions/web-dependency-locator/deployment/src/main/java/io/quarkus/webdependency/locator/deployment/WebDependencyLocatorProcessor.java similarity index 94% rename from extensions/webjars-locator/deployment/src/main/java/io/quarkus/webjar/locator/deployment/WebJarLocatorStandaloneBuildStep.java rename to extensions/web-dependency-locator/deployment/src/main/java/io/quarkus/webdependency/locator/deployment/WebDependencyLocatorProcessor.java index bf3af18e035a1..2841ccae3bfc1 100644 --- a/extensions/webjars-locator/deployment/src/main/java/io/quarkus/webjar/locator/deployment/WebJarLocatorStandaloneBuildStep.java +++ b/extensions/web-dependency-locator/deployment/src/main/java/io/quarkus/webdependency/locator/deployment/WebDependencyLocatorProcessor.java @@ -1,4 +1,4 @@ -package io.quarkus.webjar.locator.deployment; +package io.quarkus.webdependency.locator.deployment; import java.io.IOException; import java.io.UncheckedIOException; @@ -29,11 +29,11 @@ import io.quarkus.maven.dependency.ResolvedDependency; import io.quarkus.vertx.http.deployment.RouteBuildItem; import io.quarkus.vertx.http.runtime.HttpBuildTimeConfig; -import io.quarkus.webjar.locator.runtime.WebJarLocatorRecorder; +import io.quarkus.webdependency.locator.runtime.WebDependencyLocatorRecorder; import io.vertx.core.Handler; import io.vertx.ext.web.RoutingContext; -public class WebJarLocatorStandaloneBuildStep { +public class WebDependencyLocatorProcessor { private static final String WEBJARS_PREFIX = "META-INF/resources/webjars"; private static final String WEBJARS_NAME = "webjars"; @@ -41,18 +41,18 @@ public class WebJarLocatorStandaloneBuildStep { private static final String MVNPM_PREFIX = "META-INF/resources/_static"; private static final String MVNPM_NAME = "mvnpm"; - private static final Logger log = Logger.getLogger(WebJarLocatorStandaloneBuildStep.class.getName()); + private static final Logger log = Logger.getLogger(WebDependencyLocatorProcessor.class.getName()); @BuildStep @Record(ExecutionTime.RUNTIME_INIT) - public void findWebjarsAndCreateHandler( - WebJarLocatorConfig config, + public void findWebDependenciesAndCreateHandler( + WebDependencyLocatorConfig config, HttpBuildTimeConfig httpConfig, BuildProducer feature, BuildProducer routes, BuildProducer im, CurateOutcomeBuildItem curateOutcome, - WebJarLocatorRecorder recorder) throws Exception { + WebDependencyLocatorRecorder recorder) throws Exception { LibInfo webjarsLibInfo = getLibInfo(curateOutcome, WEBJARS_PREFIX, WEBJARS_NAME); LibInfo mvnpmNameLibInfo = getLibInfo(curateOutcome, MVNPM_PREFIX, MVNPM_NAME); diff --git a/extensions/webjars-locator/deployment/src/main/java/io/quarkus/webjar/locator/deployment/devui/WebJarAsset.java b/extensions/web-dependency-locator/deployment/src/main/java/io/quarkus/webdependency/locator/deployment/devui/WebDependencyAsset.java similarity index 70% rename from extensions/webjars-locator/deployment/src/main/java/io/quarkus/webjar/locator/deployment/devui/WebJarAsset.java rename to extensions/web-dependency-locator/deployment/src/main/java/io/quarkus/webdependency/locator/deployment/devui/WebDependencyAsset.java index 75b488dfd92bb..aa455eb2e5d90 100644 --- a/extensions/webjars-locator/deployment/src/main/java/io/quarkus/webjar/locator/deployment/devui/WebJarAsset.java +++ b/extensions/web-dependency-locator/deployment/src/main/java/io/quarkus/webdependency/locator/deployment/devui/WebDependencyAsset.java @@ -1,11 +1,11 @@ -package io.quarkus.webjar.locator.deployment.devui; +package io.quarkus.webdependency.locator.deployment.devui; import java.util.List; -public class WebJarAsset { +public class WebDependencyAsset { private String name; - private List children; + private List children; private boolean fileAsset; private String urlPart; @@ -17,11 +17,11 @@ public void setName(String name) { this.name = name; } - public List getChildren() { + public List getChildren() { return children; } - public void setChildren(List children) { + public void setChildren(List children) { this.children = children; } diff --git a/extensions/web-dependency-locator/deployment/src/main/java/io/quarkus/webdependency/locator/deployment/devui/WebDependencyLibrariesBuildItem.java b/extensions/web-dependency-locator/deployment/src/main/java/io/quarkus/webdependency/locator/deployment/devui/WebDependencyLibrariesBuildItem.java new file mode 100644 index 0000000000000..aaa5dfdcba7ed --- /dev/null +++ b/extensions/web-dependency-locator/deployment/src/main/java/io/quarkus/webdependency/locator/deployment/devui/WebDependencyLibrariesBuildItem.java @@ -0,0 +1,23 @@ +package io.quarkus.webdependency.locator.deployment.devui; + +import java.util.List; + +import io.quarkus.builder.item.MultiBuildItem; + +public final class WebDependencyLibrariesBuildItem extends MultiBuildItem { + private final String provider; + private final List webDependencyLibraries; + + public WebDependencyLibrariesBuildItem(String provider, List webDependencyLibraries) { + this.provider = provider; + this.webDependencyLibraries = webDependencyLibraries; + } + + public List getWebDependencyLibraries() { + return this.webDependencyLibraries; + } + + public String getProvider() { + return this.provider; + } +} diff --git a/extensions/web-dependency-locator/deployment/src/main/java/io/quarkus/webdependency/locator/deployment/devui/WebDependencyLibrary.java b/extensions/web-dependency-locator/deployment/src/main/java/io/quarkus/webdependency/locator/deployment/devui/WebDependencyLibrary.java new file mode 100644 index 0000000000000..899fb51901fcd --- /dev/null +++ b/extensions/web-dependency-locator/deployment/src/main/java/io/quarkus/webdependency/locator/deployment/devui/WebDependencyLibrary.java @@ -0,0 +1,32 @@ +package io.quarkus.webdependency.locator.deployment.devui; + +public class WebDependencyLibrary { + + private final String webDependencyName; + private String version; + private WebDependencyAsset rootAsset; // must be a list to work with vaadin-grid + + public WebDependencyLibrary(String webDependencyName) { + this.webDependencyName = webDependencyName; + } + + public String getWebDependencyName() { + return webDependencyName; + } + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public WebDependencyAsset getRootAsset() { + return rootAsset; + } + + public void setRootAsset(WebDependencyAsset rootAsset) { + this.rootAsset = rootAsset; + } +} diff --git a/extensions/webjars-locator/deployment/src/main/java/io/quarkus/webjar/locator/deployment/devui/WebJarLocatorDevModeApiProcessor.java b/extensions/web-dependency-locator/deployment/src/main/java/io/quarkus/webdependency/locator/deployment/devui/WebDependencyLocatorDevModeApiProcessor.java similarity index 59% rename from extensions/webjars-locator/deployment/src/main/java/io/quarkus/webjar/locator/deployment/devui/WebJarLocatorDevModeApiProcessor.java rename to extensions/web-dependency-locator/deployment/src/main/java/io/quarkus/webdependency/locator/deployment/devui/WebDependencyLocatorDevModeApiProcessor.java index cc2c688e56ea3..5a5ef624e6c2d 100644 --- a/extensions/webjars-locator/deployment/src/main/java/io/quarkus/webjar/locator/deployment/devui/WebJarLocatorDevModeApiProcessor.java +++ b/extensions/web-dependency-locator/deployment/src/main/java/io/quarkus/webdependency/locator/deployment/devui/WebDependencyLocatorDevModeApiProcessor.java @@ -1,4 +1,4 @@ -package io.quarkus.webjar.locator.deployment.devui; +package io.quarkus.webdependency.locator.deployment.devui; import java.io.IOException; import java.io.UncheckedIOException; @@ -28,79 +28,80 @@ import io.quarkus.maven.dependency.ResolvedDependency; import io.quarkus.vertx.http.runtime.HttpBuildTimeConfig; -public class WebJarLocatorDevModeApiProcessor { +public class WebDependencyLocatorDevModeApiProcessor { private static final String PREFIX = "META-INF/resources/"; private static final String WEBJARS_PATH = "webjars"; private static final String MVNPM_PATH = "_static"; - private static final Logger log = Logger.getLogger(WebJarLocatorDevModeApiProcessor.class.getName()); + private static final Logger log = Logger.getLogger(WebDependencyLocatorDevModeApiProcessor.class.getName()); @BuildStep(onlyIf = IsDevelopment.class) - public void findWebjarsAssets( + public void findWebDependenciesAssets( HttpBuildTimeConfig httpConfig, CurateOutcomeBuildItem curateOutcome, - BuildProducer webJarLibrariesProducer) { + BuildProducer webDependencyLibrariesProducer) { - final List webJarLibraries = getLibraries(httpConfig, curateOutcome, WEBJARS_PATH); - webJarLibrariesProducer.produce(new WebJarLibrariesBuildItem("webjars", webJarLibraries)); + final List webJarLibraries = getLibraries(httpConfig, curateOutcome, WEBJARS_PATH); + webDependencyLibrariesProducer.produce(new WebDependencyLibrariesBuildItem("webjars", webJarLibraries)); - final List mvnpmLibraries = getLibraries(httpConfig, curateOutcome, MVNPM_PATH); - webJarLibrariesProducer.produce(new WebJarLibrariesBuildItem("mvnpm", mvnpmLibraries)); + final List mvnpmLibraries = getLibraries(httpConfig, curateOutcome, MVNPM_PATH); + webDependencyLibrariesProducer.produce(new WebDependencyLibrariesBuildItem("mvnpm", mvnpmLibraries)); } - private List getLibraries(HttpBuildTimeConfig httpConfig, + private List getLibraries(HttpBuildTimeConfig httpConfig, CurateOutcomeBuildItem curateOutcome, String path) { - final List webJarLibraries = new ArrayList<>(); + final List webDependencyLibraries = new ArrayList<>(); final List providers = QuarkusClassLoader.getElements(PREFIX + path, false); if (!providers.isEmpty()) { - // Map of webjar artifact keys to class path elements - final Map webJarKeys = providers.stream() + // Map of webDependency artifact keys to class path elements + final Map webDependencyKeys = providers.stream() .filter(provider -> provider.getDependencyKey() != null && provider.isRuntime()) .collect(Collectors.toMap(ClassPathElement::getDependencyKey, provider -> provider, (a, b) -> b, () -> new HashMap<>(providers.size()))); - if (!webJarKeys.isEmpty()) { + if (!webDependencyKeys.isEmpty()) { // The root path of the application final String rootPath = httpConfig.rootPath; - // The root path of the webjars - final String webjarRootPath = (rootPath.endsWith("/")) ? rootPath + path + "/" : rootPath + "/" + path + "/"; + // The root path of the webDependencies + final String webDependencyRootPath = (rootPath.endsWith("/")) ? rootPath + path + "/" + : rootPath + "/" + path + "/"; - // For each packaged webjar dependency, create a WebJarLibrary object + // For each packaged web dependency, create a WebDependencyLibrary object curateOutcome.getApplicationModel().getDependencies().stream() - .map(dep -> createWebJarLibrary(dep, webjarRootPath, webJarKeys, path)) - .filter(Objects::nonNull).forEach(webJarLibraries::add); + .map(dep -> createWebDependencyLibrary(dep, webDependencyRootPath, webDependencyKeys, path)) + .filter(Objects::nonNull).forEach(webDependencyLibraries::add); } } - return webJarLibraries; + return webDependencyLibraries; } - private WebJarLibrary createWebJarLibrary(ResolvedDependency dep, - String webjarRootPath, - Map webJarKeys, + private WebDependencyLibrary createWebDependencyLibrary(ResolvedDependency dep, + String webDependencyRootPath, + Map webDependencyKeys, String path) { // If the dependency is not a runtime class path dependency, return null if (!dep.isRuntimeCp()) { return null; } - final ClassPathElement provider = webJarKeys.get(dep.getKey()); + final ClassPathElement provider = webDependencyKeys.get(dep.getKey()); if (provider == null) { return null; } - final WebJarLibrary webJarLibrary = new WebJarLibrary(provider.getDependencyKey().getArtifactId()); + final WebDependencyLibrary webDependencyLibrary = new WebDependencyLibrary(provider.getDependencyKey().getArtifactId()); provider.apply(tree -> { - final Path webjarsDir = tree.getPath(PREFIX + path); + final Path webDependenciesDir = tree.getPath(PREFIX + path); final Path nameDir; - try (Stream webjarsDirPaths = Files.list(webjarsDir)) { - nameDir = webjarsDirPaths.filter(Files::isDirectory).findFirst().orElseThrow(() -> new IOException( - "Could not find name directory for " + dep.getKey().getArtifactId() + " in " + webjarsDir)); + try (Stream webDependenciesDirPaths = Files.list(webDependenciesDir)) { + nameDir = webDependenciesDirPaths.filter(Files::isDirectory).findFirst().orElseThrow(() -> new IOException( + "Could not find name directory for " + dep.getKey().getArtifactId() + " in " + webDependenciesDir)); } catch (IOException e) { throw new UncheckedIOException(e); } final Path versionDir; Path root = nameDir; - // The base URL for the webjar - final StringBuilder urlBase = new StringBuilder(webjarRootPath); + // The base URL for the Web Dependency + final StringBuilder urlBase = new StringBuilder(webDependencyRootPath); boolean appendRootPart = true; try { // If the version directory exists, use it as a root, otherwise use the name directory @@ -113,11 +114,11 @@ private WebJarLibrary createWebJarLibrary(ResolvedDependency dep, log.warn("Could not find version directory for " + dep.getKey().getArtifactId() + " " + dep.getVersion() + " in " + nameDir + ", falling back to name directory"); } - webJarLibrary.setVersion(dep.getVersion()); + webDependencyLibrary.setVersion(dep.getVersion()); try { - // Create the asset tree for the webjar and set it as the root asset + // Create the asset tree for the web dependency and set it as the root asset var asset = createAssetForLibrary(root, urlBase.toString(), appendRootPart); - webJarLibrary.setRootAsset(asset); + webDependencyLibrary.setRootAsset(asset); } catch (IOException e) { throw new UncheckedIOException(e); } @@ -125,13 +126,13 @@ private WebJarLibrary createWebJarLibrary(ResolvedDependency dep, return null; }); - return webJarLibrary; + return webDependencyLibrary; } - private WebJarAsset createAssetForLibrary(Path rootPath, String urlBase, boolean appendRootPart) + private WebDependencyAsset createAssetForLibrary(Path rootPath, String urlBase, boolean appendRootPart) throws IOException { //If it is a directory, go deeper, otherwise add the file - var root = new WebJarAsset(); + var root = new WebDependencyAsset(); root.setName(rootPath.getFileName().toString()); root.setChildren(new LinkedList<>()); root.setFileAsset(false); @@ -143,7 +144,7 @@ private WebJarAsset createAssetForLibrary(Path rootPath, String urlBase, boolean var childDir = createAssetForLibrary(childPath, urlBase, true); root.getChildren().add(childDir); } else { - var childFile = new WebJarAsset(); + var childFile = new WebDependencyAsset(); childFile.setName(childPath.getFileName().toString()); childFile.setFileAsset(true); childFile.setUrlPart(urlBase + childFile.getName()); @@ -152,7 +153,7 @@ private WebJarAsset createAssetForLibrary(Path rootPath, String urlBase, boolean } } // Sort the children by name - root.getChildren().sort(Comparator.comparing(WebJarAsset::getName)); + root.getChildren().sort(Comparator.comparing(WebDependencyAsset::getName)); return root; } diff --git a/extensions/webjars-locator/deployment/src/main/java/io/quarkus/webjar/locator/deployment/devui/WebJarLocatorDevUIProcessor.java b/extensions/web-dependency-locator/deployment/src/main/java/io/quarkus/webdependency/locator/deployment/devui/WebDependencyLocatorDevUIProcessor.java similarity index 54% rename from extensions/webjars-locator/deployment/src/main/java/io/quarkus/webjar/locator/deployment/devui/WebJarLocatorDevUIProcessor.java rename to extensions/web-dependency-locator/deployment/src/main/java/io/quarkus/webdependency/locator/deployment/devui/WebDependencyLocatorDevUIProcessor.java index c13cf38105351..d4079a352e21d 100644 --- a/extensions/webjars-locator/deployment/src/main/java/io/quarkus/webjar/locator/deployment/devui/WebJarLocatorDevUIProcessor.java +++ b/extensions/web-dependency-locator/deployment/src/main/java/io/quarkus/webdependency/locator/deployment/devui/WebDependencyLocatorDevUIProcessor.java @@ -1,4 +1,4 @@ -package io.quarkus.webjar.locator.deployment.devui; +package io.quarkus.webdependency.locator.deployment.devui; import java.util.ArrayList; import java.util.List; @@ -9,38 +9,38 @@ import io.quarkus.deployment.annotations.BuildStep; import io.quarkus.devui.spi.page.CardPageBuildItem; import io.quarkus.devui.spi.page.Page; -import io.quarkus.webjar.locator.deployment.ImportMapBuildItem; +import io.quarkus.webdependency.locator.deployment.ImportMapBuildItem; -public class WebJarLocatorDevUIProcessor { +public class WebDependencyLocatorDevUIProcessor { @BuildStep(onlyIf = IsDevelopment.class) public void createPages(BuildProducer cardPageProducer, - List webJarLibrariesBuildItems, + List webDependencyLibrariesBuildItems, Optional importMapBuildItem) { - List webJarLibraries = new ArrayList<>(); - for (WebJarLibrariesBuildItem webJarLibrariesBuildItem : webJarLibrariesBuildItems) { - webJarLibraries.addAll(webJarLibrariesBuildItem.getWebJarLibraries()); + List webDependencyLibraries = new ArrayList<>(); + for (WebDependencyLibrariesBuildItem webDependencyLibrariesBuildItem : webDependencyLibrariesBuildItems) { + webDependencyLibraries.addAll(webDependencyLibrariesBuildItem.getWebDependencyLibraries()); } CardPageBuildItem cardPageBuildItem = new CardPageBuildItem(); - if (!webJarLibraries.isEmpty()) { - // WebJar Libraries - cardPageBuildItem.addBuildTimeData("webJarLibraries", webJarLibraries); + if (!webDependencyLibraries.isEmpty()) { + // Web Dependency Libraries + cardPageBuildItem.addBuildTimeData("webDependencyLibraries", webDependencyLibraries); - // WebJar Asset List + // Web Dependency Asset List cardPageBuildItem.addPage(Page.webComponentPageBuilder() - .componentLink("qwc-webjar-locator-webjar-libraries.js") + .componentLink("qwc-web-dependency-locator-libraries.js") .title("Web libraries") .icon("font-awesome-solid:folder-tree") - .staticLabel(String.valueOf(webJarLibraries.size()))); + .staticLabel(String.valueOf(webDependencyLibraries.size()))); if (importMapBuildItem.isPresent()) { cardPageBuildItem.addBuildTimeData("importMap", importMapBuildItem.get().getImportMap()); // ImportMap cardPageBuildItem.addPage(Page.webComponentPageBuilder() - .componentLink("qwc-webjar-locator-importmap.js") + .componentLink("qwc-web-dependency-locator-importmap.js") .title("Import Map") .icon("font-awesome-solid:diagram-project")); diff --git a/extensions/webjars-locator/deployment/src/main/resources/dev-ui/qwc-webjar-locator-importmap.js b/extensions/web-dependency-locator/deployment/src/main/resources/dev-ui/qwc-web-dependency-locator-importmap.js similarity index 87% rename from extensions/webjars-locator/deployment/src/main/resources/dev-ui/qwc-webjar-locator-importmap.js rename to extensions/web-dependency-locator/deployment/src/main/resources/dev-ui/qwc-web-dependency-locator-importmap.js index fa732bb3ff901..7e61772282b07 100644 --- a/extensions/webjars-locator/deployment/src/main/resources/dev-ui/qwc-webjar-locator-importmap.js +++ b/extensions/web-dependency-locator/deployment/src/main/resources/dev-ui/qwc-web-dependency-locator-importmap.js @@ -3,7 +3,7 @@ import {importMap} from 'build-time-data'; import '@quarkus-webcomponents/codeblock'; -export class QwcWebjarLocatorImportmap extends LitElement { +export class QwcWebDependencyLocatorImportmap extends LitElement { static styles = css` :host{ @@ -45,4 +45,4 @@ export class QwcWebjarLocatorImportmap extends LitElement { } } -customElements.define('qwc-webjar-locator-importmap', QwcWebjarLocatorImportmap) \ No newline at end of file +customElements.define('qwc-web-dependency-locator-importmap', QwcWebDependencyLocatorImportmap) \ No newline at end of file diff --git a/extensions/webjars-locator/deployment/src/main/resources/dev-ui/qwc-webjar-locator-webjar-libraries.js b/extensions/web-dependency-locator/deployment/src/main/resources/dev-ui/qwc-web-dependency-locator-libraries.js similarity index 80% rename from extensions/webjars-locator/deployment/src/main/resources/dev-ui/qwc-webjar-locator-webjar-libraries.js rename to extensions/web-dependency-locator/deployment/src/main/resources/dev-ui/qwc-web-dependency-locator-libraries.js index 576e6fe5d75ec..c74d9fc1261f9 100644 --- a/extensions/webjars-locator/deployment/src/main/resources/dev-ui/qwc-webjar-locator-webjar-libraries.js +++ b/extensions/web-dependency-locator/deployment/src/main/resources/dev-ui/qwc-web-dependency-locator-libraries.js @@ -1,5 +1,5 @@ import {LitElement, html, css} from 'lit'; -import {webJarLibraries} from 'build-time-data'; +import {webDependencyLibraries} from 'build-time-data'; import '@vaadin/tabsheet'; import '@vaadin/tabs'; import '@vaadin/grid'; @@ -10,7 +10,7 @@ import {notifier} from 'notifier'; import {columnBodyRenderer} from '@vaadin/grid/lit.js'; -export class QwcWebjarLocatorWebjarLibraries extends LitElement { +export class QwcWebDependencyLocatorLibraries extends LitElement { static styles = css` .full-height { @@ -19,25 +19,25 @@ export class QwcWebjarLocatorWebjarLibraries extends LitElement { `; static properties = { - _webJarLibraries: {}, + _webDependencyLibraries: {}, }; constructor() { super(); - this._webJarLibraries = webJarLibraries; + this._webDependencyLibraries = webDependencyLibraries; } render() { return html` - ${this._webJarLibraries.map(webjar => html` - - ${webjar.webJarName + " (" + webjar.version + ")"} + ${this._webDependencyLibraries.map(webDependency => html` + + ${webDependency.webDependencyName + " (" + webDependency.version + ")"} `)} - ${this._webJarLibraries.map(webjar => this._renderLibraryAssets(webjar))} + ${this._webDependencyLibraries.map(webDependency => this._renderLibraryAssets(webDependency))} @@ -54,7 +54,7 @@ export class QwcWebjarLocatorWebjarLibraries extends LitElement { }; return html` -
+
@@ -101,4 +101,4 @@ export class QwcWebjarLocatorWebjarLibraries extends LitElement { } -customElements.define('qwc-webjar-locator-webjar-libraries', QwcWebjarLocatorWebjarLibraries) \ No newline at end of file +customElements.define('qwc-web-dependency-locator-libraries', QwcWebDependencyLocatorLibraries) \ No newline at end of file diff --git a/extensions/webjars-locator/deployment/src/test/java/io/quarkus/webjar/locator/test/ImportMapTest.java b/extensions/web-dependency-locator/deployment/src/test/java/io/quarkus/webdependency/locator/test/ImportMapTest.java similarity index 91% rename from extensions/webjars-locator/deployment/src/test/java/io/quarkus/webjar/locator/test/ImportMapTest.java rename to extensions/web-dependency-locator/deployment/src/test/java/io/quarkus/webdependency/locator/test/ImportMapTest.java index 02f01cb64b614..d8e33b7463bf1 100644 --- a/extensions/webjars-locator/deployment/src/test/java/io/quarkus/webjar/locator/test/ImportMapTest.java +++ b/extensions/web-dependency-locator/deployment/src/test/java/io/quarkus/webdependency/locator/test/ImportMapTest.java @@ -1,4 +1,4 @@ -package io.quarkus.webjar.locator.test; +package io.quarkus.webdependency.locator.test; import static org.hamcrest.Matchers.containsString; @@ -12,7 +12,7 @@ import io.quarkus.test.QuarkusUnitTest; import io.restassured.RestAssured; -public class ImportMapTest extends WebJarLocatorTestSupport { +public class ImportMapTest extends WebDependencyLocatorTestSupport { private static final String META_INF_RESOURCES = "META-INF/resources/"; @RegisterExtension diff --git a/extensions/webjars-locator/deployment/src/test/java/io/quarkus/webjar/locator/test/PostResource.java b/extensions/web-dependency-locator/deployment/src/test/java/io/quarkus/webdependency/locator/test/PostResource.java similarity index 88% rename from extensions/webjars-locator/deployment/src/test/java/io/quarkus/webjar/locator/test/PostResource.java rename to extensions/web-dependency-locator/deployment/src/test/java/io/quarkus/webdependency/locator/test/PostResource.java index f595f6478dcdf..60f13a0ab3913 100644 --- a/extensions/webjars-locator/deployment/src/test/java/io/quarkus/webjar/locator/test/PostResource.java +++ b/extensions/web-dependency-locator/deployment/src/test/java/io/quarkus/webdependency/locator/test/PostResource.java @@ -1,4 +1,4 @@ -package io.quarkus.webjar.locator.test; +package io.quarkus.webdependency.locator.test; import jakarta.annotation.PreDestroy; import jakarta.ws.rs.POST; diff --git a/extensions/webjars-locator/deployment/src/test/java/io/quarkus/webjar/locator/test/WebJarLocatorDevModeTest.java b/extensions/web-dependency-locator/deployment/src/test/java/io/quarkus/webdependency/locator/test/WebDependencyLocatorDevModeTest.java similarity index 97% rename from extensions/webjars-locator/deployment/src/test/java/io/quarkus/webjar/locator/test/WebJarLocatorDevModeTest.java rename to extensions/web-dependency-locator/deployment/src/test/java/io/quarkus/webdependency/locator/test/WebDependencyLocatorDevModeTest.java index fad3ee7262948..104155f574d27 100644 --- a/extensions/webjars-locator/deployment/src/test/java/io/quarkus/webjar/locator/test/WebJarLocatorDevModeTest.java +++ b/extensions/web-dependency-locator/deployment/src/test/java/io/quarkus/webdependency/locator/test/WebDependencyLocatorDevModeTest.java @@ -1,4 +1,4 @@ -package io.quarkus.webjar.locator.test; +package io.quarkus.webdependency.locator.test; import static org.hamcrest.core.Is.is; @@ -10,7 +10,7 @@ import io.quarkus.test.QuarkusDevModeTest; import io.restassured.RestAssured; -public class WebJarLocatorDevModeTest extends WebJarLocatorTestSupport { +public class WebDependencyLocatorDevModeTest extends WebDependencyLocatorTestSupport { private static final String META_INF_RESOURCES = "META-INF/resources/"; @RegisterExtension diff --git a/extensions/webjars-locator/deployment/src/test/java/io/quarkus/webjar/locator/test/WebJarLocatorRootPathTest.java b/extensions/web-dependency-locator/deployment/src/test/java/io/quarkus/webdependency/locator/test/WebDependencyLocatorRootPathTest.java similarity index 95% rename from extensions/webjars-locator/deployment/src/test/java/io/quarkus/webjar/locator/test/WebJarLocatorRootPathTest.java rename to extensions/web-dependency-locator/deployment/src/test/java/io/quarkus/webdependency/locator/test/WebDependencyLocatorRootPathTest.java index 6efa49606eb43..013dd4bba1e3f 100644 --- a/extensions/webjars-locator/deployment/src/test/java/io/quarkus/webjar/locator/test/WebJarLocatorRootPathTest.java +++ b/extensions/web-dependency-locator/deployment/src/test/java/io/quarkus/webdependency/locator/test/WebDependencyLocatorRootPathTest.java @@ -1,4 +1,4 @@ -package io.quarkus.webjar.locator.test; +package io.quarkus.webdependency.locator.test; import static org.hamcrest.core.Is.is; @@ -12,7 +12,7 @@ import io.quarkus.test.QuarkusUnitTest; import io.restassured.RestAssured; -public class WebJarLocatorRootPathTest extends WebJarLocatorTestSupport { +public class WebDependencyLocatorRootPathTest extends WebDependencyLocatorTestSupport { private static final String META_INF_RESOURCES = "META-INF/resources/"; @RegisterExtension diff --git a/extensions/webjars-locator/deployment/src/test/java/io/quarkus/webjar/locator/test/WebJarLocatorTest.java b/extensions/web-dependency-locator/deployment/src/test/java/io/quarkus/webdependency/locator/test/WebDependencyLocatorTest.java similarity index 95% rename from extensions/webjars-locator/deployment/src/test/java/io/quarkus/webjar/locator/test/WebJarLocatorTest.java rename to extensions/web-dependency-locator/deployment/src/test/java/io/quarkus/webdependency/locator/test/WebDependencyLocatorTest.java index 715a2d042f187..9bd790756e09d 100644 --- a/extensions/webjars-locator/deployment/src/test/java/io/quarkus/webjar/locator/test/WebJarLocatorTest.java +++ b/extensions/web-dependency-locator/deployment/src/test/java/io/quarkus/webdependency/locator/test/WebDependencyLocatorTest.java @@ -1,4 +1,4 @@ -package io.quarkus.webjar.locator.test; +package io.quarkus.webdependency.locator.test; import static org.hamcrest.core.Is.is; @@ -12,7 +12,7 @@ import io.quarkus.test.QuarkusUnitTest; import io.restassured.RestAssured; -public class WebJarLocatorTest extends WebJarLocatorTestSupport { +public class WebDependencyLocatorTest extends WebDependencyLocatorTestSupport { private static final String META_INF_RESOURCES = "META-INF/resources/"; @RegisterExtension diff --git a/extensions/webjars-locator/deployment/src/test/java/io/quarkus/webjar/locator/test/WebJarLocatorTestSupport.java b/extensions/web-dependency-locator/deployment/src/test/java/io/quarkus/webdependency/locator/test/WebDependencyLocatorTestSupport.java similarity index 76% rename from extensions/webjars-locator/deployment/src/test/java/io/quarkus/webjar/locator/test/WebJarLocatorTestSupport.java rename to extensions/web-dependency-locator/deployment/src/test/java/io/quarkus/webdependency/locator/test/WebDependencyLocatorTestSupport.java index 0afe0cfae437c..64dce233c1ea0 100644 --- a/extensions/webjars-locator/deployment/src/test/java/io/quarkus/webjar/locator/test/WebJarLocatorTestSupport.java +++ b/extensions/web-dependency-locator/deployment/src/test/java/io/quarkus/webdependency/locator/test/WebDependencyLocatorTestSupport.java @@ -1,6 +1,6 @@ -package io.quarkus.webjar.locator.test; +package io.quarkus.webdependency.locator.test; -class WebJarLocatorTestSupport { +class WebDependencyLocatorTestSupport { static final String JQUERY_UI_VERSION = System.getProperty("webjar.jquery-ui.version"); static final String MOMENTJS_VERSION = System.getProperty("webjar.momentjs.version"); diff --git a/extensions/webjars-locator/pom.xml b/extensions/web-dependency-locator/pom.xml similarity index 84% rename from extensions/webjars-locator/pom.xml rename to extensions/web-dependency-locator/pom.xml index 62e69ce2dd90b..b856aa3b890f9 100644 --- a/extensions/webjars-locator/pom.xml +++ b/extensions/web-dependency-locator/pom.xml @@ -10,8 +10,8 @@ 4.0.0 - quarkus-webjars-locator-parent - Quarkus - WebJar Locator + quarkus-web-dependency-locator-parent + Quarkus - Web Dependency Locator pom deployment diff --git a/extensions/webjars-locator/runtime/pom.xml b/extensions/web-dependency-locator/runtime/pom.xml similarity index 84% rename from extensions/webjars-locator/runtime/pom.xml rename to extensions/web-dependency-locator/runtime/pom.xml index 5b7b55e4cdcb1..51703d373ba25 100644 --- a/extensions/webjars-locator/runtime/pom.xml +++ b/extensions/web-dependency-locator/runtime/pom.xml @@ -3,15 +3,15 @@ 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"> - quarkus-webjars-locator-parent + quarkus-web-dependency-locator-parent io.quarkus 999-SNAPSHOT 4.0.0 - quarkus-webjars-locator - Quarkus - WebJar Locator - Runtime - Simplify paths for WebJar dependencies + quarkus-web-dependency-locator + Quarkus - Web Dependency Locator - Runtime + Simplify paths and importmap support for Web dependencies diff --git a/extensions/webjars-locator/runtime/src/main/java/io/quarkus/webjar/locator/runtime/WebJarLocatorRecorder.java b/extensions/web-dependency-locator/runtime/src/main/java/io/quarkus/webdependency/locator/runtime/WebDependencyLocatorRecorder.java similarity index 69% rename from extensions/webjars-locator/runtime/src/main/java/io/quarkus/webjar/locator/runtime/WebJarLocatorRecorder.java rename to extensions/web-dependency-locator/runtime/src/main/java/io/quarkus/webdependency/locator/runtime/WebDependencyLocatorRecorder.java index 55f22be5cf44a..2e27661e4480a 100644 --- a/extensions/webjars-locator/runtime/src/main/java/io/quarkus/webjar/locator/runtime/WebJarLocatorRecorder.java +++ b/extensions/web-dependency-locator/runtime/src/main/java/io/quarkus/webdependency/locator/runtime/WebDependencyLocatorRecorder.java @@ -1,4 +1,4 @@ -package io.quarkus.webjar.locator.runtime; +package io.quarkus.webdependency.locator.runtime; import java.util.Map; @@ -9,32 +9,33 @@ import io.vertx.ext.web.RoutingContext; @Recorder -public class WebJarLocatorRecorder { +public class WebDependencyLocatorRecorder { - public Handler getHandler(String webjarsRootUrl, Map webjarNameToVersionMap) { + public Handler getHandler(String webDependenciesRootUrl, + Map webDependencyNameToVersionMap) { return (event) -> { String path = event.normalizedPath(); - if (path.startsWith(webjarsRootUrl)) { - String rest = path.substring(webjarsRootUrl.length()); - String webjar = rest.substring(0, rest.indexOf('/')); - if (webjarNameToVersionMap.containsKey(webjar)) { + if (path.startsWith(webDependenciesRootUrl)) { + String rest = path.substring(webDependenciesRootUrl.length()); + String webdep = rest.substring(0, rest.indexOf('/')); + if (webDependencyNameToVersionMap.containsKey(webdep)) { // Check this is not the actual path (ex: /webjars/jquery/${jquery.version}/... int endOfVersion = rest.indexOf('/', rest.indexOf('/') + 1); if (endOfVersion == -1) { endOfVersion = rest.length(); } String nextPathEntry = rest.substring(rest.indexOf('/') + 1, endOfVersion); - if (webjarNameToVersionMap.get(webjar) == null - || nextPathEntry.equals(webjarNameToVersionMap.get(webjar))) { + if (webDependencyNameToVersionMap.get(webdep) == null + || nextPathEntry.equals(webDependencyNameToVersionMap.get(webdep))) { // go to the next handler (which should be the static resource handler, if one exists) event.next(); } else { // reroute to the real resource - event.reroute(webjarsRootUrl + webjar + "/" - + webjarNameToVersionMap.get(webjar) + rest.substring(rest.indexOf('/'))); + event.reroute(webDependenciesRootUrl + webdep + "/" + + webDependencyNameToVersionMap.get(webdep) + rest.substring(rest.indexOf('/'))); } } else { - // this is not a webjar that we know about + // this is not a web dependency that we know about event.fail(404); } } else { diff --git a/extensions/webjars-locator/runtime/src/main/resources/META-INF/quarkus-extension.yaml b/extensions/web-dependency-locator/runtime/src/main/resources/META-INF/quarkus-extension.yaml similarity index 51% rename from extensions/webjars-locator/runtime/src/main/resources/META-INF/quarkus-extension.yaml rename to extensions/web-dependency-locator/runtime/src/main/resources/META-INF/quarkus-extension.yaml index 3ad6eb5bec22d..ff9725c2b3805 100644 --- a/extensions/webjars-locator/runtime/src/main/resources/META-INF/quarkus-extension.yaml +++ b/extensions/web-dependency-locator/runtime/src/main/resources/META-INF/quarkus-extension.yaml @@ -1,12 +1,14 @@ --- artifact: ${project.groupId}:${project.artifactId}:${project.version} -name: "WebJar Locator" +name: "Web Dependency Locator" metadata: - short-name: "webjars-locator" + short-name: "web-dependency-locator" keywords: - "web" - "webjar" - guide: "https://quarkus.io/guides/http-reference#webjar-locator-support" + - "mvnpm" + - "importmap" + guide: "https://quarkus.io/guides/http-reference" categories: - "web" status: "stable" diff --git a/extensions/webjars-locator/deployment/src/main/java/io/quarkus/webjar/locator/deployment/devui/WebJarLibrariesBuildItem.java b/extensions/webjars-locator/deployment/src/main/java/io/quarkus/webjar/locator/deployment/devui/WebJarLibrariesBuildItem.java deleted file mode 100644 index 709d0d21f88c0..0000000000000 --- a/extensions/webjars-locator/deployment/src/main/java/io/quarkus/webjar/locator/deployment/devui/WebJarLibrariesBuildItem.java +++ /dev/null @@ -1,23 +0,0 @@ -package io.quarkus.webjar.locator.deployment.devui; - -import java.util.List; - -import io.quarkus.builder.item.MultiBuildItem; - -public final class WebJarLibrariesBuildItem extends MultiBuildItem { - private final String provider; - private final List webJarLibraries; - - public WebJarLibrariesBuildItem(String provider, List webJarLibraries) { - this.provider = provider; - this.webJarLibraries = webJarLibraries; - } - - public List getWebJarLibraries() { - return this.webJarLibraries; - } - - public String getProvider() { - return this.provider; - } -} diff --git a/extensions/webjars-locator/deployment/src/main/java/io/quarkus/webjar/locator/deployment/devui/WebJarLibrary.java b/extensions/webjars-locator/deployment/src/main/java/io/quarkus/webjar/locator/deployment/devui/WebJarLibrary.java deleted file mode 100644 index 27138ebc39448..0000000000000 --- a/extensions/webjars-locator/deployment/src/main/java/io/quarkus/webjar/locator/deployment/devui/WebJarLibrary.java +++ /dev/null @@ -1,32 +0,0 @@ -package io.quarkus.webjar.locator.deployment.devui; - -public class WebJarLibrary { - - private final String webJarName; - private String version; - private WebJarAsset rootAsset; // must be a list to work with vaadin-grid - - public WebJarLibrary(String webJarName) { - this.webJarName = webJarName; - } - - public String getWebJarName() { - return webJarName; - } - - public String getVersion() { - return version; - } - - public void setVersion(String version) { - this.version = version; - } - - public WebJarAsset getRootAsset() { - return rootAsset; - } - - public void setRootAsset(WebJarAsset rootAsset) { - this.rootAsset = rootAsset; - } -} diff --git a/relocations/generaterelocations.java b/relocations/generaterelocations.java index 8c8042e5b01f1..cce239e9ff322 100755 --- a/relocations/generaterelocations.java +++ b/relocations/generaterelocations.java @@ -144,6 +144,11 @@ public class generaterelocations implements Runnable { RELOCATIONS.put("quarkus-smallrye-reactive-messaging-mqtt-deployment", smallryeReactiveMessagingRelocation); RELOCATIONS.put("quarkus-smallrye-reactive-messaging-rabbitmq", smallryeReactiveMessagingRelocation); RELOCATIONS.put("quarkus-smallrye-reactive-messaging-rabbitmq-deployment", smallryeReactiveMessagingRelocation); + + Function webjarsLocatorRelocation = a -> Relocation.ofArtifactId(a, a.replace("webjars-locator", "web-dependency-locator"), + "3.10"); + RELOCATIONS.put("quarkus-webjars-locator", webjarsLocatorRelocation); + RELOCATIONS.put("quarkus-webjars-locator-deployment", webjarsLocatorRelocation); } private static final String RELOCATION_POM_TEMPLATE = "\n" + // diff --git a/relocations/pom.xml b/relocations/pom.xml index 5f147f47c930a..74c679ecd5ea4 100644 --- a/relocations/pom.xml +++ b/relocations/pom.xml @@ -100,6 +100,8 @@ quarkus-smallrye-reactive-messaging-pulsar-deployment quarkus-smallrye-reactive-messaging-rabbitmq quarkus-smallrye-reactive-messaging-rabbitmq-deployment + quarkus-webjars-locator + quarkus-webjars-locator-deployment diff --git a/relocations/quarkus-webjars-locator-deployment/pom.xml b/relocations/quarkus-webjars-locator-deployment/pom.xml new file mode 100644 index 0000000000000..a555a5b09851b --- /dev/null +++ b/relocations/quarkus-webjars-locator-deployment/pom.xml @@ -0,0 +1,22 @@ + + + + quarkus-relocations-parent + io.quarkus + 999-SNAPSHOT + + 4.0.0 + + quarkus-webjars-locator-deployment + + + + io.quarkus + quarkus-web-dependency-locator-deployment + ${project.version} + Update the artifactId in your project build file. Refer to https://github.com/quarkusio/quarkus/wiki/Migration-Guide-3.10 for more information. + + + \ No newline at end of file diff --git a/relocations/quarkus-webjars-locator/pom.xml b/relocations/quarkus-webjars-locator/pom.xml new file mode 100644 index 0000000000000..1985d8b5e21ea --- /dev/null +++ b/relocations/quarkus-webjars-locator/pom.xml @@ -0,0 +1,22 @@ + + + + quarkus-relocations-parent + io.quarkus + 999-SNAPSHOT + + 4.0.0 + + quarkus-webjars-locator + + + + io.quarkus + quarkus-web-dependency-locator + ${project.version} + Update the artifactId in your project build file. Refer to https://github.com/quarkusio/quarkus/wiki/Migration-Guide-3.10 for more information. + + + \ No newline at end of file