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

["Request"] Enable incremental annotation processing for processors #2032

Closed
aballano opened this issue Feb 4, 2020 · 7 comments
Closed

Comments

@aballano
Copy link
Member

aballano commented Feb 4, 2020

Incremental annotation processing requested, but support is disabled because the following processors are not incremental: arrow.core.extensions.ExtensionProcessor (NON_INCREMENTAL), arrow.fold.AutoFoldProcessor (NON_INCREMENTAL), arrow.generic.CoproductProcessor (NON_INCREMENTAL), arrow.generic.ProductProcessor (NON_INCREMENTAL), arrow.higherkinds.HigherKindsProcessor (NON_INCREMENTAL), arrow.optics.OpticsProcessor (NON_INCREMENTAL).

  • ExtensionProcessor
  • AutoFoldProcessor
  • CoproductProcessor
  • ProductProcessor
  • HigherKindsProcessor
  • OpticsProcessor

More info: https://docs.gradle.org/nightly/userguide/java_plugin.html#sec:incremental_annotation_processing

Gradle supports incremental compilation for two common categories of annotation processors: "isolating" and "aggregating".

We should investigate which one should we use. In any case it seems the File api cannot be used, but instead Filer

Note: This work might be eclipsed when meta is out and we can replace the annotation processors with it, so I'd advise against doing it if it's too complicated.

@JorgeCastilloPrz
Copy link
Member

Thanks for opening this issue, imho something like this should have high priority.

@hadilq
Copy link
Contributor

hadilq commented Jun 5, 2020

I start working on it! However, I noticed, here we use kotlin-poet with version 1.1.0, but they have supported writeTo(Filer) since version 1.2.0, so I believe to fix this issue we need to update this library first. Its current version is 1.5.0 so anyone has any concern about updating this library?

@JorgeCastilloPrz
Copy link
Member

I don't think we have any limitations for the bump. We've been putting low attention on processors because most of these features will be moved to compiler plugins with Meta. That said, and given Meta is taking longer than expected we'd be glad to get some help with this in the meantime, in my opinion. I think it's reasonable to bump since newer versions are for sure better adapted for incremental compilation, since that is something most of the libraries that rely on annotation processors have been working on already during the last year.

@hadilq
Copy link
Contributor

hadilq commented Jun 8, 2020

I've created arrow-kt/arrow-core#144 and #2154 but they're not building correctly as they're two different PRs!

@hadilq
Copy link
Contributor

hadilq commented Jun 8, 2020

To solve above issue, I committed

compile("com.squareup:kotlinpoet:1.5.0")

directly in arrow-kt/arrow-core#144. After merging this PR, we can update #2154 and merge it. Then we need to create another PR to bring

compile("com.squareup:kotlinpoet:$KOTLIN_POET_VERSION")

back again!
lmkwdyt.

@hadilq
Copy link
Contributor

hadilq commented Jun 8, 2020

I did update the kotlinpoet library to use its writeTo(Filer) method. It was supper easy to use this method for CoproductProcessor. However, beside ExtensionProcessor, other processors are not using kotlinpoet at all, such as AutoFoldProcessor, HigherKindsProcessor, OpticsProcessor, ProductProcessor. For those cases, we use writeText or printWriter methods to write in the file, which is not recommended. IMHO we should migrate to generate all kotlin codes by kotlinpoet for every processors. Am I right or do you believe there is a better way?

And finally ExtensionProcessor case! It uses kotlinpoet, but still there is a problem! Filer is a Java API, and in Java we don't allow to use Java keywords in packageNames. But we use const in package names! For instance for generating ConstFunctor we get the following exception

e: [kapt] An exception occurred: javax.annotation.processing.FilerException: Illegal name arrow.core.extensions.const.functor

Do anyone has any solution for it? Is changing packageNames acceptable?!

@raulraja
Copy link
Member

Addressed in arrow-kt/arrow-core#153 thanks @hadilq!

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

4 participants