Skip to content

Commit 44af289

Browse files
authored
Merge pull request #17 from dodgex/13-update-readme
Add info about webjars-locator.properties to README.md
2 parents f296bdf + c7e7c66 commit 44af289

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

README.md

+29
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,32 @@ WebJarVersionLocator webJarVersionLocator = new WebJarVersionLocator();
3131
webJarVersionLocator.version("bootstrap"); // cache miss
3232
webJarVersionLocator.version("bootstrap"); // cache hit, avoiding looking up metadata in the classpath
3333
```
34+
35+
Custom WebJars
36+
--------------------------------
37+
38+
By default, `webjars-locator-lite` only supports WebJars with the Maven group IDs of `org.webjars` and `org.webjars.npm`.
39+
To support custom WebJars, you can provide a `webjars-locator.properties` file to register those WebJars with the locator.
40+
41+
The `webjars-locator.properties` file must be located in `META-INF/resources/`.
42+
43+
For a WebJar that has its resource files located in `META-INF/resources/mywebjar/3.2.1/`, the file would look like this:
44+
45+
```
46+
mywebjar.version=3.2.1
47+
```
48+
49+
For custom WebJars, it is recommended to package the file within the WebJar.
50+
However, for older releases that do not include this file, it is also possible to add it to your project directly.
51+
52+
Multiple WebJar versions can be defined in a single file:
53+
54+
```
55+
mywebjar.version=3.2.1
56+
anotherwebjar.version=1.4.3
57+
```
58+
59+
> 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
60+
> resource paths are missing the version part needed for `webjars-locator-lite`.
61+
62+
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 commit comments

Comments
 (0)