New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 792170 link

Starred by 1 user

Issue metadata

Status: Fixed
Owner:
Closed: Dec 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Android
Pri: 3
Type: Bug

Blocking:
issue 787005



Sign in to add a comment

Improve Annotation Processor support in our GN rules

Project Member Reported by agrieve@chromium.org, Dec 5 2017

Issue description

Problem #1) To use an annotation processor, you need to specify:

1) The target dep
2) The main_class (in every target that uses it, rather than just once)
3) The full classpath for the annotation processor

It would be much more sane to have to only specify 1). E.g.:

java_annotation_processor("my_processor") {
  jar_path = "lib/foo.jar"
  main_class = "foo.bar.Baz"
  deps = []  # define classpath
}

Then, to use it:

java_library("foo_java") {
  annotation_processors = [ ":my_processor" ]
}


Problem #2) Using an annotation processor breaks when used with android_library() targets that depend on resources.

This is because annotation processors currently use processed .jar files for the classpath. Normally, you'd use the "interface classpath". What we need them to use is the unprocessed .jar files.
 
Description: Show this description
Project Member

Comment 2 by bugdroid1@chromium.org, Dec 6 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/4227e23c8166bcf278455bc553c3fec566c2075d

commit 4227e23c8166bcf278455bc553c3fec566c2075d
Author: Andrew Grieve <agrieve@chromium.org>
Date: Wed Dec 06 22:06:19 2017

Android: Refactor GN templates to unify prebuilt & non-prebuilt logic

Makes it easier to add a java_annotation_processor() template

This removes main_class from java_prebuilt() in favor of using
java_binary() with a jar_path.

Bug:  792170 
Cq-Include-Trybots: master.tryserver.chromium.android:android_cronet_tester;master.tryserver.chromium.mac:ios-simulator-cronet
Change-Id: I8b92addae2228398f911d9456b9c55d5ebf48529
Reviewed-on: https://chromium-review.googlesource.com/810032
Reviewed-by: Andrei Kapishnikov <kapishnikov@chromium.org>
Reviewed-by: Eric Stevenson <estevenson@chromium.org>
Commit-Queue: agrieve <agrieve@chromium.org>
Cr-Commit-Position: refs/heads/master@{#522220}
[modify] https://crrev.com/4227e23c8166bcf278455bc553c3fec566c2075d/build/android/BUILD.gn
[modify] https://crrev.com/4227e23c8166bcf278455bc553c3fec566c2075d/build/android/gyp/create_java_binary_script.py
[modify] https://crrev.com/4227e23c8166bcf278455bc553c3fec566c2075d/build/android/gyp/write_build_config.py
[modify] https://crrev.com/4227e23c8166bcf278455bc553c3fec566c2075d/build/config/android/internal_rules.gni
[modify] https://crrev.com/4227e23c8166bcf278455bc553c3fec566c2075d/build/config/android/rules.gni
[modify] https://crrev.com/4227e23c8166bcf278455bc553c3fec566c2075d/components/cronet/android/BUILD.gn
[modify] https://crrev.com/4227e23c8166bcf278455bc553c3fec566c2075d/third_party/errorprone/BUILD.gn
[modify] https://crrev.com/4227e23c8166bcf278455bc553c3fec566c2075d/tools/android/errorprone_plugin/BUILD.gn

Project Member

Comment 3 by bugdroid1@chromium.org, Dec 11 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/bc0688555c7e9c33ac5cb9030940238591fe9d7a

commit bc0688555c7e9c33ac5cb9030940238591fe9d7a
Author: Andrew Grieve <agrieve@chromium.org>
Date: Mon Dec 11 16:33:04 2017

Android: Better support for Annotation Processors.

This introduces a dedicated template for defining and Annotation
Processor: java_annotation_processor().

Libraries can use them via:
  annotation_processor_deps = [":processor_target"]

We now explicitly pass a --processorpath to javac, and always path both
--interface-classpath and --classpath to javac.py. The
interface-classpath is always written to the depfile, but the normal
classpath is passed to javac when one or more annotation processors are
enabled.

Due to the added build_config complexity this brings, android_apk's
build_config is now written by java_library_impl(), and no more
override_build_config support exists.

Bug:  792170 
Change-Id: Ieebfa943615b9495010900c0a7be2b1ed9839a98
Reviewed-on: https://chromium-review.googlesource.com/817617
Commit-Queue: agrieve <agrieve@chromium.org>
Reviewed-by: Eric Stevenson <estevenson@chromium.org>
Cr-Commit-Position: refs/heads/master@{#523109}
[modify] https://crrev.com/bc0688555c7e9c33ac5cb9030940238591fe9d7a/build/android/gradle/generate_gradle.py
[modify] https://crrev.com/bc0688555c7e9c33ac5cb9030940238591fe9d7a/build/android/gradle/java.jinja
[modify] https://crrev.com/bc0688555c7e9c33ac5cb9030940238591fe9d7a/build/android/gyp/javac.py
[modify] https://crrev.com/bc0688555c7e9c33ac5cb9030940238591fe9d7a/build/android/gyp/lint.py
[modify] https://crrev.com/bc0688555c7e9c33ac5cb9030940238591fe9d7a/build/android/gyp/write_build_config.py
[modify] https://crrev.com/bc0688555c7e9c33ac5cb9030940238591fe9d7a/build/config/android/internal_rules.gni
[modify] https://crrev.com/bc0688555c7e9c33ac5cb9030940238591fe9d7a/build/config/android/rules.gni
[modify] https://crrev.com/bc0688555c7e9c33ac5cb9030940238591fe9d7a/third_party/auto/BUILD.gn
[modify] https://crrev.com/bc0688555c7e9c33ac5cb9030940238591fe9d7a/third_party/robolectric/BUILD.gn
[modify] https://crrev.com/bc0688555c7e9c33ac5cb9030940238591fe9d7a/tools/android/errorprone_plugin/BUILD.gn

Status: Fixed (was: Started)

Sign in to add a comment