https://github.com/dropwizard-bundles/dropwizard-webjars-bundle
Dropwizard bundle to make working with Webjars (http://webjars.org) easier.
https://github.com/dropwizard-bundles/dropwizard-webjars-bundle
dropwizard-bundle
Last synced: 5 months ago
JSON representation
Dropwizard bundle to make working with Webjars (http://webjars.org) easier.
- Host: GitHub
- URL: https://github.com/dropwizard-bundles/dropwizard-webjars-bundle
- Owner: dropwizard-bundles
- License: apache-2.0
- Created: 2015-03-09T22:54:37.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2018-07-13T20:28:33.000Z (almost 8 years ago)
- Last Synced: 2025-07-18T01:46:52.821Z (11 months ago)
- Topics: dropwizard-bundle
- Language: Java
- Size: 63.5 KB
- Stars: 3
- Watchers: 2
- Forks: 6
- Open Issues: 1
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# dropwizard-webjars-bundle
A [Dropwizard](http://dropwizard.io) bundle that makes it
a lot easier to work with [WebJars](http://www.webjars.org).
Regular java code doesn't need to know or care about what version of a
dependency it is using. It simply imports the class by name and goes on about
its business. Why shouldn't your front-end development work the same way?
This bundle automatically injects version information for you.
[](https://travis-ci.org/dropwizard-bundles/dropwizard-webjars-bundle)
## Getting Started
Just add this maven dependency to get started:
```xml
io.dropwizard-bundles
dropwizard-webjars-bundle
1.0.5
```
Add the resource to your environment:
```java
public class SampleApplication extends Application {
public static void main(String[] args) throws Exception {
new SampleApplication().run(args);
}
@Override
public void initialize(Bootstrap bootstrap) {
bootstrap.addBundle(new WebJarBundle());
}
@Override
public void run(Configuration cfg, Environment env) throws Exception {
// ...
}
}
```
Now reference your WebJar omitting version information:
```html
```
## Customizing cache settings
By default the WebJar bundle has conservative, but reasonable, cache settings
to ensure that WebJar resources are returned quickly to your clients. If for
some reason the built-in settings aren't suitable for your application they can
be overidden by invoking the `WebJarBundle` constructor with a
`com.google.common.cache.CacheBuilder` instance that is configured with
your desired caching settings.
The cache that is built by the `WebJarBundle` will include a
`com.google.common.cache.Weigher` as part of it that indicates how many bytes
each resource is taking up in the cache. If desired you can include a maximum
weight in your `CacheBuilder` to limit the amount of memory used by the cache.
## Customizing WebJar groups
Custom WebJars artifacts often appear in a maven group other than `org.webjars`.
In order to support these custom WebJars, just invoke the `WebJarBundle`
constructor with a list of the group names you would like to be considered by
the bundle.
Don't forget to also include `org.webjars` in your list if you want standard
WebJars to be found as well.