Reputation: 13581
I'm working on libGDX project and I want to use Lombok. I followed this short tutorial about using lombok in libGDX projects but unfortunately it does not working.
Situation looks like this - IntelliJ is recognizing lombok and does not complaining about get/set methods, but when I want to run project (using gradle) there's java compiler error like
error: cannot find symbol static builder
error: cannot find symbol method setBoardSize(float a, float b)
so basically Lombok is not being recognized.
Usually the advice is to set 'enable annotation processing' in the IntelliJ but I tried without a success - I also tried reinstalling the Lombok plugin, changing Lombok version to 1.18.8, adding to the build.gradle android section
annotationProcessor "org.projectlombok:lombok:1.16.6"
but nothing fixed the issue. I also believe that it is not issue of IntelliJ because when I'm trying to run project from gradle command line using
gradlew desktop:run
it is not working and I have the same stacktrace
Did anyone have the same issue? How to resolve this?
I'm attaching my build.gradle underneath
buildscript {
repositories {
mavenLocal()
mavenCentral()
maven { url "https://plugins.gradle.org/m2/" }
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
jcenter()
google()
}
dependencies {
classpath 'org.wisepersist:gwt-gradle-plugin:1.0.6'
classpath 'com.android.tools.build:gradle:3.1.0'
}
}
allprojects {
apply plugin: "eclipse"
apply plugin: "idea"
version = '1.0'
ext {
appName = "light-game"
gdxVersion = '1.9.8'
roboVMVersion = '2.3.3'
box2DLightsVersion = '1.4'
ashleyVersion = '1.7.0'
aiVersion = '1.8.0'
}
repositories {
mavenLocal()
mavenCentral()
google()
jcenter()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
maven { url "https://oss.sonatype.org/content/repositories/releases/" }
}
}
project(":desktop") {
apply plugin: "java"
apply plugin: "war"
dependencies {
compile project(":core")
compile "com.badlogicgames.gdx:gdx-backend-lwjgl:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
compile "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-desktop"
providedCompile "org.projectlombok:lombok:1.16.6"
}
}
project(":android") {
apply plugin: "android"
configurations { natives }
dependencies {
compile project(":core")
compile "com.badlogicgames.gdx:gdx-backend-android:$gdxVersion"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi-v7a"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-arm64-v8a"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86_64"
compile "com.badlogicgames.gdx:gdx-box2d:$gdxVersion"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-armeabi"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-armeabi-v7a"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-arm64-v8a"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-x86"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-x86_64"
compile "com.badlogicgames.box2dlights:box2dlights:$box2DLightsVersion"
provided "org.projectlombok:lombok:1.16.6"
}
}
project(":core") {
apply plugin: "java"
apply plugin: "war"
dependencies {
compile "com.badlogicgames.gdx:gdx:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-box2d:$gdxVersion"
compile "com.badlogicgames.box2dlights:box2dlights:$box2DLightsVersion"
providedCompile "org.projectlombok:lombok:1.16.6"
}
}
project(":html") {
apply plugin: "gwt"
apply plugin: "war"
dependencies {
compile project(":core")
compile "com.badlogicgames.gdx:gdx-backend-gwt:$gdxVersion"
compile "com.badlogicgames.gdx:gdx:$gdxVersion:sources"
compile "com.badlogicgames.gdx:gdx-backend-gwt:$gdxVersion:sources"
compile "com.badlogicgames.gdx:gdx-box2d:$gdxVersion:sources"
compile "com.badlogicgames.gdx:gdx-box2d-gwt:$gdxVersion:sources"
compile "com.badlogicgames.box2dlights:box2dlights:$box2DLightsVersion:sources"
}
}
tasks.eclipse.doLast {
delete ".project"
}
Upvotes: 1
Views: 757
Reputation: 13581
Ugh - so finally I found the issue and it was quite surprising. It turned out that my configuration was fine, IntelliJ was fine but Lombok itself has an issue I was not aware about - this issue is static import of builder() method, which completely messes up the bytecode of compiled classes and causes issues like mine
Basically all I had to do was to remove such imports as
import static com.antkowicz.project.MyClass.builder;
public MyClass getMyClass() {
return builder().build();
}
and instead of this use
import static com.antkowicz.project.MyClass;
public MyClass getMyClass() {
return MyClass.builder().build();
}
Seems that this issue is well known but not going to be resolved soon (or ever) and it's nothing trivial - so basically the only thing we can do is to ommit static imports with Lombok (at least builder()) :)
A few links beneath about this topic:
Upvotes: 0