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

[WIP] Shade Feign 8.17 #2054

Closed
wants to merge 14 commits into from
Closed
4 changes: 1 addition & 3 deletions atlasdb-cassandra/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
apply from: "../gradle/publish-jars.gradle"
apply plugin: 'org.inferred.processors'
apply plugin: 'com.github.johnrengelman.shadow'
apply from: "../gradle/feign-shading.gradle"

apply from: "../gradle/shared.gradle"

Expand Down Expand Up @@ -65,6 +66,3 @@ shadowJar {
include(dependency { false })
}
}

jar.dependsOn shadowJar
jar.onlyIf { false }
1 change: 1 addition & 0 deletions atlasdb-cli-distribution/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ apply plugin: 'com.palantir.sls-java-service-distribution'

apply from: "../gradle/publish-dists.gradle"
apply from: "../gradle/shared.gradle"
apply from: "../gradle/feign-shading.gradle"

dependencies {
runtime project(':atlasdb-cli')
Expand Down
7 changes: 4 additions & 3 deletions atlasdb-cli/build.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
apply plugin: 'org.inferred.processors'

apply from: "../gradle/publish-jars.gradle"
apply from: '../gradle/shared.gradle'

apply plugin: 'org.inferred.processors'
apply from: "../gradle/feign-shading.gradle"

dependencies {
compile project(':atlasdb-cassandra')
compile project(path: ':atlasdb-dagger', configuration: 'shadow')
compile project(path: ':atlasdb-dagger', configuration: 'daggerShadow')
compileOnly 'com.google.dagger:dagger'
compile 'io.airlift:airline:0.7'

Expand Down
33 changes: 20 additions & 13 deletions atlasdb-client/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
apply from: "../gradle/publish-jars.gradle"
apply from: "../gradle/shared.gradle"
apply from: "../gradle/feign-shading.gradle"

apply plugin: 'java'
apply plugin: 'eclipse'
Expand All @@ -22,32 +23,38 @@ task myTestJar(type: Jar) {

configurations {
testArtifacts

explicitShadow
compile.extendsFrom(explicitShadow)
shadow.extendsFrom(explicitShadow)
}

artifacts {
testArtifacts myTestJar
}

dependencies {
compile project(":atlasdb-commons")
compile project(":atlasdb-api")
compile project(":atlasdb-client-protobufs")
compile (group: 'com.googlecode.json-simple', name: 'json-simple') {
explicitShadow project(":atlasdb-commons")
explicitShadow project(":atlasdb-api")
explicitShadow project(":atlasdb-client-protobufs")
explicitShadow (group: 'com.googlecode.json-simple', name: 'json-simple') {
exclude group: 'junit'
}
compile group: "commons-lang", name: "commons-lang", version: libVersions.commons_lang
compile group: "org.xerial.snappy", name: "snappy-java", version: libVersions.snappy
compile group: "com.googlecode.protobuf-java-format", name: "protobuf-java-format", version: "1.2"
compile group: "com.google.protobuf", name: "protobuf-java", version: "2.6.0"
explicitShadow group: "commons-lang", name: "commons-lang", version: libVersions.commons_lang
explicitShadow group: "org.xerial.snappy", name: "snappy-java", version: libVersions.snappy
explicitShadow group: "com.googlecode.protobuf-java-format", name: "protobuf-java-format", version: "1.2"
explicitShadow group: "com.google.protobuf", name: "protobuf-java", version: "2.6.0"
explicitShadow group: 'com.fasterxml.jackson.core', name: 'jackson-databind'
explicitShadow group: 'com.fasterxml.jackson.core', name: 'jackson-core'
explicitShadow group: 'com.fasterxml.jackson.datatype', name: 'jackson-datatype-guava'
explicitShadow group: 'com.palantir.remoting2', name: 'tracing'
explicitShadow group: 'com.palantir.tritium', name: 'tritium-lib'

// Not needed at runtime in the shadow JAR, because we have shaded it away.
compile group: 'com.netflix.feign', name: 'feign-jackson'
compile (group: 'com.netflix.feign', name: 'feign-jaxrs') {
exclude module: 'jsr311-api'
}
compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind'
compile group: 'com.fasterxml.jackson.core', name: 'jackson-core'
compile group: 'com.fasterxml.jackson.datatype', name: 'jackson-datatype-guava'
compile group: 'com.palantir.remoting2', name: 'tracing'
compile group: 'com.palantir.tritium', name: 'tritium-lib'

testCompile group: 'junit', name: 'junit'
testCompile group: 'org.mockito', name: 'mockito-core'
Expand Down
73 changes: 65 additions & 8 deletions atlasdb-config/build.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,45 @@
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar

apply from: "../gradle/publish-jars.gradle"
apply plugin: 'org.inferred.processors'
apply plugin: 'com.github.johnrengelman.shadow'
apply from: "../gradle/feign-shading.gradle"

apply from: "../gradle/shared.gradle"

configurations {
/*
* The configurations below may be visualized as follows:
*
* +-------+ +--------------+ +------+
* |compile+--+ +--+remotingShadow+---+ |shadow|
* +---+---+ | | +--------------+ | +----+-+
* | | | | |
* +------+--+---------------+ | |
* | | | | |
* +----v--v-+ +--v-----v-----+ |
* |feignDeps| |explicitShadow<--+
* +---------+ +--------------+
*
* where we have an arrow from A to B if configuration A extends from B (i.e. A gets all dependencies of B).
*
* remotingShadow includes compile dependencies, except for remoting. It also includes the ALPN agent for HTTP/2.
* shadow includes compile dependencies, except for remoting and feign; it also includes the ALPN agent.
*
* Having shadow jar configurations extend from compile is not recommended
* (see https://github.com/johnrengelman/shadow/issues/142).
*/

remotingShadow

explicitShadow
compile.extendsFrom(explicitShadow)
shadow.extendsFrom(explicitShadow)
remotingShadow.extendsFrom(explicitShadow)

feignDeps
compile.extendsFrom(feignDeps)
remotingShadow.extendsFrom(feignDeps)
}

dependencies {
Expand All @@ -19,12 +51,6 @@ dependencies {
explicitShadow project(':leader-election-impl')
explicitShadow project(':lock-impl')

explicitShadow group: 'com.netflix.feign', name: 'feign-jackson'
explicitShadow (group: 'com.netflix.feign', name: 'feign-jaxrs') {
exclude module: 'jsr311-api'
}
// versions below 8.10.0 have a bug where POST requests must have a body
explicitShadow group: 'com.netflix.feign', name: 'feign-okhttp'
explicitShadow group: 'javax.validation', name: 'validation-api'
explicitShadow group: 'com.palantir.config.crypto', name: 'encrypted-config-value-module'
explicitShadow group: 'com.palantir.tritium', name: 'tritium-lib'
Expand All @@ -36,9 +62,18 @@ dependencies {
explicitShadow group: 'io.dropwizard', name: 'dropwizard-jackson'
explicitShadow group: 'com.google.code.findbugs', name: 'annotations'

// Feign dependencies.
// versions below 8.10.0 have a bug where POST requests must have a body
feignDeps group: 'com.netflix.feign', name: 'feign-jackson'
feignDeps (group: 'com.netflix.feign', name: 'feign-jaxrs') {
exclude module: 'jsr311-api'
}
feignDeps group: 'com.netflix.feign', name: 'feign-okhttp'

// This is added so that AtlasDB clients can specify the javaAgent as a JVM argument to load jars needed for HTTP/2
// in the boot classpath
shadow group: 'org.mortbay.jetty.alpn', name: 'jetty-alpn-agent', version: libVersions.jetty_alpn_agent
remotingShadow group: 'org.mortbay.jetty.alpn', name: 'jetty-alpn-agent', version: libVersions.jetty_alpn_agent

processor group: 'org.immutables', name: 'value'
processor 'com.google.auto.service:auto-service:1.0-rc2'
Expand Down Expand Up @@ -66,5 +101,27 @@ shadowJar {
}
}

jar.dependsOn shadowJar
jar.onlyIf { false } // Prevents running the jar task directly.
// ONLY shade Remoting. For internal use.
task remotingShadowJar(type: ShadowJar) {
mergeServiceFiles()
classifier 'remotingShadow'
from sourceSets.main.output
configurations = [project.configurations.compile]

relocate('com.palantir.remoting2.errors', 'com.palantir.atlasdb.shaded.com.palantir.remoting2.errors')
relocate('com.palantir.remoting2.ext.jackson', 'com.palantir.atlasdb.shaded.com.palantir.remoting2.ext.jackson')

dependencies {
include(dependency(group: 'com.palantir.remoting2', name: 'error-handling'))
include(dependency(group: 'com.palantir.remoting2', name: 'jackson-support'))
}
}

artifacts {
remotingShadow (tasks.remotingShadowJar.archivePath) {
builtBy remotingShadowJar
}
}

jar.dependsOn remotingShadowJar
jar.onlyIf { false }
1 change: 1 addition & 0 deletions atlasdb-console-distribution/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ apply plugin: 'com.palantir.sls-java-service-distribution'

apply from: "../gradle/publish-dists.gradle"
apply from: "../gradle/shared.gradle"
apply from: "../gradle/feign-shading.gradle"

dependencies {
runtime project(':atlasdb-console')
Expand Down
4 changes: 3 additions & 1 deletion atlasdb-console/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
apply plugin: 'groovy'

apply from: "../gradle/publish-jars.gradle"
apply from: "../gradle/shared.gradle"
apply plugin: 'groovy'
apply from: "../gradle/feign-shading.gradle"

dependencies {
compile project(':atlasdb-service')
Expand Down
39 changes: 34 additions & 5 deletions atlasdb-dagger/build.gradle
Original file line number Diff line number Diff line change
@@ -1,22 +1,30 @@
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar

apply from: "../gradle/publish-jars.gradle"
apply plugin: 'org.inferred.processors'
apply plugin: 'com.github.johnrengelman.shadow'

apply from: '../gradle/shared.gradle'
apply from: "../gradle/feign-shading.gradle"

configurations {
daggerShadow
}

dependencies {
compile project(':atlasdb-service')
compile group: 'com.google.dagger', name: 'dagger'

processor(group: 'com.google.dagger', name: 'dagger-compiler') {
// We need to explicitly exclude these so that intellij does not label them as provided
if(gradle.startParameter.taskNames.contains('idea')) {
exclude group: 'com.google.dagger', module: 'dagger'
}
// We need to explicitly exclude these so that intellij does not label them as provided
if(gradle.startParameter.taskNames.contains('idea')) {
exclude group: 'com.google.dagger', module: 'dagger'
}
}
processor group: 'org.immutables', name: 'value'

shadow project(':atlasdb-service')
daggerShadow project(':atlasdb-service')
}

shadowJar {
Expand All @@ -30,5 +38,26 @@ shadowJar {
}
}

jar.dependsOn shadowJar
// ONLY shade Dagger. This is used in the AtlasDB CLI
task daggerShadowJar(type: ShadowJar) {
mergeServiceFiles()
classifier 'daggerShadow'
from sourceSets.main.output
configurations = [project.configurations.compile]

relocate('dagger', 'com.palantir.atlasdb.shaded.dagger')

// No need to explicitly exclude Feign because that is only added to the normal shadow jar task.
dependencies {
include dependency(group: 'com.google.dagger', name: 'dagger')
}
}

artifacts {
daggerShadow (tasks.daggerShadowJar.archivePath) {
builtBy daggerShadowJar
}
}

jar.dependsOn daggerShadowJar
jar.onlyIf { false }
1 change: 1 addition & 0 deletions atlasdb-dbkvs-tests/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ apply from: "../gradle/publish-jars.gradle"
apply plugin: 'org.inferred.processors'

apply from: "../gradle/shared.gradle"
apply from: "../gradle/feign-shading.gradle"

dependencies {
compile project(":atlasdb-dbkvs")
Expand Down
3 changes: 2 additions & 1 deletion atlasdb-dbkvs/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ apply from: "../gradle/publish-jars.gradle"
apply plugin: 'org.inferred.processors'

apply from: "../gradle/shared.gradle"
apply from: "../gradle/feign-shading.gradle"

dependencies {
compile project(":atlasdb-api")
Expand All @@ -12,7 +13,7 @@ dependencies {
compile project(':commons-db')
compile project(':commons-api')

testCompile project(':atlasdb-config')
testCompile project(path: ':atlasdb-config', configuration: 'remotingShadow')
testCompile project(path: ":atlasdb-client", configuration: "testArtifacts")
testCompile group: 'org.hamcrest', name: 'hamcrest-library'
testCompile group: 'org.mockito', name: 'mockito-core'
Expand Down
3 changes: 2 additions & 1 deletion atlasdb-dropwizard-bundle/build.gradle
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
apply from: "../gradle/publish-jars.gradle"
apply from: "../gradle/shared.gradle"
apply from: "../gradle/feign-shading.gradle"

dependencies {
compile project(':atlasdb-cli')
compile project(path: ':atlasdb-config', configuration: 'shadow')
compile project(path: ':atlasdb-config', configuration: 'remotingShadow')
compile project(':atlasdb-console')

compile group: 'io.dropwizard', name: 'dropwizard-core'
Expand Down
4 changes: 3 additions & 1 deletion atlasdb-ete-tests/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@ apply from: "../gradle/shared.gradle"
apply plugin: 'com.palantir.sls-java-service-distribution'
apply plugin: 'org.inferred.processors'

apply from: "../gradle/feign-shading.gradle"

schemas = [
'com.palantir.atlasdb.cas.CheckAndSetSchema'
]

dependencies {
compile project(':lock-impl')
compile project(':leader-election-impl')
compile project(path: ':atlasdb-config', configuration: 'shadow')
compile project(path: ':atlasdb-config', configuration: 'remotingShadow')
compile project(':atlasdb-dropwizard-bundle')
compile project(':atlasdb-hikari')
compile project(':atlasdb-rocksdb')
Expand Down
1 change: 1 addition & 0 deletions atlasdb-hikari/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ apply from: "../gradle/publish-jars.gradle"
apply plugin: "org.inferred.processors"

apply from: "../gradle/shared.gradle"
apply from: "../gradle/feign-shading.gradle"

dependencies {
compile project(":atlasdb-jdbc")
Expand Down
1 change: 1 addition & 0 deletions atlasdb-impl-shared/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ apply from: "../gradle/publish-jars.gradle"
apply plugin: 'org.inferred.processors'

apply from: "../gradle/shared.gradle"
apply from: "../gradle/feign-shading.gradle"

apply plugin: 'java'
apply plugin: 'eclipse'
Expand Down
1 change: 1 addition & 0 deletions atlasdb-jdbc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ apply from: "../gradle/publish-jars.gradle"
apply plugin: "org.inferred.processors"

apply from: "../gradle/shared.gradle"
apply from: "../gradle/feign-shading.gradle"

dependencies {
compile project(":atlasdb-api")
Expand Down
11 changes: 6 additions & 5 deletions atlasdb-jepsen-tests/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
apply plugin: 'org.inferred.processors'
apply plugin: 'com.github.johnrengelman.shadow'
apply plugin: 'docker-compose'

apply from: "../gradle/publish-jars.gradle"
apply from: "${rootProject.projectDir}/gradle/shared.gradle"
apply from: "../gradle/feign-shading.gradle"

buildscript {
repositories {
Expand All @@ -10,10 +15,6 @@ buildscript {
}
}

apply plugin: 'org.inferred.processors'
apply plugin: 'com.github.johnrengelman.shadow'
apply plugin: 'docker-compose'

task runUnitTestsForPrintLogsInChronologicalOrderScript(type: Exec) {
commandLine 'python', 'scripts/print_logs_in_chronological_order.py', '--tests-only'
}
Expand All @@ -25,7 +26,7 @@ jacocoTestReport {
check.dependsOn runUnitTestsForPrintLogsInChronologicalOrderScript

dependencies {
compile project(path: ':atlasdb-config', configuration: 'shadow')
compile project(path: ':atlasdb-config', configuration: 'remotingShadow')

compile group: 'com.fasterxml.jackson.core', name: 'jackson-core'
compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind'
Expand Down
Loading