libgdx / gdx-liftoff

A modern setup tool for libGDX Gradle projects
Apache License 2.0
525 stars 48 forks source link

Bundle Release for Android with Lombok #132

Closed JojoIce closed 11 months ago

JojoIce commented 11 months ago

Using 1.12.0.3 Java 17.0.6 Zulu MacOS

Building an Android project and selecting lombok in the "third-party" selection and then attempting gradle :android:bundleRelease Leads to:

Task :android:minifyReleaseWithR8 FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':android:minifyReleaseWithR8'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.R8Task$R8Runnable
   > Compilation failed to complete

Before that there are a lot of this:

WARNING: /path/android/build/intermediates/merged_java_res/release/base.jar: R8: Unexpected reference to missing service class: META-INF/services/javax.annotation.processing.Processor.
WARNING: /path/android/build/intermediates/merged_java_res/release/base.jar: R8: Unexpected reference to missing service class: META-INF/services/lombok.core.LombokApp.
WARNING: /path/android/build/intermediates/merged_java_res/release/base.jar: R8: Unexpected reference to missing service implementation class in META-INF/services/lombok.core.LombokApp: lombok.bytecode.PoolConstantsApp.
WARNING: /path/android/build/intermediates/merged_java_res/release/base.jar: R8: Unexpected reference to missing service implementation class in META-INF/services/lombok.core.LombokApp: lombok.bytecode.PostCompilerApp.
WARNING: /path/android/build/intermediates/merged_java_res/release/base.jar: R8: Unexpected reference to missing service implementation class in META-INF/services/lombok.core.LombokApp: lombok.core.Main$LicenseApp.

LOTS more of that then

WARNING: /path/android/build/intermediates/merged_java_res/release/base.jar: R8: Unexpected reference to missing service implementation class in META-INF/services/lombok.javac.handlers.JavacSingularsRecipes$JavacSingularizer: lombok.javac.handlers.singulars.JavacJavaUtilSetSingularizer.
ERROR: Missing classes detected while running R8. Please add the missing classes or apply additional keep rules that are generated in /path/android/build/outputs/mapping/release/missing_rules.txt.
ERROR: R8: Missing class javax.annotation.processing.AbstractProcessor (referenced from: javax.annotation.processing.AbstractProcessor lombok.launch.AnnotationProcessorHider$AnnotationProcessor.instance and 5 other contexts)
Missing class javax.annotation.processing.SupportedAnnotationTypes (referenced from: lombok.launch.AnnotationProcessorHider$ClaimingProcessor)
Missing class lombok.bytecode.PoolConstantsApp (referenced from: java.util.List kotlinx.coroutines.internal.FastServiceLoader.load(java.lang.Class, java.lang.ClassLoader))
Missing class lombok.bytecode.PostCompilerApp (referenced from: java.util.List kotlinx.coroutines.internal.FastServiceLoader.load(java.lang.Class, java.lang.ClassLoader))

LOTS more of lombok.* missing classes

It works fine for iOS and desktop.

In the core/build.grade it looks something like:

[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
eclipse.project.name = appName + '-core'

dependencies {
  api "com.badlogicgames.gdx:gdx:$gdxVersion"
  api "org.projectlombok:lombok:$lombokVersion"
  annotationProcessor "org.projectlombok:lombok:$lombokVersion"
}

Changing the "api" for lombok to compileOnly seems to fix the problem!

So it looks like the build.grade should be:

[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
eclipse.project.name = appName + '-core'

dependencies {
  api "com.badlogicgames.gdx:gdx:$gdxVersion"
  compileOnly "org.projectlombok:lombok:$lombokVersion"
  annotationProcessor "org.projectlombok:lombok:$lombokVersion"
}

I have read and forgotten something about the importance of api vs compileOnly. Never seems to matter until now...

Maybe some more validation should be made, but at least that small change allowed me to build the android packages again. Some fairly recent change elsewhere in liftoff must have triggered this. New Gradle version or similar?

tommyettinger commented 11 months ago

There has been a new version of Gradle for a little while now, and we're on 8.3, so maybe something broke there. I'll try and switch the lombok dependencies to use compileOnly, thanks!