detekt: Why exception may occurs?

Gradle console output is below

21:15:39.548 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] 21:15:39.548 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] FAILURE: Build failed with an exception. 21:15:39.548 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] 21:15:39.548 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * Where: 21:15:39.548 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] Build file ‘/Users/d.samaryan/Documents/Adroid Samples/ktlint/Kotlindetect/app/build.gradle’ line: 40 21:15:39.548 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] 21:15:39.548 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * What went wrong: 21:15:39.549 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] A problem occurred evaluating project ‘:app’. 21:15:39.549 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] > java.lang.reflect.InvocationTargetException (no error message) 21:15:39.549 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] 21:15:39.549 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * Try: 21:15:39.549 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] Run with --stacktrace option to get the stack trace.

  • What went wrong: A problem occurred evaluating project ‘:app’.

java.lang.reflect.InvocationTargetException (no error message)

In my build.gradle file:

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'io.gitlab.arturbosch.detekt'


android {
    compileSdkVersion 26
    buildToolsVersion "26.0.0"
    defaultConfig {
        applicationId "com.example.kotlindetect"
        minSdkVersion 19
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:26.+'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    testCompile 'junit:junit:4.12'
    compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
}
repositories {
    mavenCentral()
}
detekt {
    version = "1.0.0.M12.3"  // Specify current detekt version
    input = "$projectDir/src/main/java" // input is preconfigured to 'project.projectDir.absolutePath'
    config = "$projectDir/detekt.yml" // Use $project.projectDir to navigate inside your project
    filters = ".*test.*, .*/resources/.*" // What paths to exclude? Use comma oder semicolon to separate
}

Hope for your help, thanks!

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 16 (7 by maintainers)

Most upvoted comments

$projectDir is the short form for $project.projectDir

More generally, quoting the project API docs:

Any property you access in your build script, which is not defined in the build script, is delegated to the Project object.

I found my mistake: in the detekt clojure I set a wrong path to the project:

detekt {
    debug = true
    version = "1.0.0.M12.3"
    profile("main") {
        input = "$projectDir/src/main/java" //   missed 'app' path element  input = "$projectDir/app/src/main/java"
        output = "$projectDir/output.xml"
        config = "$projectDir/detekt.yml"
        filters = ".*test.*,.*/resources/.*"
    }
}

And now plugin actually worked! Thank you so much for help in solving the problem and for your plugin!