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

Annotation Processing #6

Closed
hsyed opened this issue Jan 31, 2018 · 6 comments
Closed

Annotation Processing #6

hsyed opened this issue Jan 31, 2018 · 6 comments

Comments

@hsyed
Copy link
Contributor

hsyed commented Jan 31, 2018

This needs some experimentation, notes:

  • Need an Aspect rule so that we can render an arbitrary java_plugin label into an abstract set of switches or preferably an encoded payload for the worker (bazel proto format ?).
    * Unless we can cache any of the results create a single set of temp directories for all annotation processors (src, classes and stubs). (RFC: Are temp directories OK ? also used in Mixed-Mode compilation - Compile Java and Kotlin in one pass in the worker. #3). (see #3 broad rework of mix-mode compilation and fixes. #10).
  • If the compilers needs to be invoked twice (likely).
    • Expand sources to include generated sources.
    • Merge classes in a separate step if needed (likely).
  • RFC: look into what intellij aspects expect, if I remember correctly we need to declare the sources as a separate source jar, what about the stubs and classes ?
  • I knocked together a bit of a execution framework, a bit like the java builder. I can see the Kotlin worker becoming part of bazel core in the distant future. (RFC: Could we leverage the framework elements from the JavaBuilder, and / or potentially introduce Kotlin into the Worker ?)
@hsyed
Copy link
Contributor Author

hsyed commented Feb 8, 2018

kapt3 doesn't respect the processors attribute (likely I am encoding it incorrectly), it will happily discover processors from the classpath though.

Issue in Kotlin Youtrack

@hsyed
Copy link
Contributor Author

hsyed commented Feb 9, 2018

implemented in #16 intellij support works well enough with dagger. The references are resolved against the compiled classes, an improvement would be to generate an annotations processing src jar and pass that through, happy for a PR on this.

@cgruber
Copy link
Collaborator

cgruber commented Feb 13, 2018

Note, we really don't want to rely on classpath discovery. That's not a required feature of javax.annotation.processing implementations, though it happens to work in javac and kapt3 for now. But we shouldn't rely on non-spec behavior. It's fine for now, but once jetbrains attends to your issue with kapt3 configuration, we should revert to explicitly passing the processors via java_plugin targets.

As to "compilers being invoked twice" - is that necessary? I know javac does multiple "rounds" - I assume kapt3 does this also, with kotlinc, but I don't know that for sure.

@hsyed
Copy link
Contributor Author

hsyed commented Feb 13, 2018

On classpath discovery: Kapt does not respect the processor list so what I have done for the time being is exclude the plugin entry entirely if it has a null or empty processor_class attribute. Need to wait on JB (link to issue above) to fix this.

Kotlinc does need to be invoked twice once with the kapt plugin config and once without, but this is done within the kotlin builder within the same function so the overhead I suspect is very low.

@hsyed
Copy link
Contributor Author

hsyed commented Feb 19, 2018

Kotlin Youtrack issue for annotation processor classes configuration.

@hsyed
Copy link
Contributor Author

hsyed commented Jul 4, 2018

Fixed since 1.2.40

@hsyed hsyed closed this as completed Jul 4, 2018
NathanHowell pushed a commit to godaddy-icfp/rules_kotlin that referenced this issue Jun 21, 2019
Ensure that the runtime deps pass along their javainfo if present
jongerrish added a commit to jongerrish/rules_kotlin that referenced this issue Apr 16, 2020
Ensure that the runtime deps pass along their javainfo if present
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants