Skip to content
This repository has been archived by the owner on Jan 12, 2024. It is now read-only.

Commit

Permalink
Merge pull request #4 from Nike-Inc/feature/shaded-fatjar
Browse files Browse the repository at this point in the history
Use the Shadow Jar plugin to create a shaded jar that has our depende…
  • Loading branch information
fieldju authored Jan 4, 2017
2 parents 7456d07 + f87e61d commit 8bf8011
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 60 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ cache:
directories:
- "$HOME/.m2"
after_success:
- "./gradlew cobertura coveralls --stacktrace"
- ./gradlew cobertura coveralls --stacktrace
- test "${TRAVIS_PULL_REQUEST}" == "false" && test "${TRAVIS_TAG}" != "" && ./gradlew
bintrayUpload --stacktrace
env:
Expand Down
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'com.jfrog.bintray'
apply plugin: 'maven-publish'
apply plugin: "com.github.johnrengelman.shadow"

sourceCompatibility = 1.7
targetCompatibility = 1.7
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
# limitations under the License.
#

version=1.1.0
version=1.2.0
groupId=com.nike
artifactId=cerberus-client
46 changes: 4 additions & 42 deletions gradle/bintray.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
* limitations under the License.
*/

def createPomOutputLocation = "${project.buildDir}/libs/pom.xml"
def bintrayUser = project.hasProperty('bintrayUser') ? project.bintrayUser : System.getenv('BINTRAY_USER') ?: ''
def bintrayKey = project.hasProperty('bintrayKey') ? project.bintrayKey : System.getenv('BINTRAY_KEY') ?: ''
def bintrayVersion = "$version"
Expand All @@ -24,7 +23,7 @@ bintray {
key = bintrayKey
dryRun = false
publish = true
publications = ['mavenInfo']
publications = ['jar']

pkg {
repo = 'maven'
Expand Down Expand Up @@ -62,52 +61,15 @@ artifacts {
archives sourcesJar
}

task createPom << {
pom {
project {
groupId groupId
artifactId artifactId
version version
name artifactId
description "Cerberus Client"
url 'https://github.com/Nike-Inc/cerberus-java-client'
inceptionYear '2016'
licenses {
license {
name 'The Apache Software License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
distribution 'repo'
}
}
scm {
url 'https://github.com/Nike-Inc/cerberus-java-client'
connection '[email protected]:Nike-Inc/cerberus-java-client.git'
}
organization {
name 'Nike'
url 'http://nike-inc.github.io'
}
}
}.writeTo(createPomOutputLocation)
}

publishing {
publications {
mavenInfo(MavenPublication) {
from components.java
jar(MavenPublication) {
from components.shadow

artifact sourcesJar
artifact javadocJar

pom.withXml {
// The pom produced by this task is questionable - ALL dependencies are set to runtime rather than how we set them up in the build.gradle files.
// Unfortunately we need to use this task anyway for the bintray gradle plugin.
// Therefore we'll just wipe out the pom this produces and use one created by the normal maven plugin (see the createPom task) instead.
asString().delete(0, Integer.MAX_VALUE).append(new File(createPomOutputLocation).text)
}
}
}
}

bintrayUpload.dependsOn(createPom)
assemble.finalizedBy(createPom)
bintrayUpload.dependsOn(shadowJar)
1 change: 1 addition & 0 deletions gradle/buildscript.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ dependencies {
classpath "net.saliman:gradle-cobertura-plugin:2.3.0"
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.6'
classpath 'org.kt3k.gradle.plugin:coveralls-gradle-plugin:2.6.3'
classpath "com.github.jengelman.gradle.plugins:shadow:1.2.4"
}
45 changes: 29 additions & 16 deletions gradle/dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,27 @@ repositories {
jcenter()
}

final String AWS_SDK_VERSION = '1.10.50'
def AWS_SDK_VERSION = '1.11.75'
//noinspection GroovyAssignabilityCheck
configurations.all {
resolutionStrategy {
// add a dependency resolve rule
eachDependency { DependencyResolveDetails details ->
//Force use of certain dependencies or versions
if (details.requested.group == 'com.amazonaws') {
details.useVersion(AWS_SDK_VERSION)
}
}
}
}

dependencies {

/***********************************************************************************************************************
* IMPORTANT! This project produces a fat jar! *
* *
* If you add a new compile dependency to this library and do not also verify that it gets shaded *
* you will introduce a transitive dependency nightmare for users of this library. *
* *
* We do this because AWS constantly breaks backwards compatibility of their SDK with minor version releases. *
* We do not want to dictate what SDK version users of Cerberus should use. *
***********************************************************************************************************************/
compile "com.nike:vault-client:1.0.0"
compile "joda-time:joda-time:2.8.1"
compile "org.apache.commons:commons-lang3:3.4"
compile "org.slf4j:slf4j-api:1.7.14"
compile "com.amazonaws:aws-java-sdk-core:1.10.50"
compile "com.amazonaws:aws-java-sdk-kms:1.10.50"
compile "com.amazonaws:aws-java-sdk-lambda:1.10.50"

compile "com.amazonaws:aws-java-sdk-core:${AWS_SDK_VERSION}"
compile "com.amazonaws:aws-java-sdk-kms:${AWS_SDK_VERSION}"
compile "com.amazonaws:aws-java-sdk-lambda:${AWS_SDK_VERSION}"

testCompile "junit:junit:4.12"
testCompile ("org.mockito:mockito-core:1.10.19") {
Expand All @@ -54,3 +53,17 @@ dependencies {
testCompile "org.assertj:assertj-core:2.3.0"
testCompile "com.squareup.okhttp3:mockwebserver:3.0.1"
}

shadowJar {
classifier = ''
relocate('com.', 'cerberus.com.') {
exclude 'com.nike.**'
}
relocate 'org.', 'cerberus.org.'
relocate 'javax.annotation', 'cerberus.javax.annotation'
relocate 'models.', 'cerberus.models.'
relocate 'mozilla.', 'cerberus.mozilla.'
relocate 'okhttp3.', 'cerberus.okhttp3.'
relocate 'okio.', 'cerberus.okio.'
relocate 'software.', 'cerberus.software.'
}

0 comments on commit 8bf8011

Please sign in to comment.