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

Update compileSdk to 34 and fix deprecation warning #335

Closed
rschattauer opened this issue Jun 29, 2023 · 2 comments · Fixed by #339
Closed

Update compileSdk to 34 and fix deprecation warning #335

rschattauer opened this issue Jun 29, 2023 · 2 comments · Fixed by #339

Comments

@rschattauer
Copy link

Hello.

Please bump compileSdk to 34 for your lib and sample.

In my project I have allWarningsAsErrors = true within kotlinOptions { .. }.
The issue is that ksp generates the following
Class.forName("de.hochbahn.hvvswitch.ui.RootModuleCodegen").newInstance()
where newInstance() is deprecated with compileSdk 34 and this fires due to allWarningsAsErrors = true.

As workaround I currently run a script after the gradle ksp task that adds @Suppress("DEPRECATION") to that function:

tasks.withType(KspTask::class.java).configureEach {
        doLast {
            fileTree(buildDir).apply { include("**/*ShowkaseExtension*.kt") }.files.forEach { file ->
                ReplaceRegExp().apply {
                    setMatch("public fun Showkase.getMetadata")
                    setReplace("@Suppress(\"DEPRECATION\") public fun Showkase.getMetadata")
                    setFlags("g")
                    setByLine(true)
                    setFile(file)
                    execute()
                }
            }
        }
    }
@vinaygaba
Copy link
Collaborator

Thanks for flagging. I'll have to investigate what the recommended API is going forward. Should be straightforward to fix it if it only requires using a different API (haven't investigated yet)

@ahinton-league
Copy link

ahinton-league commented Aug 23, 2023

If anyone is interested, here's the work around in groovy:

    tasks.withType(KspTask).configureEach {
        doLast {
            def tree = fileTree(buildDir)
            tree.include("**/*ShowkaseExtension*.kt")
            tree.files.forEach { file ->
                def rep = new ReplaceRegExp()
                rep.setMatch("public fun Showkase.getMetadata")
                rep.setReplace("@Suppress(\"DEPRECATION\") public fun Showkase.getMetadata")
                rep.setFlags("g")
                rep.setByLine(true)
                rep.setFile(file)
                rep.execute()
            }
        }
    }

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

Successfully merging a pull request may close this issue.

3 participants