2019-09-07 23:18:57 +08:00
|
|
|
plugins {
|
2020-03-20 03:37:48 +08:00
|
|
|
id "com.android.application" apply false // Necessary for Android plugin to find its classes
|
|
|
|
id "com.android.library" apply false
|
2019-09-07 23:18:57 +08:00
|
|
|
id "com.google.osdetector" apply false
|
|
|
|
id "me.champeau.gradle.japicmp" apply false
|
|
|
|
id "net.ltgt.errorprone" apply false
|
2015-04-18 01:49:11 +08:00
|
|
|
}
|
2015-03-01 01:59:25 +08:00
|
|
|
|
2018-12-14 02:17:06 +08:00
|
|
|
import net.ltgt.gradle.errorprone.CheckSeverity
|
|
|
|
|
2015-09-05 04:26:24 +08:00
|
|
|
subprojects {
|
2015-01-31 06:58:07 +08:00
|
|
|
apply plugin: "checkstyle"
|
2014-12-16 01:58:05 +08:00
|
|
|
apply plugin: "maven"
|
2015-01-22 06:30:14 +08:00
|
|
|
apply plugin: "idea"
|
2015-03-03 05:31:14 +08:00
|
|
|
apply plugin: "signing"
|
2015-05-06 03:29:26 +08:00
|
|
|
apply plugin: "jacoco"
|
2014-12-16 01:58:05 +08:00
|
|
|
|
2015-09-17 06:15:10 +08:00
|
|
|
apply plugin: "com.google.osdetector"
|
2018-12-14 02:17:06 +08:00
|
|
|
apply plugin: "net.ltgt.errorprone"
|
2015-09-17 06:15:10 +08:00
|
|
|
|
2015-01-28 02:25:39 +08:00
|
|
|
group = "io.grpc"
|
2020-07-16 04:51:06 +08:00
|
|
|
version = "1.32.0-SNAPSHOT" // CURRENT_GRPC_VERSION
|
2014-12-16 01:58:05 +08:00
|
|
|
|
|
|
|
repositories {
|
2018-06-12 09:35:18 +08:00
|
|
|
maven { // The google mirror is less flaky than mavenCentral()
|
2020-07-10 00:38:24 +08:00
|
|
|
url "https://maven-central.storage-download.googleapis.com/maven2/" }
|
2019-09-28 02:05:56 +08:00
|
|
|
mavenCentral()
|
2018-03-02 11:11:24 +08:00
|
|
|
mavenLocal()
|
2014-12-16 01:58:05 +08:00
|
|
|
}
|
|
|
|
|
2019-09-08 00:03:53 +08:00
|
|
|
tasks.withType(JavaCompile) {
|
2018-06-12 09:35:18 +08:00
|
|
|
it.options.compilerArgs += [
|
|
|
|
"-Xlint:all",
|
|
|
|
"-Xlint:-options",
|
2018-08-17 00:35:25 +08:00
|
|
|
"-Xlint:-path",
|
|
|
|
"-Xlint:-try"
|
2018-06-12 09:35:18 +08:00
|
|
|
]
|
2015-03-13 06:25:11 +08:00
|
|
|
it.options.encoding = "UTF-8"
|
2016-07-11 02:40:12 +08:00
|
|
|
if (rootProject.hasProperty('failOnWarnings') && rootProject.failOnWarnings.toBoolean()) {
|
|
|
|
it.options.compilerArgs += ["-Werror"]
|
|
|
|
}
|
2015-01-27 06:03:11 +08:00
|
|
|
}
|
|
|
|
|
2020-07-07 06:40:45 +08:00
|
|
|
tasks.withType(GenerateModuleMetadata) {
|
|
|
|
// Module metadata, introduced in Gradle 6.0, conflicts with our publishing task for
|
|
|
|
// grpc-alts and grpc-compiler.
|
|
|
|
enabled = false
|
|
|
|
}
|
|
|
|
|
2020-05-02 13:59:06 +08:00
|
|
|
def isAndroid = project.name in [
|
|
|
|
'grpc-android', 'grpc-android-interop-testing', 'grpc-cronet']
|
|
|
|
|
2015-02-14 08:21:53 +08:00
|
|
|
ext {
|
2015-05-08 06:20:44 +08:00
|
|
|
def exeSuffix = osdetector.os == 'windows' ? ".exe" : ""
|
|
|
|
protocPluginBaseName = 'protoc-gen-grpc-java'
|
2016-01-27 04:13:06 +08:00
|
|
|
javaPluginPath = "$rootDir/compiler/build/exe/java_plugin/$protocPluginBaseName$exeSuffix"
|
2015-05-08 06:20:44 +08:00
|
|
|
|
2020-03-25 02:54:59 +08:00
|
|
|
nettyVersion = '4.1.48.Final'
|
2020-06-04 04:48:02 +08:00
|
|
|
guavaVersion = '29.0-android'
|
2020-01-31 04:59:55 +08:00
|
|
|
googleauthVersion = '0.20.0'
|
2020-05-21 07:30:59 +08:00
|
|
|
protobufVersion = '3.12.0'
|
2019-02-08 05:40:53 +08:00
|
|
|
protocVersion = protobufVersion
|
2019-10-31 01:47:43 +08:00
|
|
|
opencensusVersion = '0.24.0'
|
2015-05-08 06:20:44 +08:00
|
|
|
|
2015-05-06 07:11:27 +08:00
|
|
|
configureProtoCompilation = {
|
2018-06-12 09:35:18 +08:00
|
|
|
String generatedSourcePath = "${projectDir}/src/generated"
|
2018-10-25 05:25:22 +08:00
|
|
|
project.protobuf {
|
|
|
|
protoc {
|
|
|
|
if (project.hasProperty('protoc')) {
|
|
|
|
path = project.protoc
|
|
|
|
} else {
|
|
|
|
artifact = "com.google.protobuf:protoc:${protocVersion}"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
generateProtoTasks {
|
|
|
|
all().each { task ->
|
|
|
|
// Recompile protos when build.gradle has been changed, because
|
|
|
|
// it's possible the version of protoc has been changed.
|
|
|
|
task.inputs.file "${rootProject.projectDir}/build.gradle"
|
2020-03-20 03:37:48 +08:00
|
|
|
if (isAndroid) {
|
|
|
|
task.builtins {
|
|
|
|
java { option 'lite' }
|
|
|
|
}
|
|
|
|
}
|
2018-10-25 05:25:22 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-06-12 09:35:18 +08:00
|
|
|
if (rootProject.childProjects.containsKey('grpc-compiler')) {
|
2018-10-25 05:25:22 +08:00
|
|
|
// Only when the codegen is built along with the project, will we be able to run
|
|
|
|
// the grpc code generator.
|
2020-03-20 03:37:48 +08:00
|
|
|
task syncGeneratedSources { }
|
2018-06-12 09:35:18 +08:00
|
|
|
project.protobuf {
|
|
|
|
plugins { grpc { path = javaPluginPath } }
|
|
|
|
generateProtoTasks {
|
|
|
|
all().each { task ->
|
2020-03-20 03:37:48 +08:00
|
|
|
String variantOrSourceSet = isAndroid ? task.variant.name : task.sourceSet.name
|
|
|
|
def syncTask = project.tasks.register("syncGeneratedSources${variantOrSourceSet}", Sync) {
|
|
|
|
from "$buildDir/generated/source/proto/${variantOrSourceSet}/grpc"
|
|
|
|
into "$generatedSourcePath/${variantOrSourceSet}/grpc"
|
|
|
|
}
|
|
|
|
syncGeneratedSources.dependsOn syncTask
|
2018-10-25 05:25:22 +08:00
|
|
|
|
2018-06-12 09:35:18 +08:00
|
|
|
task.dependsOn ':grpc-compiler:java_pluginExecutable'
|
|
|
|
// Recompile protos when the codegen has been changed
|
|
|
|
task.inputs.file javaPluginPath
|
|
|
|
task.plugins { grpc { option 'noversion' } }
|
2020-03-20 03:37:48 +08:00
|
|
|
if (isAndroid) {
|
|
|
|
task.plugins {
|
|
|
|
grpc {
|
|
|
|
option 'lite'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-06-12 09:35:18 +08:00
|
|
|
}
|
|
|
|
}
|
2015-06-23 07:29:30 +08:00
|
|
|
}
|
2018-10-25 05:25:22 +08:00
|
|
|
// Re-sync as part of a normal build, to avoid forgetting to run the sync
|
|
|
|
assemble.dependsOn syncGeneratedSources
|
2018-06-12 09:35:18 +08:00
|
|
|
} else {
|
|
|
|
// Otherwise, we just use the checked-in generated code.
|
2020-03-20 03:37:48 +08:00
|
|
|
if (isAndroid) {
|
|
|
|
project.android.sourceSets {
|
|
|
|
debug { java { srcDir "${generatedSourcePath}/debug/grpc" } }
|
|
|
|
release { java { srcDir "${generatedSourcePath}/release/grpc" } }
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
project.sourceSets {
|
|
|
|
main { java { srcDir "${generatedSourcePath}/main/grpc" } }
|
|
|
|
test { java { srcDir "${generatedSourcePath}/test/grpc" } }
|
|
|
|
}
|
2015-05-08 08:32:31 +08:00
|
|
|
}
|
2015-06-23 07:29:30 +08:00
|
|
|
}
|
|
|
|
|
2019-09-08 00:03:53 +08:00
|
|
|
tasks.withType(JavaCompile) {
|
2018-10-25 05:25:22 +08:00
|
|
|
it.options.errorprone.excludedPaths = ".*/src/generated/[^/]+/java/.*" +
|
|
|
|
"|.*/build/generated/source/proto/[^/]+/java/.*"
|
2015-05-12 07:58:28 +08:00
|
|
|
}
|
2015-05-06 07:11:27 +08:00
|
|
|
}
|
|
|
|
|
2015-02-14 08:21:53 +08:00
|
|
|
libraries = [
|
2019-03-06 06:46:38 +08:00
|
|
|
android_annotations: "com.google.android:annotations:4.1.1.4",
|
2019-12-06 05:15:59 +08:00
|
|
|
animalsniffer_annotations: "org.codehaus.mojo:animal-sniffer-annotations:1.18",
|
2020-01-04 06:50:34 +08:00
|
|
|
errorprone: "com.google.errorprone:error_prone_annotations:2.3.4",
|
2020-01-10 07:20:41 +08:00
|
|
|
cronet_api: 'org.chromium.net:cronet-api:76.3809.111',
|
|
|
|
cronet_embedded: 'org.chromium.net:cronet-embedded:66.3359.158',
|
2019-12-03 08:18:12 +08:00
|
|
|
gson: "com.google.code.gson:gson:2.8.6",
|
2018-06-12 09:35:18 +08:00
|
|
|
guava: "com.google.guava:guava:${guavaVersion}",
|
|
|
|
hpack: 'com.twitter:hpack:0.10.1',
|
2020-04-30 07:46:00 +08:00
|
|
|
javax_annotation: 'org.apache.tomcat:annotations-api:6.0.53',
|
2018-09-21 02:43:54 +08:00
|
|
|
jsr305: 'com.google.code.findbugs:jsr305:3.0.2',
|
2019-12-28 03:55:05 +08:00
|
|
|
google_api_protos: 'com.google.api.grpc:proto-google-common-protos:1.17.0',
|
2019-01-04 02:50:44 +08:00
|
|
|
google_auth_credentials: "com.google.auth:google-auth-library-credentials:${googleauthVersion}",
|
|
|
|
google_auth_oauth2_http: "com.google.auth:google-auth-library-oauth2-http:${googleauthVersion}",
|
2020-02-25 04:23:11 +08:00
|
|
|
okhttp: 'com.squareup.okhttp:okhttp:2.7.4',
|
2018-06-12 09:35:18 +08:00
|
|
|
okio: 'com.squareup.okio:okio:1.13.0',
|
|
|
|
opencensus_api: "io.opencensus:opencensus-api:${opencensusVersion}",
|
|
|
|
opencensus_contrib_grpc_metrics: "io.opencensus:opencensus-contrib-grpc-metrics:${opencensusVersion}",
|
|
|
|
opencensus_impl: "io.opencensus:opencensus-impl:${opencensusVersion}",
|
|
|
|
opencensus_impl_lite: "io.opencensus:opencensus-impl-lite:${opencensusVersion}",
|
2020-03-31 03:16:29 +08:00
|
|
|
opencensus_proto: "io.opencensus:opencensus-proto:0.2.0",
|
2018-06-12 09:35:18 +08:00
|
|
|
instrumentation_api: 'com.google.instrumentation:instrumentation-api:0.4.3',
|
2019-10-23 07:55:39 +08:00
|
|
|
perfmark: 'io.perfmark:perfmark-api:0.19.0',
|
2018-06-12 09:35:18 +08:00
|
|
|
protobuf: "com.google.protobuf:protobuf-java:${protobufVersion}",
|
2019-11-15 02:26:20 +08:00
|
|
|
protobuf_lite: "com.google.protobuf:protobuf-javalite:${protobufVersion}",
|
2018-06-12 09:35:18 +08:00
|
|
|
protobuf_util: "com.google.protobuf:protobuf-java-util:${protobufVersion}",
|
|
|
|
lang: "org.apache.commons:commons-lang3:3.5",
|
|
|
|
|
|
|
|
netty: "io.netty:netty-codec-http2:[${nettyVersion}]",
|
2019-06-07 05:54:15 +08:00
|
|
|
netty_epoll: "io.netty:netty-transport-native-epoll:${nettyVersion}:linux-x86_64",
|
2018-06-12 09:35:18 +08:00
|
|
|
netty_proxy_handler: "io.netty:netty-handler-proxy:${nettyVersion}",
|
2018-12-04 05:19:17 +08:00
|
|
|
|
|
|
|
// Keep the following references of tcnative version in sync whenever it's updated
|
|
|
|
// SECURITY.md (multiple occurrences)
|
2018-12-07 04:03:25 +08:00
|
|
|
// examples/example-tls/build.gradle
|
|
|
|
// examples/example-tls/pom.xml
|
2020-03-25 02:54:59 +08:00
|
|
|
netty_tcnative: 'io.netty:netty-tcnative-boringssl-static:2.0.30.Final',
|
2018-06-12 09:35:18 +08:00
|
|
|
|
2019-10-01 04:39:22 +08:00
|
|
|
conscrypt: 'org.conscrypt:conscrypt-openjdk-uber:2.2.1',
|
2018-06-12 09:35:18 +08:00
|
|
|
re2j: 'com.google.re2j:re2j:1.2',
|
|
|
|
|
|
|
|
// Test dependencies.
|
|
|
|
junit: 'junit:junit:4.12',
|
2019-10-31 02:07:50 +08:00
|
|
|
mockito: 'org.mockito:mockito-core:2.28.2',
|
2020-02-27 03:17:42 +08:00
|
|
|
truth: 'com.google.truth:truth:1.0.1',
|
2018-09-21 02:43:54 +08:00
|
|
|
guava_testlib: "com.google.guava:guava-testlib:${guavaVersion}",
|
2020-03-05 07:40:39 +08:00
|
|
|
androidx_test: "androidx.test:core:1.2.0",
|
2020-01-14 03:39:05 +08:00
|
|
|
robolectric: "org.robolectric:robolectric:4.3.1",
|
2018-06-12 09:35:18 +08:00
|
|
|
|
|
|
|
// Benchmark dependencies
|
|
|
|
hdrhistogram: 'org.hdrhistogram:HdrHistogram:2.1.10',
|
|
|
|
math: 'org.apache.commons:commons-math3:3.6',
|
|
|
|
|
|
|
|
// Jetty ALPN dependencies
|
2020-06-25 22:13:17 +08:00
|
|
|
jetty_alpn_agent: 'org.mortbay.jetty.alpn:jetty-alpn-agent:2.0.10'
|
2016-05-03 05:01:36 +08:00
|
|
|
]
|
2020-05-02 13:59:28 +08:00
|
|
|
|
|
|
|
// A util function to config guava dependency with transitive dependencies
|
|
|
|
// properly resolved for the failOnVersionConflict strategy.
|
|
|
|
guavaDependency = { configurationName ->
|
|
|
|
dependencies."$configurationName"(libraries.guava) {
|
|
|
|
exclude group: 'com.google.code.findbugs', module: 'jsr305'
|
|
|
|
exclude group: 'com.google.errorprone', module: 'error_prone_annotations'
|
|
|
|
exclude group: 'org.codehaus.mojo', module: 'animal-sniffer-annotations'
|
|
|
|
}
|
|
|
|
dependencies."$configurationName" libraries.errorprone
|
|
|
|
dependencies.runtimeOnly libraries.animalsniffer_annotations
|
|
|
|
dependencies.runtimeOnly libraries.jsr305
|
|
|
|
}
|
|
|
|
|
|
|
|
// A util function to config opencensus_api dependency with transitive
|
|
|
|
// dependencies properly resolved for the failOnVersionConflict strategy.
|
|
|
|
censusApiDependency = { configurationName ->
|
|
|
|
dependencies."$configurationName"(libraries.opencensus_api) {
|
|
|
|
exclude group: 'com.google.code.findbugs', module: 'jsr305'
|
|
|
|
exclude group: 'com.google.guava', module: 'guava'
|
|
|
|
// we'll always be more up-to-date
|
|
|
|
exclude group: 'io.grpc', module: 'grpc-context'
|
|
|
|
}
|
|
|
|
dependencies.runtimeOnly project(':grpc-context')
|
|
|
|
dependencies.runtimeOnly libraries.jsr305
|
|
|
|
guavaDependency 'runtimeOnly'
|
|
|
|
}
|
|
|
|
|
|
|
|
// A util function to config opencensus_contrib_grpc_metrics dependency
|
|
|
|
// with transitive dependencies properly resolved for the failOnVersionConflict
|
|
|
|
// strategy.
|
|
|
|
censusGrpcMetricDependency = { configurationName ->
|
|
|
|
dependencies."$configurationName"(libraries.opencensus_contrib_grpc_metrics) {
|
|
|
|
exclude group: 'com.google.code.findbugs', module: 'jsr305'
|
|
|
|
exclude group: 'com.google.guava', module: 'guava'
|
|
|
|
// we'll always be more up-to-date
|
|
|
|
exclude group: 'io.grpc', module: 'grpc-context'
|
|
|
|
}
|
|
|
|
dependencies.runtimeOnly project(':grpc-context')
|
|
|
|
dependencies.runtimeOnly libraries.jsr305
|
|
|
|
guavaDependency 'runtimeOnly'
|
|
|
|
}
|
|
|
|
|
|
|
|
// A util function to config perfmark dependency with transitive
|
|
|
|
// dependencies properly resolved for the failOnVersionConflict strategy.
|
|
|
|
perfmarkDependency = { configurationName ->
|
|
|
|
dependencies."$configurationName"(libraries.perfmark) {
|
|
|
|
exclude group: 'com.google.errorprone', module: 'error_prone_annotations'
|
|
|
|
}
|
|
|
|
dependencies.runtimeOnly libraries.errorprone
|
|
|
|
}
|
2015-02-14 08:21:53 +08:00
|
|
|
}
|
2014-12-16 01:58:05 +08:00
|
|
|
|
2015-05-23 03:25:10 +08:00
|
|
|
configurations {
|
2020-05-02 13:59:06 +08:00
|
|
|
// Detect Maven Enforcer's dependencyConvergence failures. We only
|
|
|
|
// care for artifacts used as libraries by others.
|
|
|
|
if (isAndroid && !(project.name in ['grpc-android-interop-testing'])) {
|
|
|
|
releaseRuntimeClasspath {
|
|
|
|
resolutionStrategy.failOnVersionConflict()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!isAndroid && !(project.name in [
|
2018-06-12 09:35:18 +08:00
|
|
|
'grpc-benchmarks',
|
2018-07-21 08:59:19 +08:00
|
|
|
'grpc-interop-testing',
|
|
|
|
'grpc-gae-interop-testing-jdk8',
|
2020-05-02 13:59:06 +08:00
|
|
|
])) {
|
|
|
|
runtimeClasspath {
|
2017-09-19 07:20:18 +08:00
|
|
|
resolutionStrategy.failOnVersionConflict()
|
|
|
|
}
|
|
|
|
}
|
2015-05-23 03:25:10 +08:00
|
|
|
}
|
|
|
|
|
2015-03-03 23:59:13 +08:00
|
|
|
// Disable JavaDoc doclint on Java 8. It's annoying.
|
|
|
|
if (JavaVersion.current().isJava8Compatible()) {
|
2018-06-12 09:35:18 +08:00
|
|
|
allprojects {
|
|
|
|
tasks.withType(Javadoc) {
|
|
|
|
options.addStringOption('Xdoclint:none', '-quiet')
|
|
|
|
}
|
2015-03-03 23:59:13 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-07-20 04:35:27 +08:00
|
|
|
// For jdk10 we must explicitly choose between html4 and html5, otherwise we get a warning
|
|
|
|
if (JavaVersion.current().isJava10Compatible()) {
|
|
|
|
allprojects {
|
|
|
|
tasks.withType(Javadoc) {
|
|
|
|
options.addBooleanOption('html4', true)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-02-01 09:38:43 +08:00
|
|
|
jacoco { toolVersion = "0.8.2" }
|
2018-10-18 02:49:30 +08:00
|
|
|
|
2015-01-31 06:58:07 +08:00
|
|
|
checkstyle {
|
2017-07-13 01:53:50 +08:00
|
|
|
configDir = file("$rootDir/buildscripts")
|
2016-04-19 00:15:25 +08:00
|
|
|
toolVersion = "6.17"
|
2015-05-05 23:54:51 +08:00
|
|
|
ignoreFailures = false
|
2015-03-22 01:59:17 +08:00
|
|
|
if (rootProject.hasProperty("checkstyle.ignoreFailures")) {
|
|
|
|
ignoreFailures = rootProject.properties["checkstyle.ignoreFailures"].toBoolean()
|
|
|
|
}
|
2015-01-31 06:58:07 +08:00
|
|
|
}
|
|
|
|
|
2020-01-10 07:20:41 +08:00
|
|
|
if (rootProject.properties.get('errorProne', true)) {
|
|
|
|
dependencies {
|
|
|
|
errorprone 'com.google.errorprone:error_prone_core:2.3.4'
|
|
|
|
errorproneJavac 'com.google.errorprone:javac:9+181-r4173-1'
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// Disable Error Prone
|
|
|
|
allprojects {
|
|
|
|
afterEvaluate { project ->
|
|
|
|
project.tasks.withType(JavaCompile) {
|
|
|
|
options.errorprone.enabled = false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-08 01:24:29 +08:00
|
|
|
plugins.withId("java") {
|
|
|
|
sourceCompatibility = 1.7
|
|
|
|
targetCompatibility = 1.7
|
|
|
|
|
|
|
|
dependencies {
|
|
|
|
testCompile libraries.junit,
|
|
|
|
libraries.mockito,
|
|
|
|
libraries.truth
|
|
|
|
}
|
|
|
|
|
|
|
|
compileTestJava {
|
|
|
|
// serialVersionUID is basically guaranteed to be useless in our tests
|
|
|
|
options.compilerArgs += [
|
|
|
|
"-Xlint:-serial"
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
|
|
|
jar.manifest {
|
|
|
|
attributes('Implementation-Title': name,
|
|
|
|
'Implementation-Version': version,
|
|
|
|
'Built-By': System.getProperty('user.name'),
|
|
|
|
'Built-JDK': System.getProperty('java.version'),
|
|
|
|
'Source-Compatibility': sourceCompatibility,
|
|
|
|
'Target-Compatibility': targetCompatibility)
|
|
|
|
}
|
|
|
|
|
|
|
|
javadoc.options {
|
|
|
|
encoding = 'UTF-8'
|
|
|
|
use = true
|
|
|
|
links 'https://docs.oracle.com/javase/8/docs/api/'
|
|
|
|
source = "8"
|
|
|
|
}
|
|
|
|
|
|
|
|
checkstyleMain {
|
2019-09-24 02:48:00 +08:00
|
|
|
source = fileTree(dir: "$projectDir/src/main", include: "**/*.java")
|
2019-09-08 01:24:29 +08:00
|
|
|
}
|
2015-01-31 06:58:07 +08:00
|
|
|
|
2019-09-08 01:24:29 +08:00
|
|
|
checkstyleTest {
|
2019-09-24 02:48:00 +08:00
|
|
|
source = fileTree(dir: "$projectDir/src/test", include: "**/*.java")
|
2019-09-08 01:24:29 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// At a test failure, log the stack trace to the console so that we don't
|
|
|
|
// have to open the HTML in a browser.
|
|
|
|
test {
|
|
|
|
testLogging {
|
|
|
|
exceptionFormat = 'full'
|
|
|
|
showExceptions true
|
|
|
|
showCauses true
|
|
|
|
showStackTraces true
|
|
|
|
}
|
|
|
|
maxHeapSize = '1500m'
|
|
|
|
}
|
|
|
|
|
|
|
|
if (rootProject.properties.get('errorProne', true)) {
|
|
|
|
dependencies {
|
|
|
|
annotationProcessor 'com.google.guava:guava-beta-checker:1.0'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-01-04 06:50:34 +08:00
|
|
|
compileJava {
|
|
|
|
// This project targets Java 7 (no method references)
|
|
|
|
options.errorprone.check("UnnecessaryAnonymousClass", CheckSeverity.OFF)
|
|
|
|
// This project targets Java 7 (no time.Duration class)
|
|
|
|
options.errorprone.check("PreferJavaTimeOverload", CheckSeverity.OFF)
|
|
|
|
}
|
2019-09-08 01:24:29 +08:00
|
|
|
compileTestJava {
|
|
|
|
// LinkedList doesn't hurt much in tests and has lots of usages
|
|
|
|
options.errorprone.check("JdkObsolete", CheckSeverity.OFF)
|
2020-01-04 06:50:34 +08:00
|
|
|
options.errorprone.check("UnnecessaryAnonymousClass", CheckSeverity.OFF)
|
|
|
|
options.errorprone.check("PreferJavaTimeOverload", CheckSeverity.OFF)
|
2019-09-08 01:24:29 +08:00
|
|
|
}
|
2015-01-31 06:58:07 +08:00
|
|
|
}
|
|
|
|
|
2019-09-08 00:03:53 +08:00
|
|
|
plugins.withId("me.champeau.gradle.jmh") {
|
|
|
|
dependencies {
|
|
|
|
jmh 'org.openjdk.jmh:jmh-core:1.19',
|
|
|
|
'org.openjdk.jmh:jmh-generator-bytecode:1.19'
|
|
|
|
}
|
|
|
|
// invoke jmh on a single benchmark class like so:
|
|
|
|
// ./gradlew -PjmhIncludeSingleClass=StatsTraceContextBenchmark clean :grpc-core:jmh
|
|
|
|
jmh {
|
|
|
|
warmupIterations = 10
|
|
|
|
iterations = 10
|
|
|
|
fork = 1
|
|
|
|
// None of our benchmarks need the tests, and we have pseudo-circular
|
|
|
|
// dependencies that break when including them. (context's testCompile
|
|
|
|
// depends on core; core's testCompile depends on testing)
|
|
|
|
includeTests = false
|
|
|
|
if (project.hasProperty('jmhIncludeSingleClass')) {
|
|
|
|
include = [
|
|
|
|
project.property('jmhIncludeSingleClass')
|
|
|
|
]
|
|
|
|
}
|
2018-03-14 08:46:03 +08:00
|
|
|
}
|
2017-08-27 08:10:18 +08:00
|
|
|
}
|
|
|
|
|
2019-09-08 00:27:32 +08:00
|
|
|
plugins.withId("maven-publish") {
|
|
|
|
publishing {
|
|
|
|
publications {
|
|
|
|
// do not use mavenJava, as java plugin will modify it via "magic"
|
|
|
|
maven(MavenPublication) {
|
|
|
|
pom {
|
|
|
|
name = project.group + ":" + project.name
|
2019-02-01 09:38:43 +08:00
|
|
|
url = 'https://github.com/grpc/grpc-java'
|
2019-09-08 00:27:32 +08:00
|
|
|
afterEvaluate {
|
|
|
|
// description is not available until evaluated.
|
|
|
|
description = project.description
|
|
|
|
}
|
2015-03-13 08:03:01 +08:00
|
|
|
|
2019-09-08 00:27:32 +08:00
|
|
|
scm {
|
|
|
|
connection = 'scm:git:https://github.com/grpc/grpc-java.git'
|
|
|
|
developerConnection = 'scm:git:git@github.com:grpc/grpc-java.git'
|
|
|
|
url = 'https://github.com/grpc/grpc-java'
|
2019-02-01 09:38:43 +08:00
|
|
|
}
|
|
|
|
|
2019-09-08 00:27:32 +08:00
|
|
|
licenses {
|
|
|
|
license {
|
|
|
|
name = 'Apache 2.0'
|
|
|
|
url = 'https://opensource.org/licenses/Apache-2.0'
|
|
|
|
}
|
2019-02-01 09:38:43 +08:00
|
|
|
}
|
|
|
|
|
2019-09-08 00:27:32 +08:00
|
|
|
developers {
|
|
|
|
developer {
|
|
|
|
id = "grpc.io"
|
|
|
|
name = "gRPC Contributors"
|
|
|
|
email = "grpc-io@googlegroups.com"
|
|
|
|
url = "https://grpc.io/"
|
|
|
|
organization = "gRPC Authors"
|
|
|
|
organizationUrl = "https://www.google.com"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
withXml {
|
|
|
|
if (!(project.name in
|
|
|
|
[
|
|
|
|
"grpc-stub",
|
|
|
|
"grpc-protobuf",
|
|
|
|
"grpc-protobuf-lite",
|
|
|
|
])) {
|
|
|
|
asNode().dependencies.'*'.findAll() { dep ->
|
|
|
|
dep.artifactId.text() in ['grpc-api', 'grpc-core']
|
|
|
|
}.each() { core ->
|
|
|
|
core.version*.value = "[" + core.version.text() + "]"
|
|
|
|
}
|
2019-02-01 09:38:43 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-03-13 08:03:01 +08:00
|
|
|
}
|
|
|
|
}
|
2019-09-08 00:27:32 +08:00
|
|
|
repositories {
|
|
|
|
maven {
|
|
|
|
if (rootProject.hasProperty('repositoryDir')) {
|
|
|
|
url = new File(rootProject.repositoryDir).toURI()
|
2019-02-28 01:39:02 +08:00
|
|
|
} else {
|
2019-09-08 00:27:32 +08:00
|
|
|
String stagingUrl
|
|
|
|
if (rootProject.hasProperty('repositoryId')) {
|
|
|
|
stagingUrl = 'https://oss.sonatype.org/service/local/staging/deployByRepositoryId/' +
|
|
|
|
rootProject.repositoryId
|
|
|
|
} else {
|
|
|
|
stagingUrl = 'https://oss.sonatype.org/service/local/staging/deploy/maven2/'
|
|
|
|
}
|
|
|
|
credentials {
|
|
|
|
if (rootProject.hasProperty('ossrhUsername') && rootProject.hasProperty('ossrhPassword')) {
|
|
|
|
username = rootProject.ossrhUsername
|
|
|
|
password = rootProject.ossrhPassword
|
|
|
|
}
|
2019-02-28 01:39:02 +08:00
|
|
|
}
|
2019-09-08 00:27:32 +08:00
|
|
|
def releaseUrl = stagingUrl
|
|
|
|
def snapshotUrl = 'https://oss.sonatype.org/content/repositories/snapshots/'
|
|
|
|
url = version.endsWith('SNAPSHOT') ? snapshotUrl : releaseUrl
|
2019-02-28 01:39:02 +08:00
|
|
|
}
|
2019-09-08 00:27:32 +08:00
|
|
|
}
|
2018-06-12 09:35:18 +08:00
|
|
|
}
|
2016-04-09 04:47:30 +08:00
|
|
|
}
|
2019-02-01 09:38:43 +08:00
|
|
|
|
2019-09-08 00:27:32 +08:00
|
|
|
signing {
|
|
|
|
required false
|
|
|
|
sign publishing.publications.maven
|
|
|
|
}
|
2019-02-01 09:38:43 +08:00
|
|
|
|
2019-09-08 01:24:29 +08:00
|
|
|
plugins.withId("java") {
|
2020-07-31 04:59:34 +08:00
|
|
|
java {
|
|
|
|
withJavadocJar()
|
|
|
|
withSourcesJar()
|
2019-09-08 01:24:29 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
publishing {
|
|
|
|
publications {
|
|
|
|
maven {
|
|
|
|
if (project.name != 'grpc-netty-shaded') {
|
|
|
|
from components.java
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-04-23 01:02:19 +08:00
|
|
|
}
|
|
|
|
}
|
2017-09-27 23:31:43 +08:00
|
|
|
|
2019-09-08 01:23:23 +08:00
|
|
|
// Run with: ./gradlew japicmp --continue
|
|
|
|
plugins.withId("me.champeau.gradle.japicmp") {
|
|
|
|
def baselineGrpcVersion = '1.6.1'
|
2017-09-27 23:31:43 +08:00
|
|
|
|
|
|
|
// Get the baseline version's jar for this subproject
|
|
|
|
File baselineArtifact = null
|
|
|
|
// Use a detached configuration, otherwise the current version's jar will take precedence
|
|
|
|
// over the baseline jar.
|
|
|
|
// A necessary hack, the intuitive thing does NOT work:
|
|
|
|
// https://discuss.gradle.org/t/is-the-default-configuration-leaking-into-independent-configurations/2088/6
|
|
|
|
def oldGroup = project.group
|
|
|
|
try {
|
|
|
|
project.group = 'virtual_group_for_japicmp'
|
|
|
|
String depModule = "io.grpc:${project.name}:${baselineGrpcVersion}@jar"
|
|
|
|
String depJar = "${project.name}-${baselineGrpcVersion}.jar"
|
|
|
|
Configuration configuration = configurations.detachedConfiguration(
|
|
|
|
dependencies.create(depModule)
|
2018-06-12 09:35:18 +08:00
|
|
|
)
|
2017-09-27 23:31:43 +08:00
|
|
|
baselineArtifact = files(configuration.files).filter {
|
|
|
|
it.name.equals(depJar)
|
|
|
|
}.singleFile
|
|
|
|
} finally {
|
|
|
|
project.group = oldGroup
|
|
|
|
}
|
|
|
|
|
|
|
|
// Add a japicmp task that compares the current .jar with baseline .jar
|
|
|
|
task japicmp(type: me.champeau.gradle.japicmp.JapicmpTask, dependsOn: jar) {
|
|
|
|
oldClasspath = files(baselineArtifact)
|
|
|
|
newClasspath = files(jar.archivePath)
|
|
|
|
onlyBinaryIncompatibleModified = false
|
|
|
|
// Be quiet about things that did not change
|
|
|
|
onlyModified = true
|
|
|
|
// This task should fail if there are incompatible changes
|
|
|
|
failOnModification = true
|
|
|
|
ignoreMissingClasses = true
|
|
|
|
htmlOutputFile = file("$buildDir/reports/japi.html")
|
|
|
|
|
|
|
|
packageExcludes = ['io.grpc.internal']
|
|
|
|
|
|
|
|
// Also break on source incompatible changes, not just binary.
|
|
|
|
// Eg adding abstract method to public class.
|
|
|
|
// TODO(zpencer): enable after japicmp-gradle-plugin/pull/14
|
|
|
|
// breakOnSourceIncompatibility = true
|
|
|
|
|
|
|
|
// Ignore any classes or methods marked @ExperimentalApi
|
|
|
|
// TODO(zpencer): enable after japicmp-gradle-plugin/pull/15
|
|
|
|
// annotationExcludes = ['@io.grpc.ExperimentalApi']
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|