javalin-openapi icon indicating copy to clipboard operation
javalin-openapi copied to clipboard

Make `OpenApiAnnotationProcessor` support incremental Gradle builds

Open Petersoj opened this issue 11 months ago • 6 comments

I'm getting a warning in the Gradle output of my build:

Full recompilation is required because io.javalin.openapi.processor.OpenApiAnnotationProcessor is not incremental.

Not high priority, but would be nice to have incremental build support for the annotation processor. Would especially help if there are a large number of OpenApi annotations. Would also be nice to have an option to disable pretty printing for smaller OpenApi spec files (relevant code).

Petersoj avatar Dec 30 '24 01:12 Petersoj

I agree that it'd be great, but I can already say that it'll most likely require a lot of work or might not even be possible for our use-case. I didn't look into details, so I may be wrong, but on paper I can imagine that such incremental compilation is relatively easy to implement for plugins that generate some sort of new sources - unfortunately in our case, we're gathering a whole context to build one, final json file.

dzikoysk avatar Jan 01 '25 14:01 dzikoysk

@dzikoysk yeah makes sense that incremental builds would be tough to implement in this case. Thoughts on turning off pretty printing in the final JSON spec file? Pretty printing increases disk usage and serialization time, and most editors can auto-format the JSON file if a user wants to debug the spec file.

Petersoj avatar Jan 02 '25 19:01 Petersoj

Yeah sure, we can make it configurable :) But I'd still keep this as a default option, because it's more user-friendly ootb + it's our current behavior.

dzikoysk avatar Jan 02 '25 20:01 dzikoysk

@Petersoj There's a new withPrettyOutput(enabled = false) config option that uses standard Jackson's toString() output. It'll be a part of the next release, but you can already give it a try by using 6.4.1-SNAPSHOT.

dzikoysk avatar Jan 16 '25 23:01 dzikoysk

@dzikoysk awesome!

Petersoj avatar Jan 18 '25 18:01 Petersoj

Researched incremental support a bit more and, if I'm not mistaken, it does seem like this annotation processor can be configured to be incremental by declaring it as an aggregating processor and removing the usage of com.sun.source.util.Trees. From the docs:

These can aggregate several source files into one or more output files or validation messages.

Gradle will always reprocess (but not recompile) all annotated files that the processor was registered for. Gradle will always recompile any files the processor generates.

Petersoj avatar Jan 19 '25 04:01 Petersoj