rules_kotlin
rules_kotlin copied to clipboard
META-INF files generated by KSP processor are missing from output
Issue was found when trying to integrate with auto-service-ksp library. In this case, KSP processor is invoked but META-INF service file is missing from out jar artifact.
REPRO:
- Clone this branch : https://github.com/bazelbuild/rules_kotlin/compare/master...oliviernotteghem:rules_kotlin:inner
- Change dir to:
examples/ksp
- Run command:
bazel build coffee_lib && tar -tf bazel-bin/coffee_lib.jar
EXPECTED:
There should be a file under META-INF/services/
.
ACTUAL: File is missing.
Notes: KSP processor is invoked, since, for example, specifying a bogus value for AutoService() param (in CoffeAppService.java) causes a crash in KSP auto-value processor. Also, the following is observed in logs:
info: [ksp] loaded provider(s): [com.squareup.moshi.kotlin.codegen.ksp.JsonClassSymbolProcessorProvider, dev.zacsweers.autoservice.ksp.AutoServiceSymbolProcessor$Provider]
Hi!
Another files that are missing are for example proguard rules from moshi.
Can be reproduce on current master:
- Change dir to:
examples/ksp
- Run command:
bazel build coffee_lib && tar -tf bazel-bin/coffee_lib.jar
Expected:
There should be META-INF/proguard/moshi-coffee.CoffeeAppModel.pro
file, with content:
-if class coffee.CoffeeAppModel
-keepnames class coffee.CoffeeAppModel
-if class coffee.CoffeeAppModel
-keep class coffee.CoffeeAppModelJsonAdapter {
public <init>(com.squareup.moshi.Moshi);
}
Actual: File is missing
The META-INF/<LIBRARY_PACKAGE>.version
files are stripped in Bazel vs APKs built by Gradle. Android Studio's Layout Inspector tool uses these files to be able to know which version of the AndroidX libraries is present in the APK. They are present in both debug & release versions of the built APK.
i think I am facing a similar issue here: https://github.com/komapper/komapper/issues/1105#issuecomment-1772644697
https://github.com/bazelbuild/rules_kotlin/pull/997 looking to fix this.