-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
54 changed files
with
6,623 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,194 @@ | ||
load("@rules_proto//proto:defs.bzl", "proto_library") | ||
load("//:java_grpc_library.bzl", "java_grpc_library") | ||
load("@rules_jvm_external//:defs.bzl", "artifact") | ||
|
||
java_library( | ||
name = "s2a_channel_pool", | ||
srcs = glob([ | ||
"src/main/java/io/grpc/s2a/channel/*.java", | ||
]), | ||
deps = [ | ||
"//api", | ||
"//core", | ||
"//core:internal", | ||
"//netty", | ||
artifact("com.google.code.findbugs:jsr305"), | ||
artifact("com.google.errorprone:error_prone_annotations"), | ||
artifact("com.google.guava:guava"), | ||
artifact("org.checkerframework:checker-qual"), | ||
artifact("io.netty:netty-common"), | ||
artifact("io.netty:netty-transport"), | ||
], | ||
) | ||
|
||
java_library( | ||
name = "s2a_identity", | ||
srcs = ["src/main/java/io/grpc/s2a/handshaker/S2AIdentity.java"], | ||
deps = [ | ||
":common_java_proto", | ||
artifact("com.google.errorprone:error_prone_annotations"), | ||
artifact("com.google.guava:guava"), | ||
], | ||
) | ||
|
||
java_library( | ||
name = "token_fetcher", | ||
srcs = ["src/main/java/io/grpc/s2a/handshaker/tokenmanager/TokenFetcher.java"], | ||
deps = [ | ||
":s2a_identity", | ||
], | ||
) | ||
|
||
java_library( | ||
name = "access_token_manager", | ||
srcs = [ | ||
"src/main/java/io/grpc/s2a/handshaker/tokenmanager/AccessTokenManager.java", | ||
], | ||
deps = [ | ||
":s2a_identity", | ||
":token_fetcher", | ||
artifact("com.google.code.findbugs:jsr305"), | ||
], | ||
) | ||
|
||
java_library( | ||
name = "single_token_fetcher", | ||
srcs = [ | ||
"src/main/java/io/grpc/s2a/handshaker/tokenmanager/SingleTokenFetcher.java", | ||
], | ||
deps = [ | ||
":s2a_identity", | ||
":token_fetcher", | ||
artifact("com.google.guava:guava"), | ||
], | ||
) | ||
|
||
java_library( | ||
name = "s2a_handshaker", | ||
srcs = [ | ||
"src/main/java/io/grpc/s2a/handshaker/ConnectionClosedException.java", | ||
"src/main/java/io/grpc/s2a/handshaker/GetAuthenticationMechanisms.java", | ||
"src/main/java/io/grpc/s2a/handshaker/ProtoUtil.java", | ||
"src/main/java/io/grpc/s2a/handshaker/S2AConnectionException.java", | ||
"src/main/java/io/grpc/s2a/handshaker/S2APrivateKeyMethod.java", | ||
"src/main/java/io/grpc/s2a/handshaker/S2AProtocolNegotiatorFactory.java", | ||
"src/main/java/io/grpc/s2a/handshaker/S2AStub.java", | ||
"src/main/java/io/grpc/s2a/handshaker/S2ATrustManager.java", | ||
"src/main/java/io/grpc/s2a/handshaker/SslContextFactory.java", | ||
], | ||
deps = [ | ||
":access_token_manager", | ||
":common_java_proto", | ||
":s2a_channel_pool", | ||
":s2a_identity", | ||
":s2a_java_proto", | ||
":s2a_java_grpc_proto", | ||
":single_token_fetcher", | ||
"//api", | ||
"//core:internal", | ||
"//netty", | ||
"//stub", | ||
artifact("com.google.code.findbugs:jsr305"), | ||
artifact("com.google.errorprone:error_prone_annotations"), | ||
artifact("com.google.guava:guava"), | ||
artifact("org.checkerframework:checker-qual"), | ||
"@com_google_protobuf//:protobuf_java", | ||
artifact("io.netty:netty-common"), | ||
artifact("io.netty:netty-handler"), | ||
artifact("io.netty:netty-transport"), | ||
], | ||
) | ||
|
||
java_library( | ||
name = "s2av2_credentials", | ||
srcs = ["src/main/java/io/grpc/s2a/S2AChannelCredentials.java"], | ||
visibility = ["//visibility:public"], | ||
deps = [ | ||
":s2a_channel_pool", | ||
":s2a_handshaker", | ||
":s2a_identity", | ||
"//api", | ||
"//core:internal", | ||
"//netty", | ||
artifact("com.google.code.findbugs:jsr305"), | ||
artifact("com.google.errorprone:error_prone_annotations"), | ||
artifact("com.google.guava:guava"), | ||
artifact("org.checkerframework:checker-qual"), | ||
], | ||
) | ||
|
||
java_library( | ||
name = "mtls_to_s2av2_credentials", | ||
srcs = ["src/main/java/io/grpc/s2a/MtlsToS2AChannelCredentials.java"], | ||
visibility = ["//visibility:public"], | ||
deps = [ | ||
":s2a_channel_pool", | ||
":s2av2_credentials", | ||
"//api", | ||
"//util", | ||
artifact("com.google.guava:guava"), | ||
], | ||
) | ||
|
||
# bazel only accepts proto import with absolute path. | ||
genrule( | ||
name = "protobuf_imports", | ||
srcs = glob(["src/main/proto/grpc/gcp/s2a/*.proto"]), | ||
outs = [ | ||
"protobuf_out/grpc/gcp/s2a/s2a.proto", | ||
"protobuf_out/grpc/gcp/s2a/s2a_context.proto", | ||
"protobuf_out/grpc/gcp/s2a/common.proto", | ||
], | ||
cmd = "for fname in $(SRCS); do " + | ||
"sed 's,import \",import \"s2a/protobuf_out/,g' $$fname > " + | ||
"$(@D)/protobuf_out/grpc/gcp/s2a/$$(basename $$fname); done", | ||
) | ||
|
||
proto_library( | ||
name = "common_proto", | ||
srcs = [ | ||
"protobuf_out/grpc/gcp/s2a/common.proto", | ||
], | ||
) | ||
|
||
proto_library( | ||
name = "s2a_context_proto", | ||
srcs = [ | ||
"protobuf_out/grpc/gcp/s2a/s2a_context.proto", | ||
], | ||
deps = [ | ||
":common_proto", | ||
], | ||
) | ||
|
||
proto_library( | ||
name = "s2a_proto", | ||
srcs = [ | ||
"protobuf_out/grpc/gcp/s2a/s2a.proto", | ||
], | ||
deps = [ | ||
":common_proto", | ||
":s2a_context_proto", | ||
], | ||
) | ||
|
||
java_proto_library( | ||
name = "s2a_java_proto", | ||
deps = [":s2a_proto"], | ||
) | ||
|
||
java_proto_library( | ||
name = "s2a_context_java_proto", | ||
deps = [":s2a_context_proto"], | ||
) | ||
|
||
java_proto_library( | ||
name = "common_java_proto", | ||
deps = [":common_proto"], | ||
) | ||
|
||
java_grpc_library( | ||
name = "s2a_java_grpc_proto", | ||
srcs = [":s2a_proto"], | ||
deps = [":s2a_java_proto"], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,151 @@ | ||
buildscript { | ||
dependencies { | ||
classpath 'com.google.gradle:osdetector-gradle-plugin:1.4.0' | ||
} | ||
} | ||
|
||
plugins { | ||
id "java-library" | ||
id "maven-publish" | ||
|
||
id "com.github.johnrengelman.shadow" | ||
id "com.google.protobuf" | ||
id "ru.vyarus.animalsniffer" | ||
} | ||
|
||
description = "gRPC: S2A" | ||
|
||
apply plugin: "com.google.osdetector" | ||
|
||
dependencies { | ||
|
||
api project(':grpc-api') | ||
implementation project(':grpc-stub'), | ||
project(':grpc-protobuf'), | ||
project(':grpc-core'), | ||
libraries.protobuf.java, | ||
libraries.conscrypt, | ||
libraries.guava.jre // JRE required by protobuf-java-util from grpclb | ||
def nettyDependency = implementation project(':grpc-netty') | ||
compileOnly libraries.javax.annotation | ||
|
||
shadow configurations.implementation.getDependencies().minus(nettyDependency) | ||
shadow project(path: ':grpc-netty-shaded', configuration: 'shadow') | ||
|
||
testImplementation project(':grpc-benchmarks'), | ||
project(':grpc-testing'), | ||
project(':grpc-testing-proto'), | ||
testFixtures(project(':grpc-core')), | ||
libraries.guava, | ||
libraries.junit, | ||
libraries.mockito.core, | ||
libraries.truth, | ||
libraries.conscrypt, | ||
libraries.netty.transport.epoll | ||
|
||
testImplementation 'com.google.truth:truth:1.4.2' | ||
testImplementation 'com.google.truth.extensions:truth-proto-extension:1.4.2' | ||
testImplementation libraries.guava.testlib | ||
|
||
testRuntimeOnly libraries.netty.tcnative, | ||
libraries.netty.tcnative.classes | ||
testRuntimeOnly (libraries.netty.tcnative) { | ||
artifact { | ||
classifier = "linux-x86_64" | ||
} | ||
} | ||
testRuntimeOnly (libraries.netty.tcnative) { | ||
artifact { | ||
classifier = "linux-aarch_64" | ||
} | ||
} | ||
testRuntimeOnly (libraries.netty.tcnative) { | ||
artifact { | ||
classifier = "osx-x86_64" | ||
} | ||
} | ||
testRuntimeOnly (libraries.netty.tcnative) { | ||
artifact { | ||
classifier = "osx-aarch_64" | ||
} | ||
} | ||
testRuntimeOnly (libraries.netty.tcnative) { | ||
artifact { | ||
classifier = "windows-x86_64" | ||
} | ||
} | ||
testRuntimeOnly (libraries.netty.transport.epoll) { | ||
artifact { | ||
classifier = "linux-x86_64" | ||
} | ||
} | ||
|
||
signature libraries.signature.java | ||
} | ||
|
||
tasks.named("compileJava") { | ||
dependsOn(tasks.named("generateProto")) | ||
//dependsOn(tasks.named("syncGeneratedSourcesmain")) | ||
} | ||
|
||
|
||
tasks.named("sourcesJar") { | ||
dependsOn(tasks.named("generateProto")) | ||
//dependsOn(tasks.named("syncGeneratedSourcesmain")) | ||
} | ||
|
||
sourceSets { | ||
main { | ||
//java.srcDirs += "src/generated/main/java" | ||
//java.srcDirs += "src/generated/main/grpc" | ||
} | ||
} | ||
//println sourceSets.main.java.srcDirs | ||
//println sourceSets.test.resources.srcDirs | ||
|
||
configureProtoCompilation() | ||
|
||
tasks.named("javadoc").configure { | ||
exclude 'io/grpc/s2a/**' | ||
} | ||
|
||
tasks.named("jar").configure { | ||
// Must use a different archiveClassifier to avoid conflicting with shadowJar | ||
archiveClassifier = 'original' | ||
manifest { | ||
attributes('Automatic-Module-Name': 'io.grpc.s2a') | ||
} | ||
} | ||
|
||
// We want to use grpc-netty-shaded instead of grpc-netty. But we also want our | ||
// source to work with Bazel, so we rewrite the code as part of the build. | ||
tasks.named("shadowJar").configure { | ||
archiveClassifier = null | ||
dependencies { | ||
exclude(dependency {true}) | ||
} | ||
relocate 'io.grpc.netty', 'io.grpc.netty.shaded.io.grpc.netty' | ||
relocate 'io.netty', 'io.grpc.netty.shaded.io.netty' | ||
} | ||
|
||
publishing { | ||
publications { | ||
maven(MavenPublication) { | ||
// We want this to throw an exception if it isn't working | ||
def originalJar = artifacts.find { dep -> dep.classifier == 'original'} | ||
artifacts.remove(originalJar) | ||
|
||
pom.withXml { | ||
def dependenciesNode = new Node(null, 'dependencies') | ||
project.configurations.shadow.allDependencies.each { dep -> | ||
def dependencyNode = dependenciesNode.appendNode('dependency') | ||
dependencyNode.appendNode('groupId', dep.group) | ||
dependencyNode.appendNode('artifactId', dep.name) | ||
dependencyNode.appendNode('version', dep.version) | ||
dependencyNode.appendNode('scope', 'compile') | ||
} | ||
asNode().dependencies[0].replaceNode(dependenciesNode) | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.