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

Applying plugin to subprojects doesn't work #826

Open
ydavygora opened this issue Jan 17, 2025 · 1 comment
Open

Applying plugin to subprojects doesn't work #826

ydavygora opened this issue Jan 17, 2025 · 1 comment

Comments

@ydavygora
Copy link

ydavygora commented Jan 17, 2025

Hello,

I'm running into an issue with a multiproject setup (using Gradle 8.12). My top level build.gradle.kts is minimal:

plugins {
    id("org.jlleitschuh.gradle.ktlint") version ("12.1.2")
}

allprojects {
    repositories {
        mavenCentral()
    }
}

subprojects {
    // apply(plugin = "org.jlleitschuh.gradle.ktlint")
}

ktlint {
    version = "1.5.0"
}

If I leave the line commented, then the code in the subprojects does not get formatted/checked. If I uncomment the line, here's the error I get:

./gradlew clean ktlintFormat

FAILURE: Build failed with an exception.

* What went wrong:
org/jetbrains/kotlin/gradle/dsl/KotlinProjectExtension
> org.jetbrains.kotlin.gradle.dsl.KotlinProjectExtension

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.

If I run this with stacktrace, the first three lines are:

* Exception is:
java.lang.NoClassDefFoundError: org/jetbrains/kotlin/gradle/dsl/KotlinProjectExtension
        at org.jlleitschuh.gradle.ktlint.KtlintPlugin$applyKtLint$1.invoke(KtlintPlugin.kt:81)
        at org.jlleitschuh.gradle.ktlint.KtlintPlugin$applyKtLint$1.invoke(KtlintPlugin.kt:19)
        at org.jlleitschuh.gradle.ktlint.KtlintPlugin$sam$org_gradle_api_Action$0.execute(KtlintPlugin.kt)
...

To be honest, I am not sure if I am doing anything wrong or if there is a bug in the plugin. In any case I would be really grateful for your assistance. If you need more input from me (more logs, a minimal working or, rather, failling example), please let me know and thank you very much in advance!

@ydavygora
Copy link
Author

Minimal example: https://github.com/ydavygora/ktlint_example

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

1 participant