rules_kotlin icon indicating copy to clipboard operation
rules_kotlin copied to clipboard

META-INF files generated by KSP processor are missing from output

Open oliviernotteghem opened this issue 1 year ago • 4 comments

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:

  1. Clone this branch : https://github.com/bazelbuild/rules_kotlin/compare/master...oliviernotteghem:rules_kotlin:inner
  2. Change dir to: examples/ksp
  3. 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]

oliviernotteghem avatar Jul 21 '23 16:07 oliviernotteghem

Hi!

Another files that are missing are for example proguard rules from moshi.

Can be reproduce on current master:

  1. Change dir to: examples/ksp
  2. 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

zalewskise avatar Jul 30 '23 19:07 zalewskise

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.

Screenshot 2023-07-31 at 10 51 15 AM

jbarr21 avatar Jul 31 '23 17:07 jbarr21

i think I am facing a similar issue here: https://github.com/komapper/komapper/issues/1105#issuecomment-1772644697

jvgelder avatar Oct 20 '23 12:10 jvgelder

https://github.com/bazelbuild/rules_kotlin/pull/997 looking to fix this.

restingbull avatar Oct 20 '23 17:10 restingbull