Hot deploy with Lombok

Hi

Hot deploy is not functionning with no error message.

Studio 13.0-191
IDEA 2019.3.3

I think this is related to lombok, as soon as I put the 3 lines in build.gradle below hot deploy is not triggering anymore.

Sample project attached.

configure([globalModule, coreModule, webModule]) {
    apply(plugin: 'java')
    apply(plugin: 'maven')
    apply(plugin: 'cuba')

    dependencies {
            testCompile('org.junit.jupiter:junit-jupiter-api:5.5.2')
            testCompile('org.junit.jupiter:junit-jupiter-engine:5.5.2')
            testCompile('org.junit.vintage:junit-vintage-engine:5.5.2')
        >  testCompile 'org.projectlombok:lombok:1.18.12'
        >  compile 'org.projectlombok:lombok:1.18.12'
        >  annotationProcessor 'org.projectlombok:lombok:1.18.12'
    }
[...]

Regards
Michael

testcuba72.zip (72.8 KB)

Hi! You are right! Unfortunatelly, we do not support hot deploy with lombok. By the way, we support Kotlin. You do not need to use Lombok, if you have Kotlin.

1 Like

Hi @AlexBudarov

We have years of code produced with Lombok !

Before Cuba 7.2 hot deployment of lomboked classes was not working (on-the-fly compilation error), but all others classes would, especially when modifying an xml descriptor, which was ok.

Now with 7.2, even modifying an xml descriptor does not trigger hot deployment.

And technically, if Lombok does not work, I guess AutoValue or Immutable neither, or any annotation library that modify java code, right ?

Michael

So sad. Lombok code is not valid Java code and when you use it you are in danger.

@jreznot Can you elaborate a litte bit on that what you mean in detail?

The problem of Lombok can be described in 3 sentences:

  1. You cannot compile your code without Lombok annotations processor with only Java compiler, because you use things that do not exist in Java code, e.g. generated constructors.
  2. IDEs cannot correctly work with “invisible” Java methods, constructors and interfaces produced by Lombok. Third-party plugin always required and often makes developer experience worse.
  3. When Java byte code version and language is updated Lombok gets broken and this is an additional dependency in your project that might not update as fast as upstream language.

So generally, I’m avoiding Lombok in my projects. There are many good alternative solutions that do not try to hack/patch existing things: languages (Groovy/Kotlin) or normal annotation processors that do not create invisible declarations, or complete code generation (Jooq, JavaPoet) that produces normal Java code.

See also https://medium.com/@vgonzalo/dont-use-lombok-672418daa819

From methodology perspective I think that developers focus on wrong problems when they decide to use Lombok.

1 Like

You can uncheck Hot deploy compiled classes option in CUBA -> Settings, to use old hot deploy behavior.

Hi,
I’ve checked sample project and it looks like you can enable hot deploy with new mechanism.
Open CUBA -> Settings -> Hot deploy settings.

You will see this, because Studio auto-determines generated sources instead of main source root:
image

Settings need to be changed:
image

Then basic hot deploy features will become available.

1 Like

Thanks @AlexBudarov, this will help during the time we delombok the project. Good news is that we used it essentially for getter/setters/value classes, but it will take time anyway, and I’m not fixed yet on an alternative.

Michael

Hi,

@michael.renaud just FYI in case you are not aware: Lombok has a mechanism to basically remove the lombok annotations via a dedicated cmd line command: https://projectlombok.org/features/delombok

Cheers
Mario

Hi @mario

Yes i’m aware of that but the code produced can be ugly so for some important classes we will apply immediately after the alternative solution I need to decide on. Codebase is big.

Michael