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

Rename webjars-locator to web-dependency-locator #40066

Merged
merged 1 commit into from
Apr 22, 2024
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
14 changes: 12 additions & 2 deletions bom/application/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3125,12 +3125,12 @@
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-webjars-locator</artifactId>
<artifactId>quarkus-web-dependency-locator</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-webjars-locator-deployment</artifactId>
<artifactId>quarkus-web-dependency-locator-deployment</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
Expand Down Expand Up @@ -6670,6 +6670,16 @@
<artifactId>quarkus-smallrye-reactive-messaging-rabbitmq-deployment</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-webjars-locator</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-webjars-locator-deployment</artifactId>
<version>${project.version}</version>
</dependency>
<!-- End of Relocations, please put new extensions above this list -->

</dependencies>
Expand Down
2 changes: 1 addition & 1 deletion devtools/bom-descriptor-json/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2867,7 +2867,7 @@
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-webjars-locator</artifactId>
<artifactId>quarkus-web-dependency-locator</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>test</scope>
Expand Down
2 changes: 1 addition & 1 deletion docs/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2883,7 +2883,7 @@
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-webjars-locator-deployment</artifactId>
<artifactId>quarkus-web-dependency-locator-deployment</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>test</scope>
Expand Down
82 changes: 52 additions & 30 deletions docs/src/main/asciidoc/http-reference.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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
phillip-kruger marked this conversation as resolved.
Show resolved Hide resolved
:web-locator-ga: quarkus-web-dependency-locator

This document clarifies different HTTP functionalities available in Quarkus.

Expand All @@ -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
----
<dependency>
<groupId>org.mvnpm</groupId>
<artifactId>bootstrap</artifactId>
<version>5.3.3</version>
<scope>runtime</scope>
<groupId>org.webjars</groupId>
<artifactId>jquery</artifactId>
<version>3.1.1</version>
</dependency>
----

[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]
----
<script src="_static/bootstrap/5.3.3/dist/css/bootstrap.min.css"></script>
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
----
<dependency>
<groupId>org.webjars</groupId>
<artifactId>jquery</artifactId>
<version>3.1.1</version>
<groupId>io.quarkus</groupId>
<artifactId>{web-locator-ga}</artifactId>
</dependency>
----

[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
----
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-webjars-locator</artifactId>
<groupId>org.mvnpm</groupId>
<artifactId>lit</artifactId>
<version>3.1.2</version>
</dependency>
----

[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]
----
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>My app</title>

<script src="/_importmap/generated_importmap.js"></script> <1>

<script type="module">
import '@lit'; <2>
import 'app/demo-app.js'; <3>
</script>
</head>

</html>
----
<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

Expand Down
2 changes: 1 addition & 1 deletion docs/src/main/asciidoc/web.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@

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.

Check warning on line 30 in docs/src/main/asciidoc/web.adoc

View workflow job for this annotation

GitHub Actions / Linting with Vale

[vale] reported by reviewdog 🐶 [Quarkus.Spelling] Use correct American English spelling. Did you really mean 'CDNs'? Raw Output: {"message": "[Quarkus.Spelling] Use correct American English spelling. Did you really mean 'CDNs'?", "location": {"path": "docs/src/main/asciidoc/web.adoc", "range": {"start": {"line": 30, "column": 34}}}, "severity": "WARNING"}

Check warning on line 30 in docs/src/main/asciidoc/web.adoc

View workflow job for this annotation

GitHub Actions / Linting with Vale

[vale] reported by reviewdog 🐶 [Quarkus.Spelling] Use correct American English spelling. Did you really mean 'cdnjs'? Raw Output: {"message": "[Quarkus.Spelling] Use correct American English spelling. Did you really mean 'cdnjs'?", "location": {"path": "docs/src/main/asciidoc/web.adoc", "range": {"start": {"line": 30, "column": 47}}}, "severity": "WARNING"}

Check warning on line 30 in docs/src/main/asciidoc/web.adoc

View workflow job for this annotation

GitHub Actions / Linting with Vale

[vale] reported by reviewdog 🐶 [Quarkus.Spelling] Use correct American English spelling. Did you really mean 'unpkg'? Raw Output: {"message": "[Quarkus.Spelling] Use correct American English spelling. Did you really mean 'unpkg'?", "location": {"path": "docs/src/main/asciidoc/web.adoc", "range": {"start": {"line": 30, "column": 54}}}, "severity": "WARNING"}

Check warning on line 30 in docs/src/main/asciidoc/web.adoc

View workflow job for this annotation

GitHub Actions / Linting with Vale

[vale] reported by reviewdog 🐶 [Quarkus.Spelling] Use correct American English spelling. Did you really mean 'jsDelivr'? Raw Output: {"message": "[Quarkus.Spelling] Use correct American English spelling. Did you really mean 'jsDelivr'?", "location": {"path": "docs/src/main/asciidoc/web.adoc", "range": {"start": {"line": 30, "column": 61}}}, "severity": "WARNING"}
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].

Check warning on line 31 in docs/src/main/asciidoc/web.adoc

View workflow job for this annotation

GitHub Actions / Linting with Vale

[vale] reported by reviewdog 🐶 [Quarkus.Spelling] Use correct American English spelling. Did you really mean 'webjars'? Raw Output: {"message": "[Quarkus.Spelling] Use correct American English spelling. Did you really mean 'webjars'?", "location": {"path": "docs/src/main/asciidoc/web.adoc", "range": {"start": {"line": 31, "column": 54}}}, "severity": "WARNING"}

Check warning on line 31 in docs/src/main/asciidoc/web.adoc

View workflow job for this annotation

GitHub Actions / Linting with Vale

