Expected Behavior
When running ktlintFormat (or any ktlint task) on a module that contains no .kt or .kts source files, ktlint should gracefully skip the module with no errors. Empty modules (e.g., newly scaffolded feature modules with only a build.gradle.kts) are common in large modular Android projects and should not cause build failures.
Observed Behavior
Running ktlintFormat on an empty module (no Kotlin source files) causes the loadKtlintReporters task to fail with a NoClassDefFoundError:
* What went wrong:
Execution failed for task ':features:myModule:loadKtlintReporters'.
> A failure occurred while executing org.jlleitschuh.gradle.ktlint.worker.LoadReportersWorkAction
> com/pinterest/ktlint/cli/reporter/core/api/ReporterProviderV2
This failure is intermittent — it does not happen on every run, but it regularly breaks CI builds.
Steps to Reproduce
- Create a multi-module Android/Kotlin project with the
org.jlleitschuh.gradle.ktlint plugin applied via a convention plugin to all modules.
- Add an empty module (e.g.,
features/my-module/) that has a build.gradle.kts but contains no .kt or .kts source files.
- Run
./gradlew ktlintFormat (or ktlintCheck).
- Observe that
loadKtlintReporters fails on the empty module. The failure is intermittent and more easily reproduced in CI environments.
Your Environment
- Version of ktlint used: 1.7.1
- Relevant parts of the
.editorconfig settings:
[*.{kt,kts}]
max_line_length=120
indent_size=4
ktlint_code_style=android_studio
ij_kotlin_allow_trailing_comma=true
ij_kotlin_allow_trailing_comma_on_call_site=true
- Name and version of integration used:
org.jlleitschuh.gradle:ktlint-gradle:14.0.1 (applied via Gradle convention plugin)
- Version of Gradle used: 9.2.1
- Operating System and version: macOS (CI also runs on Linux)
Expected Behavior
When running
ktlintFormat(or any ktlint task) on a module that contains no.ktor.ktssource files, ktlint should gracefully skip the module with no errors. Empty modules (e.g., newly scaffolded feature modules with only abuild.gradle.kts) are common in large modular Android projects and should not cause build failures.Observed Behavior
Running
ktlintFormaton an empty module (no Kotlin source files) causes theloadKtlintReporterstask to fail with aNoClassDefFoundError:This failure is intermittent — it does not happen on every run, but it regularly breaks CI builds.
Steps to Reproduce
org.jlleitschuh.gradle.ktlintplugin applied via a convention plugin to all modules.features/my-module/) that has abuild.gradle.ktsbut contains no.ktor.ktssource files../gradlew ktlintFormat(orktlintCheck).loadKtlintReportersfails on the empty module. The failure is intermittent and more easily reproduced in CI environments.Your Environment
.editorconfigsettings:org.jlleitschuh.gradle:ktlint-gradle:14.0.1(applied via Gradle convention plugin)