WebJar
What is a WebJar?
WebJars are client-side web libraries packaged into JAR files.
- Explicitly and easily manage the client-side dependencies in JVM-based web applications
- Use JVM-based build tools (e.g. Maven, Gradle, sbt, …) to download your client-side dependencies
- Know which client-side dependencies you are using
- Transitive dependencies are automatically resolved and optionally loaded via RequireJS
- Deployed on Maven Central
Use a WebJar with Maven
- Visit https://www.webjars.org
- Enter the package name into search
- Select
Maven
- Copy the example snippet
Use a WebJar with Gradle
- Visit https://www.webjars.org
- Enter the package name into search
- Select
Gradle
- Copy the example snippet
Create a WebJar from NPM
- Visit https://www.webjars.org
- Click add a WebJar
- Select a NPM package to add
- Select type
NPM
- Choose the package name
- Choose the version to add
- Click
Deploy!
Create a WebJar from a local directory
- Build the project (usually
npm run build
)
- Build a jar of the project
zip project.jar .
- Get the absolute path to the current folder
pwd
- Goto the maven project
mvn install:install-file ${path from step 3}/project.jar