I'm trying my hand at adding ktlint to an android ...
# community-support
c
I'm trying my hand at adding ktlint to an android project I didn't setup. It's multi module and it has modules that has modules contained in it (i'm not sure what that's called) Following ktlint readme https://github.com/jlleitschuh/ktlint-gradle im trying trying to apply ktlint to all subprojects as such
Copy code
subprojects {
    apply(plugin = "org.jlleitschuh.gradle.ktlint") // Version should be inherited from parent
    // Optionally configure plugin
    configure<org.jlleitschuh.gradle.ktlint.KtlintExtension> {
        debug.set(true)
    }
}
but I get an error on one of my "modules that contains other modules"
What went wrong:
Could not read script '/Users/cidle/dev/myapp/analytics/org.jlleitschuh.gradle.ktlint'
my hunch is because my
analytics
"module" doesn't have a build.gradle.kts. instead it contains
base
and
android
which do have build.gradle.kts. How can I address my issue?
v
modules that has modules contained in it (i'm not sure what that's called)
No special name as there is nothing special, just a project with subprojects.
my hunch is because my
analytics
"module" doesn't have a build.gradle.kts. instead it contains
base
and
android
which do have build.gradle.kts
That should not really be relevant, a project is a project, whether it has an explicit build script or not. Especially as you configure it using the highly discouraged bad-practice cross-project configuration (
subprojects { ... }
) and thus also configure that. Without the full error message, especially
--stacktrace
or optimally a build
--scan
URL, it is hard to say what that error could mean, at least for people not knowing that error in particular. If it really is the absence of the build script and you want to continue following the evil road, just add a condition to only apply the plugin if the project has a build script. 🤷‍♂️
p
It seems you are applying a local script, so perhaps the location is wrong. Are you using relative path
../
v
No, it seems like the plugin id is treated like a file name. But without a proper stacktrace as I said it is hard to guess who does that.
👍 1
c
im starting to think it might be due to our usage of buildSrc?
v
Hard to say without the requested information
c
I'm going to debug further tomorrow, but thank you all for the sanity check at least ❤️
👌 1