question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Looking for some advice on report customization with multiple lint tasks

See original GitHub issue

Use case: I have four source sets that lintKotlin lints: main, debug, androidTest, and test. Running that task results in the production of four reports. I would like to collate those four reports into one. (not to mention I have four modules in my project, and each has four source sets, … you see the problem.)

In fact, I have a proof of concept that works, but I’ve run into a problem – the lintKotlin task is fail-fast. If any of the sub-tasks fails, the aggregate task fails and my custom Gradle task never runs. I tried using finalizedBy, but conceptually it should be lintKotlin.finalizedBy customTask, and that just doesn’t work if a sub-task fails (correct me if I’m wrong).

So, I’m hoping you might have some advice on what’s a good hook for running my task, which should run regardless of whether lintKotlin succeeds. If this succeeds, I’d like to turn it into a plugin, perhaps.

Thanks!

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:12 (12 by maintainers)

github_iconTop GitHub Comments

1reaction
autonomousappscommented, Jul 16, 2018

Yeah, that totally works! Thanks!

I’m not sure if it’s worth publishing the jar as a standalone artifact. The use-case is simply letting me push more of my build logic into buildSrc, which has various advantages (but also disadvantages, as this shows). Maybe I’m the only guy using your plugin that cares about this 😃

1reaction
jeremymailencommented, Apr 4, 2018

That’s great! FYI you don’t need to specify the kotlinter extension block. That configuration only applies to the automatically created tasks and you are using the default values anyway.

If you need to specify those configurations on your custom task, the properties have the same names, eg:

import org.jmailen.gradle.kotlinter.tasks.LintTask
task ktLint(type: LintTask, group: 'verification') {
    source files("app/src", "net/src", "logging/src", "utils/src")
    indentSize = 8  // just an example of a non-default config
    continuationIndentSize = 8  // just an example
    reports = [
            'plain': file("$buildDir/reports/ktlint/all-lint.txt"),
            'html': file("$buildDir/reports/ktlint/all-lint.html")
    ]
}

but again no need to do that since you’re using the default indent values.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Improve your code with lint checks - Android Developers
All lint methods that override the given severity level of an issue— enable , disable / ignore , informational , warning , error...
Read more >
[Lint] Some questions about writing custom lint rules
What is your recommendation for passing configuration into custom lint rules? - Lint tries to load rules from every jar file in the...
Read more >
Android User Guide - Google Samples
Lint checks now include information for reported incidents where the lint check came from, such as which library artifact provided it. This should...
Read more >
Pressing "Make Project" does not prepare custom Lint checks ...
Specifically, pressing "Make Project" will build the custom Lint check modules, but it will not "prepare" those Lint checks for use in the...
Read more >
Gradle build: Execution failed for task ':app:lint' - Stack Overflow
you can disable the block but it is not the best practice. You should analyze the lint report to solve each point. Share....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found