LoginSignup
8
8

More than 5 years have passed since last update.

gradleでDropwizard

Posted at

Gradle Shadow Plugin

dropwizardでfat jarをつくる時のbuild.gradle。
これまではこちらの記事を参考にやっていましたが、dropwizard-authでエラーがでたので、mavenのshade pluginと同等の機能をもつshadow pluginでやってみた。
(元の方法でもやれるかもしれないけど。。。)

build.gradle
//shadow plugin
buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.github.jengelman.gradle.plugins:shadow:0.8'
    }
}
apply plugin: 'java'
apply plugin: 'shadow'


repositories {
    mavenCentral()
}

dependencies {
   //省略

}

import com.github.jengelman.gradle.plugins.shadow.transformers.ServiceFileTransformer
shadow {

        exclude 'META-INF/MANIFEST.MF'
        exclude 'META-INF/*.SF'
        exclude 'META-INF/*.DSA'
        exclude 'META-INF/*.RSA'

        transformer(ServiceFileTransformer )
}

jar {
    manifest {
        attributes('Main-Class': 'メインクラス')
    }
}

//buildタスク時にshadowJarタスクを実行するように依存関係設定。
assemble.dependsOn shadowJar

shadowJarタスクを実行すれば、ターゲットディレクトリにdistributions/アプリ名-shadow.jarが作成されている。

詳細は本家サイトに。https://github.com/johnrengelman/shadow

8
8
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
8