Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,15 @@ reports/

# OS hidden files
.DS_Store
atlassian-ide-plugin.xml
atlassian-ide-plugin.xml

.gradle
.idea
.build.id
build
out
*.log
server.yaml
/.run/
/gradle
gradlew*
4 changes: 0 additions & 4 deletions .travis.yml

This file was deleted.

44 changes: 44 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
plugins {
id 'java'
id 'java-library'
}

repositories {
mavenCentral()
}

java {
toolchain {
languageVersion = JavaLanguageVersion.of(17)
}
}

project.ext {
dropwizardVersion = '4.0.11'
junitPlatformVersion = '1.9.0'
junitJupiterVersion = '5.7.2'
bootstrapVersion = '5.3.3'
mockitoVersion = '4.8.0'
}

dependencies {
implementation 'io.dropwizard:dropwizard-core:' + dropwizardVersion
implementation 'io.dropwizard:dropwizard-testing:' + dropwizardVersion

implementation 'org.webjars:bootstrap:' + bootstrapVersion

// junit jupiter (junit5)
testImplementation 'org.junit.platform:junit-platform-engine:' + junitPlatformVersion
testImplementation 'org.junit.platform:junit-platform-launcher:' + junitPlatformVersion
testImplementation 'org.junit.platform:junit-platform-runner:' + junitPlatformVersion
testImplementation 'org.junit.jupiter:junit-jupiter-api:' + junitJupiterVersion
testImplementation 'org.junit.jupiter:junit-jupiter-engine:' + junitJupiterVersion
testImplementation 'org.junit.jupiter:junit-jupiter-migrationsupport:' + junitJupiterVersion
testImplementation 'org.junit.jupiter:junit-jupiter-params:' + junitJupiterVersion
testImplementation 'org.junit.vintage:junit-vintage-engine:' + junitJupiterVersion


testImplementation 'org.assertj:assertj-guava:3.26.3'
testImplementation 'org.mockito:mockito-core:' + mockitoVersion
testImplementation 'org.mockito:mockito-junit-jupiter:' + mockitoVersion
}
94 changes: 0 additions & 94 deletions pom.xml

This file was deleted.

73 changes: 3 additions & 70 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,75 +1,8 @@
# dropwizard-webjars-bundle

> _This project is forked from [https://github.com/dropwizard-bundles/dropwizard-webjars-bundle](https://github.com/dropwizard-bundles/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.

[![Build Status](https://travis-ci.org/dropwizard-bundles/dropwizard-webjars-bundle.png)](https://travis-ci.org/dropwizard-bundles/dropwizard-webjars-bundle)

## Getting Started

Just add this maven dependency to get started:

```xml
<dependency>
<groupId>io.dropwizard-bundles</groupId>
<artifactId>dropwizard-webjars-bundle</artifactId>
<version>1.0.5</version>
</dependency>
```

Add the resource to your environment:

```java
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:

```html
<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.
See more documentation at [github.com](https://github.com/dropwizard-bundles/dropwizard-webjars-bundle/blob/master/readme.md)
1 change: 1 addition & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
rootProject.name ='dropwizard-webjars-bundle'
24 changes: 12 additions & 12 deletions src/main/java/io/dropwizard/bundles/webjars/Asset.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@

import java.util.Date;

class Asset {
public final byte[] bytes;
public final MediaType mediaType;
public final String hash;
public final long lastModifiedTime;
public class Asset {
public final byte[] bytes;
public final MediaType mediaType;
public final String hash;
public final long lastModifiedTime;

public Asset(byte[] bytes, MediaType mediaType) {
this.bytes = bytes;
this.mediaType = mediaType;
this.hash = (bytes != null) ? Hashing.murmur3_128().hashBytes(bytes).toString() : null;
this.lastModifiedTime = (new Date().getTime() / 1000) * 1000; // Ignore milliseconds
}
}
public Asset(byte[] bytes, MediaType mediaType) {
this.bytes = bytes;
this.mediaType = mediaType;
this.hash = (bytes != null) ? Hashing.murmur3_128().hashBytes(bytes).toString() : null;
this.lastModifiedTime = (new Date().getTime() / 1000) * 1000; // Ignore milliseconds
}
}
56 changes: 26 additions & 30 deletions src/main/java/io/dropwizard/bundles/webjars/AssetId.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,34 @@
import com.google.common.base.MoreObjects;
import com.google.common.base.Objects;

class AssetId {
public final String library;
public final String resource;
public class AssetId {
public final String library;
public final String resource;

public AssetId(String library, String resource) {
this.library = library;
this.resource = resource;
}

@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null || !(obj instanceof AssetId)) {
return false;
public AssetId(String library, String resource) {
this.library = library;
this.resource = resource;
}

AssetId id = (AssetId) obj;
return Objects.equal(library, id.library) && Objects.equal(resource, id.resource);
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj instanceof AssetId id) {
return Objects.equal(library, id.library) && Objects.equal(resource, id.resource);
} else {
return false;
}
}

@Override
public int hashCode() {
return Objects.hashCode(library, resource);
}
@Override
public int hashCode() {
return Objects.hashCode(library, resource);
}

@Override
public String toString() {
return MoreObjects.toStringHelper(this)
.add("library", library)
.add("resource", resource)
.toString();
}
}
@Override
public String toString() {
return MoreObjects.toStringHelper(this).add("library", library).add("resource", resource).toString();
}
}
Loading