-
Notifications
You must be signed in to change notification settings - Fork 51
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
Please add a sample for how to apply kotlinter on a multi module Android project #256
Comments
That is correct, a task exists for each SourceSet, so you need to customize them as shown here https://github.com/jeremymailen/kotlinter-gradle#customizing-tasks As with all things gradle you can programmatically iterate through tasks of that type and apply the customization. |
Thanks @jeremymailen. You mean like I can iterate through the respective allprojects {
apply(plugin = "org.jmailen.kotlinter")
repositories {
google()
mavenCentral()
}
kotlinter {
ignoreFailures = false
reporters = arrayOf("html")
experimentalRules = true
disabledRules = emptyArray()
}
tasks.withType<LintTask>().configureEach {
exclude("**/generated/**", "**/build/**")
}
} |
That's what I was thinking. Do note when you are excluding file paths above the package root, you need to use a slight different incantation to exclude the path. Two styles: |
@jeremymailen I was struggling with finding the right syntax for excluding generated files. Maybe one of the solutions in the comments that you mentioned could be added to the documentation? tasks.withType<LintTask>().configureEach {
exclude { it.file.path.contains("/build/generated/") }
} Thank you very much for this great Gradle plugin 👍🏼 |
I agree, we should document a simple example like that to help people so they don't need to go digging. |
I spent a few hours today figuring out how to set up the pre push hook task to a multi module project. A sample project would've been mightily helpful. |
+1 on this. It doesn't make any sense to apply the plugin to the root project of a multi-module/Android build configuration but even when I tried, it still didn't work. In order to add this to the root project (as described in the README):
you'd need to apply the |
Can you guide me how to use git hook in android project, I added it under the app/build.gradle.kts, but when I run the project or build, no file are generated under .git/hooks, thank you very much if you can help |
I recommend using the git hooks that come with ktlint actually since a command line invocation makes a lot more sense in a git workflow. Likely hooks will be phased out of the next major release of this plugin. Beyond that, if you want some kind of setup task in your root gradle file to install a hook and you don't otherwise have kotlin code there, I would recommend just making a custom task rather than relying on the suggestion to tie it to |
Did anyone figure this out? The above |
Hello,
Thanks for the up-to-date
ktlint
plugin. This is what I am looking for nowadays. I set up the plugin well but still didn't understand how to exclude some packages in a multi module project. It was enough with ktlint-gradle to exclude project-wide packages within the plugin block itself like belowbut for this one, from what I understand from the doc, I need to configure the task(
lintKotlinMain
,formatKotlinMain
) created by the plugin in each module or is there a better and centralized way of doing so? Thank you!The text was updated successfully, but these errors were encountered: