Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

all: update animalsniffer to Java 7 and add Android 14 #4727

Merged
merged 5 commits into from
Aug 9, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion auth/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ dependencies {
libraries.google_auth_credentials
testCompile project(':grpc-testing'),
libraries.oauth_client
signature "org.codehaus.mojo.signature:java16:1.1@signature"
signature "org.codehaus.mojo.signature:java17:1.0@signature"
signature "net.sf.androidscents.signature:android-api-level-14:4.0_r4@signature"
}
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ subprojects {
epoll_suffix = ":" + osdetector.classifier
}
libraries = [
animalsniffer_annotations: "org.codehaus.mojo:animal-sniffer-annotations:1.17",
errorprone: "com.google.errorprone:error_prone_annotations:2.2.0",
gson: "com.google.code.gson:gson:2.7",
guava: "com.google.guava:guava:${guavaVersion}",
Expand Down
3 changes: 2 additions & 1 deletion context/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ description = 'gRPC: Context'

dependencies {
testCompile libraries.jsr305
signature "org.codehaus.mojo.signature:java16:1.1@signature"
signature "org.codehaus.mojo.signature:java17:1.0@signature"
signature "net.sf.androidscents.signature:android-api-level-14:4.0_r4@signature"
}
1 change: 1 addition & 0 deletions core/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ java_library(
"@com_google_guava_guava//jar",
"@io_opencensus_opencensus_api//jar",
"@io_opencensus_opencensus_contrib_grpc_metrics//jar",
"@org_codehaus_mojo_animal_sniffer_annotations//jar",
],
)

Expand Down
6 changes: 4 additions & 2 deletions core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ dependencies {
libraries.gson,
libraries.guava,
libraries.errorprone,
libraries.jsr305
libraries.jsr305,
libraries.animalsniffer_annotations
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

compileOnly. The annotation is Retention(Class)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

compileOnly triggers a Proguard warning (=> fails the Android build):

Warning: io.grpc.internal.JndiResourceResolverFactory$JndiResourceResolver: can't find referenced class org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement

I think JndiResourceResolverFactory should actually be stripped out by proguard, so adding a proguard -dontwarn is probably all that's necessary - but this would then be required in all downstream apps' proguard configs as well. Will look for a better solution here...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see a few options here: (fwiw, guava had some similar pain tracked in google/guava#2721)

  1. Keep the dependency as compileOnly, which will require Android apps to add a new -dontwarn to their proguard configs
  2. Bite the cost of making this a compile dependency in open-source. The annotation package is very small (no impact on Android app size/dex count).
  3. Use our own custom annotation (supported by animalsniffer) to avoid the dependency
  4. Drop the annotations altogether and configure animalsniffer to ignore JndiResourceResolverFactory's uses of unsupported APIs

I lean towards option 4. @ejona86 what do you think?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(2) sounds appropriate. Let's just add it as a normal dep. Unfortunate, but whatever.

compile (libraries.opencensus_api) {
// prefer 3.0.0 from libraries instead of 3.0.1
exclude group: 'com.google.code.findbugs', module: 'jsr305'
Expand All @@ -28,7 +29,8 @@ dependencies {
project(':grpc-grpclb'),
libraries.guava_testlib

signature "org.codehaus.mojo.signature:java16:1.1@signature"
signature "org.codehaus.mojo.signature:java17:1.0@signature"
signature "net.sf.androidscents.signature:android-api-level-14:4.0_r4@signature"
}

javadoc {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import javax.naming.directory.Attribute;
import javax.naming.directory.DirContext;
import javax.naming.directory.InitialDirContext;
import org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement;

/**
* {@link JndiResourceResolverFactory} resolves additional records for the DnsNameResolver.
Expand Down Expand Up @@ -194,6 +195,7 @@ static SrvRecord parseSrvRecord(String rawRecord) {
return new SrvRecord(parts[3], Integer.parseInt(parts[2]));
}

@IgnoreJRERequirement
private static List<String> getAllRecords(String recordType, String name)
throws NamingException {
String[] rrType = new String[]{recordType};
Expand Down Expand Up @@ -235,6 +237,7 @@ private static List<String> getAllRecords(String recordType, String name)
return records;
}

@IgnoreJRERequirement
private static void closeThenThrow(NamingEnumeration<?> namingEnumeration, NamingException e)
throws NamingException {
try {
Expand All @@ -245,6 +248,7 @@ private static void closeThenThrow(NamingEnumeration<?> namingEnumeration, Namin
throw e;
}

@IgnoreJRERequirement
private static void closeThenThrow(DirContext ctx, NamingException e) throws NamingException {
try {
ctx.close();
Expand Down
3 changes: 2 additions & 1 deletion okhttp/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ dependencies {
testCompile project(':grpc-core').sourceSets.test.output,
project(':grpc-testing'),
project(':grpc-netty')
signature "org.codehaus.mojo.signature:java16:1.1@signature"
signature "org.codehaus.mojo.signature:java17:1.0@signature"
signature "net.sf.androidscents.signature:android-api-level-14:4.0_r4@signature"
}

project.sourceSets {
Expand Down
3 changes: 2 additions & 1 deletion protobuf-lite/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ dependencies {

testProtobuf libraries.protobuf

signature "org.codehaus.mojo.signature:java16:1.1@signature"
signature "org.codehaus.mojo.signature:java17:1.0@signature"
signature "net.sf.androidscents.signature:android-api-level-14:4.0_r4@signature"
}

compileTestJava {
Expand Down
3 changes: 2 additions & 1 deletion protobuf-nano/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ dependencies {
compile project(':grpc-core'),
libraries.protobuf_nano,
libraries.guava
signature "org.codehaus.mojo.signature:java16:1.1@signature"
signature "org.codehaus.mojo.signature:java17:1.0@signature"
signature "net.sf.androidscents.signature:android-api-level-14:4.0_r4@signature"
}

configureProtoCompilation()
Expand Down
2 changes: 1 addition & 1 deletion protobuf/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ dependencies {
exclude group: 'com.google.protobuf', module: 'protobuf-lite'
}

signature "org.codehaus.mojo.signature:java16:1.1@signature"
signature "org.codehaus.mojo.signature:java17:1.0@signature"
}

javadoc.options.links 'https://developers.google.com/protocol-buffers/docs/reference/java/'
12 changes: 11 additions & 1 deletion repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ def grpc_java_repositories(
omit_io_opencensus_grpc_metrics = False,
omit_javax_annotation = False,
omit_junit_junit = False,
omit_org_apache_commons_lang3 = False):
omit_org_apache_commons_lang3 = False,
omit_org_codehaus_mojo_animal_sniffer_annotations = False):
"""Imports dependencies for grpc-java."""
if not omit_com_google_api_grpc_google_common_protos:
com_google_api_grpc_google_common_protos()
Expand Down Expand Up @@ -92,6 +93,8 @@ def grpc_java_repositories(
junit_junit()
if not omit_org_apache_commons_lang3:
org_apache_commons_lang3()
if not omit_org_codehaus_mojo_animal_sniffer_annotations:
org_codehaus_mojo_animal_sniffer_annotations()

native.bind(
name = "guava",
Expand Down Expand Up @@ -311,3 +314,10 @@ def org_apache_commons_lang3():
artifact = "org.apache.commons:commons-lang3:3.5",
sha1 = "6c6c702c89bfff3cd9e80b04d668c5e190d588c6",
)

def org_codehaus_mojo_animal_sniffer_annotations():
native.maven_jar(
name = "org_codehaus_mojo_animal_sniffer_annotations",
artifact = "org.codehaus.mojo:animal-sniffer-annotations:1.17",
sha1 = "f97ce6decaea32b36101e37979f8b647f00681fb",
)
2 changes: 1 addition & 1 deletion services/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ dependencies {
compileOnly libraries.javax_annotation
testCompile project(':grpc-testing'),
libraries.netty_epoll // for DomainSocketAddress
signature "org.codehaus.mojo.signature:java16:1.1@signature"
signature "org.codehaus.mojo.signature:java17:1.0@signature"
}

configureProtoCompilation()
3 changes: 2 additions & 1 deletion stub/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ dependencies {
compile project(':grpc-core')
testCompile libraries.truth,
project(':grpc-testing')
signature "org.codehaus.mojo.signature:java16:1.1@signature"
signature "org.codehaus.mojo.signature:java17:1.0@signature"
signature "net.sf.androidscents.signature:android-api-level-14:4.0_r4@signature"
}

javadoc.options.links "https://google.github.io/guava/releases/${guavaVersion}/api/docs/"