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" } } release { java { srcDir "${generatedSourcePath}/release/grpc" } }
} }
} else { } else {
project.sourceSets { project.sourceSets.each() { sourceSet ->
main { java { srcDir "${generatedSourcePath}/main/grpc" } } sourceSet.java { srcDir "${generatedSourcePath}/${sourceSet.name}/grpc" }
test { java { srcDir "${generatedSourcePath}/test/grpc" } }
} }
} }
} }

View File

@ -29,6 +29,7 @@ cd "$GRPC_JAVA_DIR"
## Deploy the dummy 'default' version of the service ## Deploy the dummy 'default' version of the service
## ##
GRADLE_FLAGS="--stacktrace -DgaeStopPreviousVersion=false -PskipCodegen=true -PskipAndroid=true" 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. # 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. # 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_LIBS=%ESCWORKSPACE%\\grpc-java-helper32\\protobuf-%PROTOBUF_VER%\\build\\Release
SET VC_PROTOBUF_INCLUDE=%ESCWORKSPACE%\\grpc-java-helper32\\protobuf-%PROTOBUF_VER%\\build\\include 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_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" cmd.exe /C "%WORKSPACE%\gradlew.bat %GRADLE_FLAGS% build"
set GRADLEEXIT=%ERRORLEVEL% 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_LIBS=%ESCWORKSPACE%\\grpc-java-helper64\\protobuf-%PROTOBUF_VER%\\build\\Release
SET VC_PROTOBUF_INCLUDE=%ESCWORKSPACE%\\grpc-java-helper64\\protobuf-%PROTOBUF_VER%\\build\\include 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_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 @rem make sure no daemons have any files open
cmd.exe /C "%WORKSPACE%\gradlew.bat --stop" cmd.exe /C "%WORKSPACE%\gradlew.bat --stop"

View File

@ -11,24 +11,41 @@ plugins {
description = "gRPC: XDS plugin" 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) 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 { dependencies {
implementation project(':grpc-protobuf'), thirdpartyCompileOnly libraries.javax.annotation
thirdpartyImplementation project(':grpc-protobuf'),
project(':grpc-stub'), project(':grpc-stub'),
libraries.opencensus.proto
implementation sourceSets.thirdparty.output
implementation project(':grpc-stub'),
project(':grpc-core'), project(':grpc-core'),
project(':grpc-services'), project(':grpc-services'),
project(':grpc-auth'), project(':grpc-auth'),
@ -36,7 +53,6 @@ dependencies {
libraries.gson, libraries.gson,
libraries.re2j, libraries.re2j,
libraries.auto.value.annotations, libraries.auto.value.annotations,
libraries.opencensus.proto,
libraries.protobuf.java.util libraries.protobuf.java.util
def nettyDependency = implementation project(':grpc-netty') def nettyDependency = implementation project(':grpc-netty')
@ -44,9 +60,8 @@ dependencies {
testImplementation project(':grpc-core').sourceSets.test.output testImplementation project(':grpc-core').sourceSets.test.output
annotationProcessor libraries.auto.value annotationProcessor libraries.auto.value
compileOnly libraries.javax.annotation, // At runtime use the epoll included in grpc-netty-shaded
// At runtime use the epoll included in grpc-netty-shaded compileOnly libraries.netty.transport.epoll
libraries.netty.transport.epoll
testImplementation project(':grpc-testing'), testImplementation project(':grpc-testing'),
project(':grpc-testing-proto') project(':grpc-testing-proto')
@ -92,30 +107,36 @@ dependencies {
} }
} }
sourceSets { configureProtoCompilation()
main {
java { compileThirdpartyJava {
srcDir "${projectDir}/third_party/zero-allocation-hashing/main/java" options.errorprone.enabled = false
} options.compilerArgs += [
proto { // valueOf(int) in RoutingPriority has been deprecated
srcDir 'third_party/envoy/src/main/proto' "-Xlint:-deprecation",
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() 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 { jar {
archiveClassifier = 'original' archiveClassifier = 'original'
from sourceSets.thirdparty.output
} }
javadoc { javadoc {
@ -211,7 +232,11 @@ publishing {
pom.withXml { pom.withXml {
def dependenciesNode = new Node(null, 'dependencies') 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') def dependencyNode = dependenciesNode.appendNode('dependency')
dependencyNode.appendNode('groupId', dep.group) dependencyNode.appendNode('groupId', dep.group)
dependencyNode.appendNode('artifactId', dep.name) dependencyNode.appendNode('artifactId', dep.name)