dropwizard-webjars-bundle

Dropwizard bundle to make working with Webjars (http://webjars.org) easier.

Categories

Categories

DropWizard Container Microservices
GroupId

GroupId

com.bazaarvoice.dropwizard
ArtifactId

ArtifactId

dropwizard-webjars-bundle
Last Version

Last Version

0.2.1
Release Date

Release Date

Type

Type

jar
Description

Description

dropwizard-webjars-bundle
Dropwizard bundle to make working with Webjars (http://webjars.org) easier.
Source Code Management

Source Code Management

https://github.com/bazaarvoice/dropwizard-webjars-bundle

Download dropwizard-webjars-bundle

How to add to project

<!-- https://jarcasting.com/artifacts/com.bazaarvoice.dropwizard/dropwizard-webjars-bundle/ -->
<dependency>
    <groupId>com.bazaarvoice.dropwizard</groupId>
    <artifactId>dropwizard-webjars-bundle</artifactId>
    <version>0.2.1</version>
</dependency>
// https://jarcasting.com/artifacts/com.bazaarvoice.dropwizard/dropwizard-webjars-bundle/
implementation 'com.bazaarvoice.dropwizard:dropwizard-webjars-bundle:0.2.1'
// https://jarcasting.com/artifacts/com.bazaarvoice.dropwizard/dropwizard-webjars-bundle/
implementation ("com.bazaarvoice.dropwizard:dropwizard-webjars-bundle:0.2.1")
'com.bazaarvoice.dropwizard:dropwizard-webjars-bundle:jar:0.2.1'
<dependency org="com.bazaarvoice.dropwizard" name="dropwizard-webjars-bundle" rev="0.2.1">
  <artifact name="dropwizard-webjars-bundle" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.bazaarvoice.dropwizard', module='dropwizard-webjars-bundle', version='0.2.1')
)
libraryDependencies += "com.bazaarvoice.dropwizard" % "dropwizard-webjars-bundle" % "0.2.1"
[com.bazaarvoice.dropwizard/dropwizard-webjars-bundle "0.2.1"]

Dependencies

compile (2)

Group / Artifact Type Version
io.dropwizard : dropwizard-core jar 0.7.1
com.google.guava : guava jar 17.0

test (5)

Group / Artifact Type Version
io.dropwizard : dropwizard-testing jar 0.7.1
junit : junit jar 4.11
org.eclipse.jetty : jetty-servlet jar 9.0.7.v20131107
org.mockito : mockito-core jar 1.9.5
org.webjars : bootstrap jar 2.3.1

Project Modules

There are no modules declared in this project.

dropwizard-webjars-bundle

NOTE: THIS PROJECT IS DEPRECATED. This projects is no longer maintained. It is deprecated for dropwizard-bundles maintained fork. Users of this project should update their project dependencies appropriately.

A Dropwizard bundle that makes it a lot easier to work with WebJars.

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.

Getting Started

Just add this maven dependency to get started:

<dependency>
    <groupId>com.bazaarvoice.dropwizard</groupId>
    <artifactId>dropwizard-webjars-bundle</artifactId>
    <version>0.2.1</version>
</dependency>
  • For Dropwizard 0.6.2: use version < 0.2.0
  • For Dropwizard 0.7.0: use version >= 0.2.0

Add the resource to your environment:

public class SampleApplication extends Application<Configuration> {
    public static void main(String[] args) throws Exception {
        new SampleApplication().run(args);
    }

    @Override
    public void initialize(Bootstrap<Configuration> bootstrap) {
        bootstrap.addBundle(new WebJarBundle());
    }

    @Override
    public void run(Configuration cfg, Environment env) throws Exception {
        // ...
    }
}

Now reference your WebJar omitting version information:

<script src="/webjars/bootstrap/js/bootstrap.min.js"></script>

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.

com.bazaarvoice.dropwizard

Bazaarvoice

Versions

Version
0.2.1
0.2.0
0.1.1
0.1.0