[vale] reported by reviewdog 🐶 [Quarkus.CaseSensitiveTerms] Use 'Gradle' rather than 'gradle'. Raw Output: {"message": "[Quarkus.CaseSensitiveTerms] Use 'Gradle' rather than 'gradle'.", "location": {"path": "docs/src/main/asciidoc/web.adoc", "range": {"start": {"line": 31, "column": 99}}}, "severity": "INFO"}
c. Package your scripts (js, ts), styles (css, scss), and web dependencies together using a bundler (see xref:#bundling[below]).

Check warning on line 32 in docs/src/main/asciidoc/web.adoc

View workflow job for this annotation

GitHub Actions / Linting with Vale

[vale] reported by reviewdog 🐶 [Quarkus.Spelling] Use correct American English spelling. Did you really mean 'js'? Raw Output: {"message": "[Quarkus.Spelling] Use correct American English spelling. Did you really mean 'js'?", "location": {"path": "docs/src/main/asciidoc/web.adoc", "range": {"start": {"line": 32, "column": 26}}}, "severity": "WARNING"}

Check warning on line 32 in docs/src/main/asciidoc/web.adoc

View workflow job for this annotation

GitHub Actions / Linting with Vale

[vale] reported by reviewdog 🐶 [Quarkus.Spelling] Use correct American English spelling. Did you really mean 'css'? Raw Output: {"message": "[Quarkus.Spelling] Use correct American English spelling. Did you really mean 'css'?", "location": {"path": "docs/src/main/asciidoc/web.adoc", "range": {"start": {"line": 32, "column": 43}}}, "severity": "WARNING"}

Check warning on line 32 in docs/src/main/asciidoc/web.adoc

View workflow job for this annotation

GitHub Actions / Linting with Vale

[vale] reported by reviewdog 🐶 [Quarkus.Spelling] Use correct American English spelling. Did you really mean 'scss'? Raw Output: {"message": "[Quarkus.Spelling] Use correct American English spelling. Did you really mean 'scss'?", "location": {"path": "docs/src/main/asciidoc/web.adoc", "range": {"start": {"line": 32, "column": 48}}}, "severity": "WARNING"}

Check warning on line 32 in docs/src/main/asciidoc/web.adoc

View workflow job for this annotation

GitHub Actions / Linting with Vale

[vale] reported by reviewdog 🐶 [Quarkus.TermsSuggestions] Depending on the context, consider using 'by using' or 'that uses' rather than 'using'. Raw Output: {"message": "[Quarkus.TermsSuggestions] Depending on the context, consider using 'by using' or 'that uses' rather than 'using'.", "location": {"path": "docs/src/main/asciidoc/web.adoc", "range": {"start": {"line": 32, "column": 84}}}, "severity": "INFO"}

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].

Expand Down
2 changes: 1 addition & 1 deletion extensions/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
<module>undertow</module>
<module>websockets</module>
<module>websockets-next</module>
<module>webjars-locator</module>
<module>web-dependency-locator</module>
<module>resteasy-reactive</module>
<module>reactive-routes</module>
<module>apache-httpclient</module>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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">
<parent>
<artifactId>quarkus-webjars-locator-parent</artifactId>
<artifactId>quarkus-web-dependency-locator-parent</artifactId>
<groupId>io.quarkus</groupId>
<version>999-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>quarkus-webjars-locator-deployment</artifactId>
<name>Quarkus - WebJar Locator - Deployment</name>
<artifactId>quarkus-web-dependency-locator-deployment</artifactId>
<name>Quarkus - Web Dependency Locator - Deployment</name>

<properties>
<!-- do not update these dependencies, they are only used for testing -->
Expand All @@ -30,7 +30,7 @@
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-webjars-locator</artifactId>
<artifactId>quarkus-web-dependency-locator</artifactId>
</dependency>
<dependency>
<groupId>io.mvnpm</groupId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.quarkus.webjar.locator.deployment;
package io.quarkus.webdependency.locator.deployment;

phillip-kruger marked this conversation as resolved.
Show resolved Hide resolved
import io.quarkus.builder.item.SimpleBuildItem;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package io.quarkus.webjar.locator.deployment;
package io.quarkus.webdependency.locator.deployment;

import java.util.Map;

import io.quarkus.runtime.annotations.ConfigItem;
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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.quarkus.webjar.locator.deployment;
package io.quarkus.webdependency.locator.deployment;

import java.io.IOException;
import java.io.UncheckedIOException;
Expand Down Expand Up @@ -29,30 +29,30 @@
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";

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<FeatureBuildItem> feature,
BuildProducer<RouteBuildItem> routes,
BuildProducer<ImportMapBuildItem> 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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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<WebJarAsset> children;
private List<WebDependencyAsset> children;
private boolean fileAsset;
private String urlPart;

Expand All @@ -17,11 +17,11 @@ public void setName(String name) {
this.name = name;
}

public List<WebJarAsset> getChildren() {
public List<WebDependencyAsset> getChildren() {
return children;
}

public void setChildren(List<WebJarAsset> children) {
public void setChildren(List<WebDependencyAsset> children) {
this.children = children;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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<WebDependencyLibrary> webDependencyLibraries;

public WebDependencyLibrariesBuildItem(String provider, List<WebDependencyLibrary> webDependencyLibraries) {
this.provider = provider;
this.webDependencyLibraries = webDependencyLibraries;
}

public List<WebDependencyLibrary> getWebDependencyLibraries() {
return this.webDependencyLibraries;
}

public String getProvider() {
return this.provider;
}
}
Original file line number Diff line number Diff line change
@@ -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;
}
}
Loading
Loading