Skip to content

Commit

Permalink
Merge pull request #17 from dodgex/13-update-readme
Browse files Browse the repository at this point in the history
Add info about webjars-locator.properties to README.md
  • Loading branch information
jamesward authored Dec 1, 2024
2 parents f296bdf + c7e7c66 commit 44af289
Showing 1 changed file with 29 additions and 0 deletions.
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.

0 comments on commit 44af289

Please sign in to comment.