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.

Gradle: how to run lint automatically with `check`?

See original GitHub issue

I don’t know if this is a bug or just my ignorance regarding Gradle, but I can’t seem to do:

test.dependsOn ktlintCheck

I get this message:

A problem occurred evaluating root project 'lintsetup'.
  > Could not get unknown property 'ktlintCheck' for root project 'lintsetup' of type org.gradle.api.Project.

I created an otherwise clean project, which has a build.gradle like this:

buildscript {
    ext.kotlin_version = '1.2.21'

    repositories {
        mavenCentral()
    }
    dependencies {
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

plugins {
    id "org.jlleitschuh.gradle.ktlint" version "3.0.0"
}

group 'lintsetup'
version '1.0-SNAPSHOT'

apply plugin: 'kotlin-platform-jvm'

repositories {
    mavenCentral()
}

dependencies {
    compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
    testCompile "junit:junit:4.12"
    testCompile "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version"
    testCompile "org.jetbrains.kotlin:kotlin-test:$kotlin_version"
}

test.dependsOn ktlintCheck

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
Tapchicomacommented, Mar 6, 2018

@mverleg feel free to reopen if it will not work for you.

1reaction
JLLeitschuhcommented, Feb 13, 2018

We should support this. For now the solution is to do the following:

afterEvaluate {
    test.dependsOn ktlintCheck
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Improve your code with lint checks - Android Developers
Run lint from the command line. Run lint using the standalone tool ; Configure lint to suppress warnings. Configure lint in Android Studio;...
Read more >
How Do We Configure Android Studio to Run Its Lint on Every ...
Edit the project configuration · In the General tab of the configuration, scroll down and fold open the "Before launch" panel · In...
Read more >
Writing your first Lint check - Medium
The first parameter is the id. That one can be used to suppress it via the @SuppressLint annotation.
Read more >
Using static checks for Android development with annotations ...
Lint checks are automatically performed by the Gradle build system. To see the available checks in Android Studio File Settings Editor Inspections.
Read more >
Leveraging Android Lint Checks - ProAndroidDev
Available within Android Studio as warnings or run directly via gradle via lintDebug; Lint checks are run directly within Android Studio on ...
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