airbnb / Showkase

🔦 Showkase is an annotation-processor based Android library that helps you organize, discover, search and visualize Jetpack Compose UI elements
https://medium.com/airbnb-engineering/introducing-showkase-a-library-to-organize-discover-and-visualize-your-jetpack-compose-elements-d5c34ef01095
Apache License 2.0
2.11k stars 107 forks source link

Multi module: same package name leads to silently ignoring previews #361

Open Syex opened 11 months ago

Syex commented 11 months ago

Hi 👋

I have two Gradle modules A and B, both with some @Preview and both have the same package name - let's say com.example.ui.

In my case, both are library projects with no further root, so I added a new module referencing both, A and B, and added a @ShowkaseRoot to this module, but this is only a side note to understand how I came here.

I'm using this module to record Paparazzi screenshot tests for both modules and after capturing the screenshots I end up with either all screenshotted previews from A OR B, depending on which dependency I declared first in the module's Gradle file.

Looking at the ksp generated Showkase files I observed the following:

In module A it generated a file with content:

package com.airbnb.android.showkase

import com.airbnb.android.showkase.`annotation`.ShowkaseCodegenMetadata
import kotlin.Unit

public class ShowkaseMetadata_com_example_ui {
  // not relevant content
}

and in module B it generated the absolutely equal content (which makes sense obviously).

I assume because of same package and class name Showkase fails internally somewhere at processing the file from the respective other module.

I could fix it by renaming the modules to something unique, e.g. for module A to com.example.ui.a.

However, it would be great if Showkase at least threw some error in such a case.