Skip to content

Instantly share code, notes, and snippets.

@mrserverless
Last active February 5, 2017 03:39
Show Gist options
  • Save mrserverless/170efc94faa7fe974207 to your computer and use it in GitHub Desktop.
Save mrserverless/170efc94faa7fe974207 to your computer and use it in GitHub Desktop.
Dropwizard build.gradle with ShadowJar
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.github.jengelman.gradle.plugins:shadow:1.1.2'
}
}
apply plugin: 'maven'
apply plugin: 'java'
apply plugin: 'application'
apply plugin: 'com.github.johnrengelman.shadow'
project.ext {
dropwizardVersion = '0.8.0-SNAPSHOT'
}
mainClassName = 'com.yunspace.dropwizard.example.ShadowApplication'
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
// dropwizard
compile 'io.dropwizard:dropwizard-core:' + dropwizardVersion
// test
testCompile 'junit:junit:4.11'
compile 'io.dropwizard:dropwizard-testing:' + dropwizardVersion
}
task wrapper(type: Wrapper) {
gradleVersion = '2.1'
}
// Configure the shadow jar task
shadowJar {
mergeServiceFiles()
exclude 'META-INF/*.DSA'
exclude 'META-INF/*.RSA'
}
jar {
manifest {
attributes 'Main-Class': mainClassName
}
}
@andrericardo
Copy link

Thank you! First I was having issues with OneJar and Dropwizard-Sundial annotated-jobs-package-name not being found in the single jar with all the dependencies. Then using the default shadowJar configuration did not find

src/dist/config/dicionario-portugues-GCM.yml has an error:
  * Failed to parse configuration at: server.applicationConnectors.[0]; Could not resolve type id 'http' into a subtype of [simple type, class io.dropwizard.jetty.ConnectorFactory]: known type ids = [ConnectorFactory]
 at [Source: N/A; line: -1, column: -1] (through reference chain: uk.me.andre.dicionarioportugues.DictionaryConfiguration["server"]->io.dropwizard.server.DefaultServerFactory["applicationConnectors"]->java.util.ArrayList[0])

Using your shadowJar configuration sorted it out!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment