Hi,
I'm using project lombok to generate getters and setters on my models but Room don't see the getters and setters generated by lombok.
If I manually edit generated implementation class it can use that getters and setters of lombok without problems (I do that saving modified content of the generated file with a text editor while is compiling the apk).
My code is:
build.gradle:
provided 'org.projectlombok:lombok:1.16.18'
apt "android.arch.persistence.room:compiler:1.0.0-alpha8"
compile "android.arch.persistence.room:runtime:1.0.0-alpha8"
Model:
@Entity
@Data
public class Test {
@PrimaryKey
long id;
String description;
}
Dao:
@Dao
public interface TestDao {
@Query("SELECT * FROM Test WHERE id = :id")
Test getTest(long id);
@Insert
void insert(Test test);
@Delete
void delete(Test test);
}
The code generated is:
if (value.description == null) {
stmt.bindNull(1);
} else {
stmt.bindString(1, value.description);
}
instead of:
if (value.getDescripcion() == null) {
stmt.bindNull(1);
} else {
stmt.bindString(1, value.getDescripcion());
}
There is an issue of project lombok too with another example:
https://github.com/rzwitserloot/lombok/issues/1403
Any suggestion?
Thanks
java annotation processors are not allowed to change class structures.
Project lombok uses private APIs to do so and Room has no way of knowing about these changes.
Nothing we can do here.
annotationProcessor MUST be in order.
compile 'org.projectlombok:lombok:1.16.20'
annotationProcessor 'org.projectlombok:lombok:1.16.20'
implementation 'android.arch.persistence.room:runtime:1.0.0'
annotationProcessor 'android.arch.persistence.room:compiler:1.0.0'
annotationProcessor MUST be in order.
compile 'org.projectlombok:lombok:1.16.20'
annotationProcessor 'org.projectlombok:lombok:1.16.20'implementation 'android.arch.persistence.room:runtime:1.0.0'
annotationProcessor 'android.arch.persistence.room:compiler:1.0.0'
This saved my day..........
Thanks
Most helpful comment
annotationProcessor MUST be in order.
compile 'org.projectlombok:lombok:1.16.20'
annotationProcessor 'org.projectlombok:lombok:1.16.20'
implementation 'android.arch.persistence.room:runtime:1.0.0'
annotationProcessor 'android.arch.persistence.room:compiler:1.0.0'