Showkase
Showkase copied to clipboard
KSP compiler warning when using multi preview annotations
When using ksp combined with multi preview annotations I am seeing a compiler warning like this:
w: [ksp] No dependencies are reported for ShowkaseMetadata_showkase_ which will prevent incremental compilation.
The custom annotation looks like this:
@Preview(
name = PreviewConfig.PreviewDefaultSuffix,
device = PreviewConfig.DefaultDevice,
locale = PreviewConfig.DefaultLocale,
uiMode = Configuration.UI_MODE_NIGHT_NO,
)
@Preview(
name = PreviewConfig.PreviewDarkSuffix,
group = PreviewConfig.PreviewNoSnapshotGroup,
device = PreviewConfig.DefaultDevice,
locale = PreviewConfig.DefaultLocale,
uiMode = Configuration.UI_MODE_NIGHT_YES,
)
@Preview(
name = PreviewConfig.PreviewScaledSuffix,
group = PreviewConfig.PreviewNoSnapshotGroup,
device = PreviewConfig.DefaultDevice,
locale = PreviewConfig.DefaultLocale,
uiMode = Configuration.UI_MODE_NIGHT_NO,
fontScale = PreviewConfig.DefaultUpscale,
)
annotation class DefaultPreviews
What I think is happening is that KSP is picking up on the @Preview annotation over the custom annotation (like it would normally do for a compose preview) and generates a file based on it. But then something checks it later and realizes something is wrong since the generated code isn't tied to an actual preview.
@JeremiahStephenson Is this only happening in the multi preview context? i.e can you confirm you aren't seeing this when you are not using multi-preview?
I'm also experiencing something similar, but it is not related to the root module, not multiple annotations:
No dependencies are reported for MyRootModuleCodegen which will prevent incremental compilation.
@vinaygaba I can confirm that this happens with custom annotation classes. My annotations look like this:
import androidx.compose.ui.tooling.preview.Preview
@Preview(widthDp = 411, heightDp = 842)
annotation class PortraitPreview
@Preview(widthDp = 842, heightDp = 411)
annotation class LandscapePreview
@PortraitPreview
@LandscapePreview
annotation class OrientedPreviews
When I use @OrientedPreviews
(or @PortraitPreview
and @LandscapePreview
respectively) on my previews, the warning already shown above will be printed out:
> Task :cmx:kspDebugKotlin
w: [ksp] No dependencies are reported for ShowkaseMetadata_showkase_some_path_previews_portraitpreview which will prevent
incremental compilation.
Please file a bug at https://issuetracker.google.com/issues/new?component=413107.
w: [ksp] No dependencies are reported for ShowkaseMetadata_showkase_some_path_previews_landscapepreview which will prevent
incremental compilation.
Please file a bug at https://issuetracker.google.com/issues/new?component=413107.
If I replace @PortraitPreview
and @LandscapePreview
with the @Preview(...)
annotations, the warning is not shown.
Yes, the issue seems to come from that generated metadata used to be able to automatically detect multi preview annotations in KSP through different runs in different modules. I modified the code in Showkase to only process annotations provided with multiPreviewType
in KSP too, removing the intermediate step of generating ShowkaseMultiPreviewCodegenMetadata
and this issue is gone and the custom annotations are working just fine, tested against our real project.
You can see my changes here, in case they help.
@matejdro Did you have any luck resolving this issue coming from the RootModuleCodegen? Currently experiencing the same warning/issue causing our custom Jenkins job to fail
No luck yet, but the warning does not seem to affect anything. Our jobs do not fail because of it.
This has been fixed with the following change - https://github.com/airbnb/Showkase/pull/383