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

[BUG] Upgrading to android tools gradle plugin 3.6.0+ breaks lombok #2412

Open
darekxan opened this issue Mar 31, 2020 · 9 comments
Open

[BUG] Upgrading to android tools gradle plugin 3.6.0+ breaks lombok #2412

darekxan opened this issue Mar 31, 2020 · 9 comments

Comments

@darekxan
Copy link

Describe the bug
it appears there are no property assessors generated.

To Reproduce
I've prepared minimal failing build:
https://github.com/darekxan/lomboktest/tree/broken_3.6.1
(sources, build output there)

Expected behavior
This one works, version 3.5.3
https://github.com/darekxan/lomboktest/tree/master
(sources, build output there)

Version info:

  • Lombok version v1.18.12
  • Android Studio 3.6.1 + javac 13.0.1 + kotlin 1.3.71 + kapt3
@CharlyLafon37
Copy link

It's really annoying. We can't update android gradle plugin in any of our projects because of this. @rzwitserloot @rspilker can you look at this bug please ?

@rspilker
Copy link
Collaborator

I don't know which is better, 3.5.3 or 3.6.1. I know that 3.5.3 doesn't fail the build. But there is a warning in the log that lombok is disabled. So probably the code doesn't do what you expect.

In your example, you've annotated TestModel with @Data, but you never call getTest().

@rspilker
Copy link
Collaborator

rspilker commented Jun 25, 2020

My knowledge of Kotlin is limited, but is I look at the IncrementalProcessinEnvironment and the lombok source code at
https://github.com/rzwitserloot/lombok/blob/master/src/core/lombok/core/AnnotationProcessor.java#L86
a possible solution is to not only see if there is a field delegate but also look for processingEnv.

This is only going to work if there is somewhere a com.sun.tools.javac.processing.JavacProcessingEnvironment.

Otherwise we need way more code to make it work with the Kotlin compiler.

rspilker added a commit that referenced this issue Jun 25, 2020
@rspilker
Copy link
Collaborator

Can you see if the edge release fixes this problem?

@AngryGami
Copy link

AngryGami commented Jun 26, 2020

Nope, it didn't help. I didn't manage to get plugin (net.ltgt.apt) to work, though I'm not sure it is strictly required. Without this plugin it still complaints about field access inside builder class e.g. like this:

@Builder
public class MyConfiguration {
    @Builder.Default
    public final Integer mWidth = 352;

    public static class MyConfigurationBuilder {
        private MyConfiguration buildWithOptions() {
            System.out.println("just as an example: " + this.mWidth);
            return null;
        }
    }
}

causing compilation error during build:

error: cannot find symbol
System.out.println("just as an example: " + this.mWidth);

I've first encounter this error in version of lombok 1.18.12 + android gradle plugin 3.6.2 + gradle 6.1.1. I've tried edge release and got same failure.
Version of lombok that works is 1.16.20, even 1.16.22 already doesnt, so change that happened in between these two is causing trouble. Version of android gradle plugin doesn't seem to have any impact on the issue, I've tried with versions 3.5.2, 3.6.2 and 4.0.0 - all works with lombok 1.16.20 and none with 1.16.22+.

@Rawi01
Copy link
Collaborator

Rawi01 commented Jun 29, 2020

@rspilker I managed to remove the warning by adding processingEnv and filer as field in https://github.com/rzwitserloot/lombok/blob/326955cde1e788c0038ab77d2db340666b5f568b/src/core/lombok/javac/apt/LombokProcessor.java#L469-L471
Unfortunately it still fails to compile the example project. A possible reason might be the IncrementalFiler defined in IncrementalProcessor. It seems like it collects a list of classes and skipping this might be a problem.

@Rawi01
Copy link
Collaborator

Rawi01 commented Jul 22, 2020

You can compile your example if you add

project.afterEvaluate {
    def variants = project.android.applicationVariants + project.android.testVariants
    variants.each { var ->
        def task = tasks["compile${var.name.capitalize()}JavaWithJavac"]
        task.doFirst {
            task.options.compilerArgs=[]
        }
    }
}

to your build.gradle. There might be some side effects, I only tried your example project.

@CharlyLafon37
Copy link

Does anyone have a solution for this ? The latest release 1.18.16 does not solve this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants