diff --git a/all/build.gradle b/all/build.gradle index 5cd86feb47..060a8d0ae2 100644 --- a/all/build.gradle +++ b/all/build.gradle @@ -1,4 +1,5 @@ plugins { + id "java" id "maven-publish" id "com.github.kt3k.coveralls" diff --git a/alts/build.gradle b/alts/build.gradle index 4b06db9e5d..3d510205bb 100644 --- a/alts/build.gradle +++ b/alts/build.gradle @@ -1,4 +1,5 @@ plugins { + id "java" id "maven-publish" id "com.github.johnrengelman.shadow" diff --git a/api/build.gradle b/api/build.gradle index ce4662904c..aecda52442 100644 --- a/api/build.gradle +++ b/api/build.gradle @@ -1,4 +1,5 @@ plugins { + id "java" id "maven-publish" id "me.champeau.gradle.jmh" diff --git a/auth/build.gradle b/auth/build.gradle index a95d141962..808766a23c 100644 --- a/auth/build.gradle +++ b/auth/build.gradle @@ -1,4 +1,5 @@ plugins { + id "java" id "maven-publish" id "me.champeau.gradle.japicmp" diff --git a/benchmarks/build.gradle b/benchmarks/build.gradle index a91c7b26e1..7aef7870e3 100644 --- a/benchmarks/build.gradle +++ b/benchmarks/build.gradle @@ -1,5 +1,6 @@ plugins { id "application" + id "java" id "maven-publish" id "com.google.protobuf" diff --git a/build.gradle b/build.gradle index 7591959fd7..7c41ffd644 100644 --- a/build.gradle +++ b/build.gradle @@ -9,7 +9,6 @@ import net.ltgt.gradle.errorprone.CheckSeverity subprojects { apply plugin: "checkstyle" - apply plugin: "java" apply plugin: "maven" apply plugin: "idea" apply plugin: "signing" @@ -20,30 +19,10 @@ subprojects { apply plugin: "ru.vyarus.animalsniffer" apply plugin: "net.ltgt.errorprone" - if (rootProject.properties.get('errorProne', true)) { - dependencies { - errorprone 'com.google.errorprone:error_prone_core:2.3.3' - errorproneJavac 'com.google.errorprone:javac:9+181-r4173-1' - - annotationProcessor 'com.google.guava:guava-beta-checker:1.0' - } - } else { - // Disable Error Prone - allprojects { - afterEvaluate { project -> - project.tasks.withType(JavaCompile) { - options.errorprone.enabled = false - } - } - } - } group = "io.grpc" version = "1.25.0-SNAPSHOT" // CURRENT_GRPC_VERSION - sourceCompatibility = 1.7 - targetCompatibility = 1.7 - repositories { maven { // The google mirror is less flaky than mavenCentral() url "https://maven-central.storage-download.googleapis.com/repos/central/data/" } @@ -63,31 +42,6 @@ subprojects { } } - compileTestJava { - // serialVersionUID is basically guaranteed to be useless in our tests - options.compilerArgs += [ - "-Xlint:-serial" - ] - // LinkedList doesn't hurt much in tests and has lots of usages - options.errorprone.check("JdkObsolete", CheckSeverity.OFF) - } - - 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" - } - ext { def exeSuffix = osdetector.os == 'windows' ? ".exe" : "" protocPluginBaseName = 'protoc-gen-grpc-java' @@ -233,12 +187,6 @@ subprojects { } } - dependencies { - testCompile libraries.junit, - libraries.mockito, - libraries.truth - } - // Disable JavaDoc doclint on Java 8. It's annoying. if (JavaVersion.current().isJava8Compatible()) { allprojects { @@ -268,12 +216,81 @@ subprojects { } } - checkstyleMain { - source = fileTree(dir: "src/main", include: "**/*.java") - } + plugins.withId("java") { + sourceCompatibility = 1.7 + targetCompatibility = 1.7 - checkstyleTest { - source = fileTree(dir: "src/test", include: "**/*.java") + 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 { + source = fileTree(dir: "src/main", include: "**/*.java") + } + + checkstyleTest { + source = fileTree(dir: "src/test", include: "**/*.java") + } + + // 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 { + errorprone 'com.google.errorprone:error_prone_core:2.3.3' + errorproneJavac 'com.google.errorprone:javac:9+181-r4173-1' + + annotationProcessor 'com.google.guava:guava-beta-checker:1.0' + } + } else { + // Disable Error Prone + allprojects { + afterEvaluate { project -> + project.tasks.withType(JavaCompile) { + options.errorprone.enabled = false + } + } + } + } + + compileTestJava { + // LinkedList doesn't hurt much in tests and has lots of usages + options.errorprone.check("JdkObsolete", CheckSeverity.OFF) + } } plugins.withId("me.champeau.gradle.jmh") { @@ -300,27 +317,10 @@ subprojects { } plugins.withId("maven-publish") { - task javadocJar(type: Jar) { - classifier = 'javadoc' - from javadoc - } - - task sourcesJar(type: Jar) { - classifier = 'sources' - from sourceSets.main.allSource - } - publishing { publications { // do not use mavenJava, as java plugin will modify it via "magic" maven(MavenPublication) { - if (project.name != 'grpc-netty-shaded') { - from components.java - } - - artifact javadocJar - artifact sourcesJar - pom { name = project.group + ":" + project.name url = 'https://github.com/grpc/grpc-java' @@ -400,18 +400,31 @@ subprojects { required false sign publishing.publications.maven } - } - // 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 + plugins.withId("java") { + task javadocJar(type: Jar) { + classifier = 'javadoc' + from javadoc + } + + task sourcesJar(type: Jar) { + classifier = 'sources' + from sourceSets.main.allSource + } + + publishing { + publications { + maven { + if (project.name != 'grpc-netty-shaded') { + from components.java + } + + artifact javadocJar + artifact sourcesJar + } + } + } } - maxHeapSize = '1500m' } // Run with: ./gradlew japicmp --continue diff --git a/compiler/build.gradle b/compiler/build.gradle index 1b0a21037f..ad2a609b6e 100644 --- a/compiler/build.gradle +++ b/compiler/build.gradle @@ -1,5 +1,6 @@ plugins { id "cpp" + id "java" id "maven-publish" id "com.google.protobuf" diff --git a/context/build.gradle b/context/build.gradle index dbde77aa2c..6903bcf03a 100644 --- a/context/build.gradle +++ b/context/build.gradle @@ -1,4 +1,5 @@ plugins { + id "java" id "maven-publish" id "me.champeau.gradle.japicmp" diff --git a/core/build.gradle b/core/build.gradle index 4e0ef7dee0..2f734ca527 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -1,4 +1,5 @@ plugins { + id "java" id "maven-publish" id "me.champeau.gradle.japicmp" @@ -7,6 +8,9 @@ plugins { description = 'gRPC: Core' +evaluationDependsOn(project(':grpc-context').path) +evaluationDependsOn(project(':grpc-api').path) + dependencies { compile project(':grpc-api'), libraries.gson, diff --git a/grpclb/build.gradle b/grpclb/build.gradle index c044e72091..bf5a9ca906 100644 --- a/grpclb/build.gradle +++ b/grpclb/build.gradle @@ -1,4 +1,5 @@ plugins { + id "java" id "maven-publish" id "com.google.protobuf" @@ -7,6 +8,8 @@ plugins { description = "gRPC: GRPCLB LoadBalancer plugin" +evaluationDependsOn(project(':grpc-core').path) + dependencies { compile project(':grpc-core'), project(':grpc-protobuf'), diff --git a/interop-testing/build.gradle b/interop-testing/build.gradle index 2178705c43..369dcc11f4 100644 --- a/interop-testing/build.gradle +++ b/interop-testing/build.gradle @@ -1,5 +1,6 @@ plugins { id "application" + id "java" id "maven-publish" id "com.google.protobuf" diff --git a/netty/build.gradle b/netty/build.gradle index 9076c7f0ac..374504e14b 100644 --- a/netty/build.gradle +++ b/netty/build.gradle @@ -1,4 +1,5 @@ plugins { + id "java" id "maven-publish" id "me.champeau.gradle.japicmp" diff --git a/netty/shaded/build.gradle b/netty/shaded/build.gradle index 609e6c3c28..1ecc36d970 100644 --- a/netty/shaded/build.gradle +++ b/netty/shaded/build.gradle @@ -1,4 +1,5 @@ plugins { + id "java" id "maven-publish" id "com.github.johnrengelman.shadow" diff --git a/okhttp/build.gradle b/okhttp/build.gradle index c88bf262a3..1cf98513a0 100644 --- a/okhttp/build.gradle +++ b/okhttp/build.gradle @@ -1,4 +1,5 @@ plugins { + id "java" id "maven-publish" id "me.champeau.gradle.japicmp" diff --git a/protobuf-lite/build.gradle b/protobuf-lite/build.gradle index 217f08795b..9bbe108529 100644 --- a/protobuf-lite/build.gradle +++ b/protobuf-lite/build.gradle @@ -1,4 +1,5 @@ plugins { + id "java" id "maven-publish" id "com.google.protobuf" diff --git a/protobuf/build.gradle b/protobuf/build.gradle index fb1ca70c54..45e0c637cc 100644 --- a/protobuf/build.gradle +++ b/protobuf/build.gradle @@ -1,4 +1,5 @@ plugins { + id "java" id "maven-publish" id "com.google.protobuf" diff --git a/services/build.gradle b/services/build.gradle index cac01f3d9a..03f7a6de75 100644 --- a/services/build.gradle +++ b/services/build.gradle @@ -1,4 +1,5 @@ plugins { + id "java" id "maven-publish" id "com.google.protobuf" diff --git a/stub/build.gradle b/stub/build.gradle index 8a4e1e357c..24df11721b 100644 --- a/stub/build.gradle +++ b/stub/build.gradle @@ -1,4 +1,5 @@ plugins { + id "java" id "maven-publish" id "me.champeau.gradle.japicmp" diff --git a/testing-proto/build.gradle b/testing-proto/build.gradle index 25a717bf3f..8ff8ccc6c0 100644 --- a/testing-proto/build.gradle +++ b/testing-proto/build.gradle @@ -1,4 +1,5 @@ plugins { + id "java" id "maven-publish" id "com.google.protobuf" diff --git a/testing/build.gradle b/testing/build.gradle index c156c7b45e..e64611d9eb 100644 --- a/testing/build.gradle +++ b/testing/build.gradle @@ -1,4 +1,5 @@ plugins { + id "java" id "maven-publish" id "me.champeau.gradle.japicmp" diff --git a/xds/build.gradle b/xds/build.gradle index fb98b48cd0..7a111e8839 100644 --- a/xds/build.gradle +++ b/xds/build.gradle @@ -1,4 +1,5 @@ plugins { + id "java" id "maven-publish" id "com.github.johnrengelman.shadow"