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

Add info about webjars-locator.properties to README.md #17

Merged
merged 2 commits into from
Dec 1, 2024
Merged
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
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,32 @@ WebJarVersionLocator webJarVersionLocator = new WebJarVersionLocator();
webJarVersionLocator.version("bootstrap"); // cache miss
webJarVersionLocator.version("bootstrap"); // cache hit, avoiding looking up metadata in the classpath
```

Custom WebJars
--------------------------------

By default, `webjars-locator-lite` only supports WebJars with the Maven group IDs of `org.webjars` and `org.webjars.npm`.
To support custom WebJars, you can provide a `webjars-locator.properties` file to register those WebJars with the locator.

The `webjars-locator.properties` file must be located in `META-INF/resources/`.

For a WebJar that has its resource files located in `META-INF/resources/mywebjar/3.2.1/`, the file would look like this:

```
mywebjar.version=3.2.1
```

For custom WebJars, it is recommended to package the file within the WebJar.
However, for older releases that do not include this file, it is also possible to add it to your project directly.

Multiple WebJar versions can be defined in a single file:

```
mywebjar.version=3.2.1
anotherwebjar.version=1.4.3
```

> This allows the use of [legacy](https://github.com/webjars/webjars/issues/2039) `org.webjars.bower` WebJars. However, `org.webjars.bowergithub.xyz` WebJars are not supported because their
> resource paths are missing the version part needed for `webjars-locator-lite`.

You can find an [example file](https://github.com/webjars/webjars-locator-lite/blob/main/src/test/resources/META-INF/resources/webjars-locator.properties) in our tests.