だから私はあなたが2つの構成を探していると思います。
apply plugin: 'groovy'
repositories {
jcenter()
}
dependencies {
compile localGroovy()
compile 'org.slf4j:slf4j-api:1.7.21'
compileOnly group: 'com.google.guava', name: 'guava', version: '20.0'
testCompile 'junit:junit:4.12'
}
task fatJar(type: Jar) {
from sourceSets.main.output, configurations.compile
baseName = "$project.name-fat"
}
jar.dependsOn fatJar
これで、デプロイ先のコンテキストごとに jar を作成できます
$ ./gradlew clean build
Configuration on demand is an incubating feature.
:clean
:compileJava UP-TO-DATE
:compileGroovy
:processResources UP-TO-DATE
:classes
:fatJar
:jar
:assemble
:compileTestJava UP-TO-DATE
:compileTestGroovy UP-TO-DATE
:processTestResources UP-TO-DATE
:testClasses UP-TO-DATE
:test UP-TO-DATE
:check UP-TO-DATE
:build
BUILD SUCCESSFUL
Total time: 4.997 secs
太った瓶があることを確認しましょう
$ unzip build/libs/q40727142-fat.jar -d build/libs/included
Archive: build/libs/q40727142-fat.jar
creating: build/libs/included/META-INF/
inflating: build/libs/included/META-INF/MANIFEST.MF
creating: build/libs/included/com/
creating: build/libs/included/com/jbirdvegas/
creating: build/libs/included/com/jbirdvegas/q40727142/
inflating: build/libs/included/com/jbirdvegas/q40727142/Hello.class
inflating: build/libs/included/groovy-all-2.4.7.jar
inflating: build/libs/included/slf4j-api-1.7.21.jar
元の構成に提供されると予想される jar がないことを確認します。
$ unzip build/libs/q40727142.jar -d build/libs/notIncluded
Archive: build/libs/q40727142.jar
creating: build/libs/notIncluded/META-INF/
inflating: build/libs/notIncluded/META-INF/MANIFEST.MF
creating: build/libs/notIncluded/com/
creating: build/libs/notIncluded/com/jbirdvegas/
creating: build/libs/notIncluded/com/jbirdvegas/q40727142/
inflating: build/libs/notIncluded/com/jbirdvegas/q40727142/Hello.class