litho icon indicating copy to clipboard operation
litho copied to clipboard

Add @Generated annotation to generated files

Open vinc3m1 opened this issue 6 years ago • 4 comments

Probably needs some build.grade/BUCK file fixes.

Fixes #551

vinc3m1 avatar Jun 05 '19 21:06 vinc3m1

Thanks a lot for your work on this, @vinc3m1! I was hopoing to add that in the future) Let me share a couple of thoughts about the topic below.

We'd like to remove that mandatory dependency on Generated annotation. Can you refactor this to use string-literal for classname and remove that dep? (Similar to how Moshi is doing: https://github.com/square/moshi/blob/0943ef5a6165c2c2796eb0dafd2246e58982cc0b/kotlin/codegen/src/main/java/com/squareup/moshi/kotlin/codegen/JsonClassCodegenProcessor.kt#L59). So, that by default we won't add this annotation and use that dep, but if our consumers will need it, they can add it along with litho.

And let the trigger for this annotation to be added be a CLI parameter. But we don't need to support JDK9 annotation, just the flag whether to add it or not.

colriot avatar Jun 18 '19 11:06 colriot

Changed to use a string literal, this drops the dep from the annotation process, but the original CL never quite required the dep on underlying dependencies either (at least with gradle, since they were compileOnly).

The trigger is currently based on whether the processing environment actually has the class on the classpath, which means the consumer has the dependency already, otherwise the annotation will not be added.

vinc3m1 avatar Jun 18 '19 15:06 vinc3m1

bump

vinc3m1 avatar Jul 02 '19 00:07 vinc3m1

@vinc3m1 has updated the pull request. Re-import the pull request

facebook-github-bot avatar Jul 13 '20 22:07 facebook-github-bot