projectlombok / lombok

Very spicy additions to the Java programming language.
https://projectlombok.org/
Other
12.92k stars 2.4k forks source link

support Android Databinding Library #894

Open boxcounter opened 9 years ago

boxcounter commented 9 years ago

The Databinding library cannot find getter generated by lombok.

Imported like this:

dependencies {

    ......
    provided 'org.projectlombok:lombok:1.16.4'
}

Thanks.

bowmanb commented 9 years ago

Same issue here. Also using Dagger and EventBus to make things more interesting.

Full build.gradles: https://gist.github.com/bowmanb/7dcbb5de6609bfbca128

carlonzo commented 9 years ago

please, how can we fix this?

Ks89 commented 9 years ago

I confirm the problem with Android data binding.

domsu commented 9 years ago

Bump!

ScottPierce commented 9 years ago

:+1: I'm encountering the same thing.

rspilker commented 9 years ago

I know there are some problems if multiple annotation processors are involved. One way to handle those if to first run delombok on the whole codebase and feed the resulting files to the rest of the compilation process.

In a build.gradle file I wrote I used the following setup:

configurations {
    provided
    compileOnly.extendsFrom provided
    testCompile.extendsFrom compileOnly
}

dependencies {
    // other stuff
    compileOnly 'org.projectlombok:lombok:1.14.8'
}

task sourcesJar(type: Jar, dependsOn: classes) {
    classifier = 'sources'
    from sourceSets.main.allSource
}

sourceSets.main.compileClasspath += configurations.compileOnly

task myJavadoc(type: Javadoc) {
    source = sourceSets.main.allJava
    classpath = sourceSets.main.compileClasspath
    options.author = true
    options.links(project.ext.javadocLinks)
}

task javadocJar(type: Jar, dependsOn: myJavadoc) {
    classifier = 'javadoc'
    from javadoc.destinationDir
}

I hope this helps

skhaz commented 8 years ago

@rspilker can you provide a working example? I tried your example above

carlonzo commented 8 years ago

up! @rspilker that code does not work for me. do you have a working example? thanks!

jaboko commented 8 years ago

up? I also encountered this problem, the whole brain is already broken!

JeonGyungMin commented 8 years ago

I have same issue...

Shujito commented 8 years ago

I'm interested on this

vekexasia commented 8 years ago

Hey @rspilker can you please help us all ? :+1:

appcoders commented 8 years ago

How to delombok with gradle 2.2? Thanks @rspilker!

soldmachine commented 8 years ago

Any update on this issue? Did anyone maybe find a workaround for this issue?

Shujito commented 8 years ago

@soldmachine: I can think of four workarounds:

  1. Not using lombok with databinding
  2. Not using databinding with lombok
  3. Use public fields
  4. Extend your class with annotations, then override the getters you want to use on the layout with databinding. This has worked nicely for me, the only issue with extending classes is that you'll have dupe code.

Hope this helps

soldmachine commented 8 years ago

@Shujito: THX for your suggestions!

I opted for option 3!

Modulo216 commented 7 years ago

Looks like this is still an issue. Any solid work arounds besides public fields?

ScottPierce commented 7 years ago

I found that lombok actually caused a memory leak with Android instant run, inflating my build times dramatically over the course of an hour. Due to that and other issues like this one, I've stopped using lombok, and found myself with a much more pleasant Android development experience.

shidaping commented 2 years ago

change implementation 'org.projectlombok:lombok:1.18.12' to compileOnly 'org.projectlombok:lombok:1.18.12' annotationProcessor 'org.projectlombok:lombok:1.18.12' in your build.gradle

cylonid commented 2 years ago

In 2022, convert your Java class to a Kotlin data class, getters/setters are accessible by design and the conversion can be done (mostly) automatically by Android Studio for a simple POJO. You don't need to fully switch to Kotlin, mixed builds are possible.