DrakkLord / gradle-android-metric-plugin

Plugin for Android Studio that can collect and show code metric infromation from Gradle plugins, such as PMD, Checkstyle
https://plugins.jetbrains.com/plugin/9196-android-gradle-metrics
Apache License 2.0
3 stars 0 forks source link

Checkstyle executes and generate the report but the plugin fails to collect the data #1

Open Townk opened 6 years ago

Townk commented 6 years ago

I have the following configuration on my build.gradle:

apply plugin: 'com.android.application'
apply plugin: 'android-checkstyle'

checkstyle {
    toolVersion = '7.6'
}

tasks.withType(Checkstyle) {
    ignoreFailures = true
    showViolations = false
    source 'src/main', 'src/release', 'src/debug'
    include '**/*.java'
    exclude '**/gen/**'
    exclude '**/R.java'
    exclude '**/BuildConfig.java'
    reports {
        xml.enabled true
        xml {
            destination "${project.buildDir.absolutePath}/reports/checkstyle/checkstyle-report.xml" // this is okay
        }
        html.enabled true
        html {
            destination "${project.buildDir.absolutePath}/reports/checkstyle/checkstyle-report.html"
        }
    }
    classpath = files()
    configFile = file("config/checkstyle/checkstyle.xml")

    configProperties.lineWidth = 120
}

If I manually run the checkstyle task, it generates the report as expected.

If I call the Analyze->Get code metrics report, I get the following:



5:53 PM Gradle build finished in 7s 43ms

5:53 PM Gradle code metrics: collection error >> file element is not part of the project in checkstyle report : /Volumes/Workspace/HelixTrails/src/HelixAndroid/app/build/reports/checkstyle/checkstyle-report.xml

5:53 PM Android-Gradle metric plugin: report collection failed : Checkstyle

5:53 PM Android-Gradle metric plugin: result collection failed```

I'm using AndroidStudio 3.0.1
Gradle v4.6
AndroidGradlePlugin v3.0.0

I also tried to change:

```apply plugin: 'android-checkstyle'```

to:

```apply plugin: 'checkstyle'```

And it gets even worst. The checkstyle tasks are not even created.
DrakkLord commented 6 years ago

One key thing is that variable expansion is not supported properly I think so this

"${project.buildDir.absolutePath}/reports/checkstyle/checkstyle-report.xml"

may not work because it expands a variable.

I've also found issues with Android Studio 3.1, since google is very aggressive about not making old versions available I couldn't test with 3.0, however plugin version 1.0.7 is pending approval which works with Android Studio 3.1. I'll post again when it's up so you can check it out with that version and see if it works for you, just to point it out the new plugin version will only work with android studio 3.1 and up.

Townk commented 6 years ago

No problems, thanks for the update.