Skip to content

Commit

Permalink
Fix Issue #111: NPE when using Android plugin
Browse files Browse the repository at this point in the history
Added defensive code tp prevent an NPE when this plugin is used
with the Android plugin. I believe this points to a problem in
the Android plugin setting the Test task classpath to a null instead
of an empty file collection as would be the correct way to do it.
  • Loading branch information
Alex-Vol-SV committed Apr 24, 2018
1 parent f0e4fb5 commit b65bcba
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 3 deletions.
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,17 @@

The plugin provides generation of code coverage reports using [OpenClover](http://openclover.org/).

# Gradle Compatibility Tested

Built for Oracle JDK7
Tested with Oracle JDK8

| Gradle Version | Works |
| :------------: | :---: |
| 2.14.1 | yes |
| 3.5.1 | yes |
| 4.4.1 | yes |

## Usage

To use the Clover plugin, include in your build script:
Expand All @@ -39,7 +50,7 @@ example on how to retrieve it from Bintray:
}

dependencies {
classpath 'com.bmuschko:gradle-clover-plugin:2.2.0'
classpath 'com.bmuschko:gradle-clover-plugin:2.2.1'
}
}

Expand Down
4 changes: 4 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
### Version 2.2.1 (April 24, 2017)

* Fix NPE with Android Plugin - [Issue 111](https://github.com/bmuschko/gradle-clover-plugin/issues/111)

### Version 2.2.0 (December 29, 2017)

Gradle 4.x compatibility release
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,6 @@ class JavaProjectSpec extends AbstractFunctionalTestBase {
cloverPdfReport.exists()
where:
gradle << [ '2.14.1', '3.5.1', CURRENT_GRADLE ]
gradle << GRADLE_TEST_VERSIONS
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,11 @@ class CloverPlugin implements Plugin<Project> {
@CompileStatic
private void configureActionsForTask(Test test, Project project, CloverPluginConvention cloverPluginConvention, SourceSetsResolver resolver, AggregateDatabasesTask aggregateDatabasesTask) {
if (testTaskEnabled(test, cloverPluginConvention)) {
test.classpath += project.configurations.getByName(CONFIGURATION_NAME).asFileTree
// NB: I believe this is a bug in one of the Android plugins used in the
// user's build who reported this in Issue #111, adding some defensive
// logic here to avoid adding to a null pointer. In Gradle 4.7 this
// might change even further and perhaps will disallow assigning a null.
test.classpath = (test.classpath ?: project.files()).plus(project.configurations.getByName(CONFIGURATION_NAME))
OptimizeTestSetAction optimizeTestSetAction = createOptimizeTestSetAction(cloverPluginConvention, project, resolver, test)
test.doFirst optimizeTestSetAction // add first, gets executed second
test.doFirst createInstrumentCodeAction(cloverPluginConvention, project, resolver, test) // add second, gets executed first
Expand Down

0 comments on commit b65bcba

Please sign in to comment.