xds: Build third-party protos in separate build step

This dramatically shortens build time, even for full builds. A full
assemble of xds on my laptop goes from 1m 46s to 33s at least because
errorprone is disabled for the protos.
This commit is contained in:
Eric Anderson 2022-07-07 07:26:38 -07:00 committed by GitHub
parent 1f1712c67c
commit 3de7e74c57
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 68 additions and 41 deletions

View File

@ -123,9 +123,8 @@ subprojects {
release { java { srcDir "${generatedSourcePath}/release/grpc" } }
}
} else {
project.sourceSets {
main { java { srcDir "${generatedSourcePath}/main/grpc" } }
test { java { srcDir "${generatedSourcePath}/test/grpc" } }
project.sourceSets.each() { sourceSet ->
sourceSet.java { srcDir "${generatedSourcePath}/${sourceSet.name}/grpc" }
}
}
}

View File

@ -29,6 +29,7 @@ cd "$GRPC_JAVA_DIR"
## Deploy the dummy 'default' version of the service
##
GRADLE_FLAGS="--stacktrace -DgaeStopPreviousVersion=false -PskipCodegen=true -PskipAndroid=true"
export GRADLE_OPTS="-Dorg.gradle.jvmargs='-Xmx1g'"
# Deploy the dummy 'default' version. We only require that it exists when cleanup() is called.
# It ok if we race with another run and fail here, because the end result is idempotent.

View File

@ -29,6 +29,7 @@ SET FAIL_ON_WARNINGS=true
SET VC_PROTOBUF_LIBS=%ESCWORKSPACE%\\grpc-java-helper32\\protobuf-%PROTOBUF_VER%\\build\\Release
SET VC_PROTOBUF_INCLUDE=%ESCWORKSPACE%\\grpc-java-helper32\\protobuf-%PROTOBUF_VER%\\build\\include
SET GRADLE_FLAGS=-PtargetArch=%TARGET_ARCH% -PfailOnWarnings=%FAIL_ON_WARNINGS% -PvcProtobufLibs=%VC_PROTOBUF_LIBS% -PvcProtobufInclude=%VC_PROTOBUF_INCLUDE% -PskipAndroid=true
SET GRADLE_OPTS="-Dorg.gradle.jvmargs='-Xmx1g'"
cmd.exe /C "%WORKSPACE%\gradlew.bat %GRADLE_FLAGS% build"
set GRADLEEXIT=%ERRORLEVEL%

View File

@ -28,6 +28,7 @@ SET FAIL_ON_WARNINGS=true
SET VC_PROTOBUF_LIBS=%ESCWORKSPACE%\\grpc-java-helper64\\protobuf-%PROTOBUF_VER%\\build\\Release
SET VC_PROTOBUF_INCLUDE=%ESCWORKSPACE%\\grpc-java-helper64\\protobuf-%PROTOBUF_VER%\\build\\include
SET GRADLE_FLAGS=-PtargetArch=%TARGET_ARCH% -PfailOnWarnings=%FAIL_ON_WARNINGS% -PvcProtobufLibs=%VC_PROTOBUF_LIBS% -PvcProtobufInclude=%VC_PROTOBUF_INCLUDE% -PskipAndroid=true
SET GRADLE_OPTS="-Dorg.gradle.jvmargs='-Xmx1g'"
@rem make sure no daemons have any files open
cmd.exe /C "%WORKSPACE%\gradlew.bat --stop"

View File

@ -11,24 +11,41 @@ plugins {
description = "gRPC: XDS plugin"
[compileJava].each() {
it.options.compilerArgs += [
// valueOf(int) in RoutingPriority has been deprecated
"-Xlint:-deprecation",
// only has AutoValue annotation processor
"-Xlint:-processing",
]
appendToProperty(
it.options.errorprone.excludedPaths,
".*/build/generated/sources/annotationProcessor/java/.*",
"|")
}
evaluationDependsOn(project(':grpc-core').path)
sourceSets {
thirdparty {
java {
srcDir "${projectDir}/third_party/zero-allocation-hashing/main/java"
}
proto {
srcDir 'third_party/envoy/src/main/proto'
srcDir 'third_party/protoc-gen-validate/src/main/proto'
srcDir 'third_party/xds/src/main/proto'
srcDir 'third_party/googleapis/src/main/proto'
srcDir 'third_party/istio/src/main/proto'
}
}
test {
java {
srcDir "${projectDir}/third_party/zero-allocation-hashing/test/java"
}
}
}
configurations {
pomDeps {
extendsFrom configurations.thirdpartyRuntimeClasspath, configurations.shadow
}
}
dependencies {
implementation project(':grpc-protobuf'),
thirdpartyCompileOnly libraries.javax.annotation
thirdpartyImplementation project(':grpc-protobuf'),
project(':grpc-stub'),
libraries.opencensus.proto
implementation sourceSets.thirdparty.output
implementation project(':grpc-stub'),
project(':grpc-core'),
project(':grpc-services'),
project(':grpc-auth'),
@ -36,7 +53,6 @@ dependencies {
libraries.gson,
libraries.re2j,
libraries.auto.value.annotations,
libraries.opencensus.proto,
libraries.protobuf.java.util
def nettyDependency = implementation project(':grpc-netty')
@ -44,9 +60,8 @@ dependencies {
testImplementation project(':grpc-core').sourceSets.test.output
annotationProcessor libraries.auto.value
compileOnly libraries.javax.annotation,
// At runtime use the epoll included in grpc-netty-shaded
libraries.netty.transport.epoll
// At runtime use the epoll included in grpc-netty-shaded
compileOnly libraries.netty.transport.epoll
testImplementation project(':grpc-testing'),
project(':grpc-testing-proto')
@ -92,30 +107,36 @@ dependencies {
}
}
sourceSets {
main {
java {
srcDir "${projectDir}/third_party/zero-allocation-hashing/main/java"
}
proto {
srcDir 'third_party/envoy/src/main/proto'
srcDir 'third_party/protoc-gen-validate/src/main/proto'
srcDir 'third_party/xds/src/main/proto'
srcDir 'third_party/googleapis/src/main/proto'
srcDir 'third_party/istio/src/main/proto'
}
}
test {
java {
srcDir "${projectDir}/third_party/zero-allocation-hashing/test/java"
}
}
configureProtoCompilation()
compileThirdpartyJava {
options.errorprone.enabled = false
options.compilerArgs += [
// valueOf(int) in RoutingPriority has been deprecated
"-Xlint:-deprecation",
]
}
configureProtoCompilation()
checkstyleThirdparty {
enabled = false
}
[compileJava].each() {
it.options.compilerArgs += [
// TODO: remove
"-Xlint:-deprecation",
// only has AutoValue annotation processor
"-Xlint:-processing",
]
appendToProperty(
it.options.errorprone.excludedPaths,
".*/build/generated/sources/annotationProcessor/java/.*",
"|")
}
jar {
archiveClassifier = 'original'
from sourceSets.thirdparty.output
}
javadoc {
@ -211,7 +232,11 @@ publishing {
pom.withXml {
def dependenciesNode = new Node(null, 'dependencies')
project.configurations.shadow.allDependencies.each { dep ->
project.configurations.pomDeps.allDependencies.each { dep ->
if (dep.group == null && dep.name == 'unspecified') {
// Ignore the thirdparty self-dependency
return;
}
def dependencyNode = dependenciesNode.appendNode('dependency')
dependencyNode.appendNode('groupId', dep.group)
dependencyNode.appendNode('artifactId', dep.name)