From 29f800548fb231ca5af13b0b1f85bb5281fa691b Mon Sep 17 00:00:00 2001 From: Eric Anderson Date: Mon, 30 Oct 2017 12:42:31 -0700 Subject: [PATCH 1/2] Fix building with Java 9 --- benchmarks/build.gradle | 1 + build.gradle | 1 + core/src/test/java/io/grpc/AttributesTest.java | 17 +++++++++++++---- examples/build.gradle | 1 + grpclb/build.gradle | 1 + interop-testing/build.gradle | 1 + services/build.gradle | 1 + testing-proto/build.gradle | 1 + 8 files changed, 20 insertions(+), 4 deletions(-) diff --git a/benchmarks/build.gradle b/benchmarks/build.gradle index a0499e3ac84..4cab041e928 100644 --- a/benchmarks/build.gradle +++ b/benchmarks/build.gradle @@ -37,6 +37,7 @@ dependencies { libraries.netty_tcnative, libraries.netty_epoll, libraries.math + compileOnly libraries.javax_annotation } compileJava { diff --git a/build.gradle b/build.gradle index 08728492e07..a580cba4985 100644 --- a/build.gradle +++ b/build.gradle @@ -192,6 +192,7 @@ subprojects { gson: "com.google.code.gson:gson:2.7", guava: "com.google.guava:guava:${guavaVersion}", hpack: 'com.twitter:hpack:0.10.1', + javax_annotation: 'javax.annotation:javax.annotation-api:1.2', jsr305: 'com.google.code.findbugs:jsr305:3.0.0', oauth_client: 'com.google.auth:google-auth-library-oauth2-http:0.9.0', google_api_protos: 'com.google.api.grpc:proto-google-common-protos:1.0.0', diff --git a/core/src/test/java/io/grpc/AttributesTest.java b/core/src/test/java/io/grpc/AttributesTest.java index db4e86a324d..ab0bc79fee4 100644 --- a/core/src/test/java/io/grpc/AttributesTest.java +++ b/core/src/test/java/io/grpc/AttributesTest.java @@ -53,11 +53,20 @@ public void empty() { } @Test - @SuppressWarnings("BoxedPrimitiveConstructor") public void valueEquality() { - Attributes.Key key = Attributes.Key.of("ints"); - Integer v1 = new Integer(100000); - Integer v2 = new Integer(100000); + class EqualObject { + @Override public boolean equals(Object o) { + return o instanceof EqualObject; + } + + @Override public int hashCode() { + return 42; + } + } + + Attributes.Key key = Attributes.Key.of("ints"); + EqualObject v1 = new EqualObject(); + EqualObject v2 = new EqualObject(); assertNotSame(v1, v2); assertEquals(v1, v2); diff --git a/examples/build.gradle b/examples/build.gradle index 3d5888b9e28..068a9029a45 100644 --- a/examples/build.gradle +++ b/examples/build.gradle @@ -37,6 +37,7 @@ dependencies { compile "io.grpc:grpc-netty:${grpcVersion}" compile "io.grpc:grpc-protobuf:${grpcVersion}" compile "io.grpc:grpc-stub:${grpcVersion}" + compileOnly "javax.annotation:javax.annotation-api:1.2" // Used for TLS in HelloWorldServerTls compile "io.netty:netty-tcnative-boringssl-static:${nettyTcNativeVersion}" diff --git a/grpclb/build.gradle b/grpclb/build.gradle index 921a14ca622..03915c61ff6 100644 --- a/grpclb/build.gradle +++ b/grpclb/build.gradle @@ -17,6 +17,7 @@ dependencies { project(':grpc-protobuf'), project(':grpc-stub'), libraries.protobuf + compileOnly libraries.javax_annotation testCompile libraries.truth, project(':grpc-core').sourceSets.test.output } diff --git a/interop-testing/build.gradle b/interop-testing/build.gradle index 3de5573919f..afb5e6e30cf 100644 --- a/interop-testing/build.gradle +++ b/interop-testing/build.gradle @@ -29,6 +29,7 @@ dependencies { libraries.mockito, libraries.oauth_client, libraries.truth + compileOnly libraries.javax_annotation runtime libraries.opencensus_impl, libraries.netty_tcnative testCompile project(':grpc-context').sourceSets.test.output diff --git a/services/build.gradle b/services/build.gradle index 6f7924863e4..2438bfea795 100644 --- a/services/build.gradle +++ b/services/build.gradle @@ -22,6 +22,7 @@ dependencies { // we'll always be more up-to-date exclude group: 'io.grpc', module: 'grpc-context' } + compileOnly libraries.javax_annotation testCompile project(':grpc-testing'), libraries.netty_epoll // for DomainSocketAddress signature "org.codehaus.mojo.signature:java16:1.1@signature" diff --git a/testing-proto/build.gradle b/testing-proto/build.gradle index d28992127cf..8acff452b44 100644 --- a/testing-proto/build.gradle +++ b/testing-proto/build.gradle @@ -16,6 +16,7 @@ buildscript { dependencies { compile project(':grpc-protobuf'), project(':grpc-stub') + compileOnly libraries.javax_annotation testCompile libraries.truth } From 2afbf303c8560e4122e64664c435b322b5afbd24 Mon Sep 17 00:00:00 2001 From: Eric Anderson Date: Fri, 23 Mar 2018 09:46:01 -0700 Subject: [PATCH 2/2] Add travis CI for Java 9 --- .travis.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index aa15eea7b71..7ea9aee3d99 100644 --- a/.travis.yml +++ b/.travis.yml @@ -36,12 +36,17 @@ script: - ./gradlew check :grpc-all:jacocoTestReport after_success: - - if \[ "$TRAVIS_OS_NAME" = linux \]; then ./gradlew :grpc-all:coveralls; fi + # Upload to coveralls once, instead of for each job in the matrix + - if \[\[ "$TRAVIS_JOB_NUMBER" == *.1 \]\]; then ./gradlew :grpc-all:coveralls; fi - bash <(curl -s https://codecov.io/bash) os: - linux +jdk: + - oraclejdk8 + - oraclejdk9 + notifications: email: false