1plugins { 2 id "java-library" 3 id "maven-publish" 4 5 id "com.github.johnrengelman.shadow" 6 id "com.google.protobuf" 7 id "ru.vyarus.animalsniffer" 8} 9 10description = "gRPC: ALTS" 11 12dependencies { 13 api project(':grpc-core') 14 implementation project(':grpc-auth'), 15 project(':grpc-grpclb'), 16 project(':grpc-protobuf'), 17 project(':grpc-stub'), 18 libraries.protobuf.java, 19 libraries.conscrypt, 20 libraries.guava.jre, // JRE required by protobuf-java-util from grpclb 21 libraries.google.auth.oauth2Http 22 def nettyDependency = implementation project(':grpc-netty') 23 compileOnly libraries.javax.annotation 24 25 shadow configurations.implementation.getDependencies().minus(nettyDependency) 26 shadow project(path: ':grpc-netty-shaded', configuration: 'shadow') 27 28 testImplementation project(':grpc-testing'), 29 testFixtures(project(':grpc-core')), 30 project(':grpc-testing-proto'), 31 libraries.guava, 32 libraries.junit, 33 libraries.mockito.core, 34 libraries.truth 35 36 testImplementation (libraries.guava.testlib) { 37 exclude group: 'junit', module: 'junit' 38 } 39 testRuntimeOnly libraries.netty.tcnative, 40 libraries.netty.tcnative.classes 41 testRuntimeOnly (libraries.netty.transport.epoll) { 42 artifact { 43 classifier = "linux-x86_64" 44 } 45 } 46 signature libraries.signature.java 47} 48 49configureProtoCompilation() 50 51import net.ltgt.gradle.errorprone.CheckSeverity 52 53[tasks.named("compileJava"), tasks.named("compileTestJava")]*.configure { 54 // protobuf calls valueof. Will be fixed in next release (google/protobuf#4046) 55 options.compilerArgs += [ 56 "-Xlint:-deprecation" 57 ] 58 // ALTS returns a lot of futures that we mostly don't care about. 59 options.errorprone.check("FutureReturnValueIgnored", CheckSeverity.OFF) 60} 61 62tasks.named("javadoc").configure { 63 exclude 'io/grpc/alts/internal/**' 64 exclude 'io/grpc/alts/Internal*' 65} 66 67tasks.named("jar").configure { 68 // Must use a different archiveClassifier to avoid conflicting with shadowJar 69 archiveClassifier = 'original' 70} 71 72// We want to use grpc-netty-shaded instead of grpc-netty. But we also want our 73// source to work with Bazel, so we rewrite the code as part of the build. 74tasks.named("shadowJar").configure { 75 archiveClassifier = null 76 dependencies { 77 exclude(dependency {true}) 78 } 79 relocate 'io.grpc.netty', 'io.grpc.netty.shaded.io.grpc.netty' 80 relocate 'io.netty', 'io.grpc.netty.shaded.io.netty' 81} 82 83publishing { 84 publications { 85 maven(MavenPublication) { 86 // We want this to throw an exception if it isn't working 87 def originalJar = artifacts.find { dep -> dep.classifier == 'original'} 88 artifacts.remove(originalJar) 89 90 pom.withXml { 91 def dependenciesNode = new Node(null, 'dependencies') 92 project.configurations.shadow.allDependencies.each { dep -> 93 def dependencyNode = dependenciesNode.appendNode('dependency') 94 dependencyNode.appendNode('groupId', dep.group) 95 dependencyNode.appendNode('artifactId', dep.name) 96 dependencyNode.appendNode('version', dep.version) 97 dependencyNode.appendNode('scope', 'compile') 98 } 99 asNode().dependencies[0].replaceNode(dependenciesNode) 100 } 101 } 102 } 103} 104