Feign makes writing java http clients easier
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

55 lines
1.4 KiB

// NOTE: This module is intended to be a stand-alone example which does depend on nebula.
defaultTasks 'clean', 'fatJar'
apply plugin: 'java'
repositories {
mavenCentral()
}
configurations {
compile
}
dependencies {
compile 'io.github.openfeign:feign-core:9.0.0'
compile 'io.github.openfeign:feign-gson:9.0.0'
}
// create a self-contained jar that is executable
// the output is both a 'fat' project artifact and
// a convenience file named "build/github"
task fatJar(dependsOn: classes, type: Jar) {
classifier 'fat'
doFirst {
// Delay evaluation until the compile configuration is ready
from {
configurations.compile.collect { zipTree(it) }
}
}
from (sourceSets*.output.classesDir) {
}
// really executable jar
// http://skife.org/java/unix/2011/06/20/really_executable_jars.html
manifest {
attributes 'Main-Class': 'feign.example.wikipedia.WikipediaExample'
}
// for convenience, we make a file in the build dir named github with no extension
doLast {
def srcFile = new File("${buildDir}/libs/${archiveName}")
def shortcutFile = new File("${buildDir}/wikipedia")
shortcutFile.delete()
shortcutFile << "#!/usr/bin/env sh\n"
shortcutFile << 'exec java -jar $0 "$@"' + "\n"
shortcutFile << srcFile.bytes
shortcutFile.setExecutable(true, true)
srcFile.delete()
srcFile << shortcutFile.bytes
srcFile.setExecutable(true, true)
}
}