Skip to content

diroussel/dropwizard-webjars-resource

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 

Repository files navigation

dropwizard-webjars-resource

Resource for use in Dropwizard 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 resource 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-resource</artifactId>
    <version>0.1.9</version>
</dependency>

Add the resource to your environment:

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

    @Override
    public void initialize(Bootstrap<...> bootstrap) {
        ...
    }

    @Override
    public void run(... cfg, Environment env)
            throws Exception {
        env.addResource(new WebJarResource());
    }
}

Now reference your WebJar omitting version information:

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

About

Resource for use in Dropwizard that makes it a lot easier to work with WebJars

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages