Skip to content

Lite WebJars Locator - No Startup Classpath Scanning

License

Notifications You must be signed in to change notification settings

webjars/webjars-locator-lite

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

webjars-locator-lite

This project provides a means to locate assets within WebJars.

Latest Release Javadoc .github/workflows/test.yml

Usage

Get the version of a WebJar on the classpath

new WebJarVersionLocator().version("bootstrap");

Get the full path to a file in a WebJar

new WebJarVersionLocator().fullPath("bootstrap", "js/bootstrap.js");
// returns "META-INF/resources/webjars/bootstrap/<version>/js/bootstrap.js"

Get the path in the standard WebJar classpath location

new WebJarVersionLocator().path("bootstrap", "js/bootstrap.js");
// returns "bootstrap/<version>/js/bootstrap.js"

WebJarVersionLocator has a built-in threadsafe cache that is created on construction. It is highly recommended that you use it as a Singleton to utilize the cache, i.e.

WebJarVersionLocator webJarVersionLocator = new WebJarVersionLocator();
webJarVersionLocator.version("bootstrap"); // cache miss
webJarVersionLocator.version("bootstrap"); // cache hit, avoiding looking up metadata in the classpath