Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KSP compiler warning when using multi preview annotations #322

Closed
JeremiahStephenson opened this issue May 5, 2023 · 7 comments
Closed

Comments

@JeremiahStephenson
Copy link

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.

@vinaygaba
Copy link
Collaborator

@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?

@matejdro
Copy link

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.

@ln-12
Copy link

ln-12 commented Sep 4, 2023

@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.

@jmartinesp
Copy link
Contributor

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.

@joshdmiller5
Copy link

@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

@matejdro
Copy link

No luck yet, but the warning does not seem to affect anything. Our jobs do not fail because of it.

@vinaygaba
Copy link
Collaborator

This has been fixed with the following change - #383

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants