I have a code-base that heavily uses Lombok, but I wish to incrementally migrate some of it using Immutables (Mostly for Staged Builder and Precheck). I use Gradle and I ran into problems as I used Immutables through kapt (kapt("org.immutables:value:2.8.2")), along with Lombok gradle plugin(id("io.freefair.lombok") version "6.0.0-m2"). Is there a way for both Immutables and Lombok can co-exist?
They should coexist in theory, just different annotation processors (well, Lombok is also doing "compiler plugin" things by manipulating AST, but it launches as an annotation processor). Maybe it's a plugin thing, some users reported they've used Immutables and Lombok in a Java codebase built with Maven. Are you using kotlin/kotlin tooling (kapt) in Gradle, is there a way to use Java plugins?
I have a mix of Kotlin and Java. Immutables works perfectly with kapt (although I had to recompile the class with Immutable annotations every time, I make a change). But with both lombok-gradle-plugin and kapt, kapt is taking over and nothing related to lombok is being executed.
I created a Sample project. It has a test called ImmutablesTest.java, which fails to recognize Lombok annotations.
I tried to make delombok task depends on sources generated by kapt, but it didn't work out. Can you please take a look and help me with what is missing? Thanks.
I see. I might look at it if I have some extra time, but cannot promise that. What ideally should be possible — might be just a limitation of kapt, for example. In a meanwhile, another tip comes to mind: is it possible to use lombok launching it as an annotation processor, i.e. ditching plugin and use smth like kapt("lombok...jar"). It's possible other people might have Lombok/kapt issues, unrelated to Immutables, so searching internet for these might pop something up.
Thanks @elucash. I did try that as well having lombok as annotation processor, but somehow I could not get the sequencing of Immutables and Lombok right.
Thanks for Immutables. It's a great no-magic alternative for Lombok and once we figure out an incremental way to migrate, I plan to write a blog post as it might be useful to many who wish to migrate.
Most helpful comment
Thanks @elucash. I did try that as well having lombok as annotation processor, but somehow I could not get the sequencing of Immutables and Lombok right.
Thanks for Immutables. It's a great no-magic alternative for Lombok and once we figure out an incremental way to migrate, I plan to write a blog post as it might be useful to many who wish to migrate.