bmuschko / gradle-clover-plugin

Gradle plugin for generating a code coverage report using Clover
Apache License 2.0
74 stars 49 forks source link

NPE with Android plugin #111

Closed sahoosunilkumar closed 6 years ago

sahoosunilkumar commented 6 years ago

I am facing java.lang.NullPointerException: Cannot execute null+configuration ':app:clover'

Following is my application build.gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript { repositories { jcenter() google() mavenCentral() maven { url 'https://plugins.gradle.org/m2/' } } dependencies { classpath 'com.android.tools.build:gradle:3.0.1'

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}

}

plugins { id 'com.github.johnrengelman.shadow' version '2.0.2' id "com.bmuschko.clover" version "2.1.3" }

allprojects { repositories { jcenter() } }

task clean(type: Delete) { delete rootProject.buildDir }

And following is my module build.gradle

apply plugin: 'com.github.johnrengelman.shadow' apply plugin: 'com.bmuschko.clover' apply plugin: 'com.android.application'

android { compileSdkVersion 25 buildToolsVersion "25.0.0" defaultConfig { applicationId "net.karthikraj.sample.scrollingbehaviorandroid" minSdkVersion 19 targetSdkVersion 25 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:25.1.0' testCompile 'junit:junit:4.12' compile 'com.android.support:design:25.1.0' compile 'com.android.support:cardview-v7:25.1.0'

clover 'org.openclover:clover:4.2.0'

}

Alex-Vol commented 6 years ago

Please use plugin version 2.2.0. You are referencing version 2.1.3. I will not debug an issue with an older version of the plugin.

sahoosunilkumar commented 6 years ago

FAILURE: Build failed with an exception.

BUILD FAILED in 0s

Alex-Vol commented 6 years ago

The stacktrace helped pinpoint the issue. It is an easy fix but it is a curious issue. The Test task appears to have a null classpath which is unusual to say the least. Something, perhaps another plugin is setting the classpath to null instead of empty. I can add defensive logic to avoid the problem. I will try to find some time to correct this during the weekend.

Alex-Vol commented 6 years ago

Added defensive logic for this issue. It feels like this is a bug in Android plugins in your build but I did find the code and protected against null. I cannot make a reasonable reproduction of this so I hope that is taking care of your issues.

Release 2.2.1 may take a bit of time to propagate to the plugin portal.