@@ -29,11 +29,8 @@ class RootCoveragePlugin : Plugin<Project> {
29
29
rootProjectExtension = project.extensions.create(" rootCoverage" , RootCoveragePluginExtension ::class .java)
30
30
31
31
if (project.plugins.withType(JacocoPlugin ::class .java).isEmpty()) {
32
- project.logger.warn(
33
- " Warning: Jacoco plugin was not found for project: '${project.name} ', it has been" +
34
- " applied automatically, but you should do this manually. Build file: ${project.buildFile} "
35
- )
36
32
project.plugins.apply (JacocoPlugin ::class .java)
33
+ project.logJacocoHasBeenApplied()
37
34
}
38
35
39
36
project.afterEvaluate {
@@ -162,7 +159,7 @@ class RootCoveragePlugin : Plugin<Project> {
162
159
task.reports.html.destination = project.file(" ${project.buildDir} /reports/jacoco" )
163
160
task.reports.xml.destination = project.file(" ${project.buildDir} /reports/jacoco.xml" )
164
161
task.reports.csv.destination = project.file(" ${project.buildDir} /reports/jacoco.csv" )
165
-
162
+
166
163
// Add some run-time checks.
167
164
task.doFirst {
168
165
it.project.allprojects.forEach { subProject ->
@@ -223,12 +220,8 @@ class RootCoveragePlugin : Plugin<Project> {
223
220
extension.libraryVariants.all { variant ->
224
221
if (variant.buildType.isTestCoverageEnabled && variant.name.capitalize() == buildVariant.capitalize()) {
225
222
if (subProject.plugins.withType(JacocoPlugin ::class .java).isEmpty()) {
226
- subProject.logger.info(
227
- " Jacoco plugin was not found for project: '${subProject.name} ', it" +
228
- " has been applied automatically but you should do this manually. Build file:" +
229
- " ${subProject.buildFile} "
230
- )
231
223
subProject.plugins.apply (JacocoPlugin ::class .java)
224
+ subProject.logJacocoHasBeenApplied()
232
225
}
233
226
addSubProjectVariant(subProject, variant)
234
227
}
@@ -238,12 +231,8 @@ class RootCoveragePlugin : Plugin<Project> {
238
231
extension.applicationVariants.all { variant ->
239
232
if (variant.buildType.isTestCoverageEnabled && variant.name.capitalize() == buildVariant.capitalize()) {
240
233
if (subProject.plugins.withType(JacocoPlugin ::class .java).isEmpty()) {
241
- subProject.logger.info(
242
- " Jacoco plugin was not found for project: '${subProject.name} ', it" +
243
- " has been applied automatically but you should do this manually. Build file:" +
244
- " ${subProject.buildFile} "
245
- )
246
234
subProject.plugins.apply (JacocoPlugin ::class .java)
235
+ subProject.logJacocoHasBeenApplied()
247
236
}
248
237
addSubProjectVariant(subProject, variant)
249
238
}
@@ -293,9 +282,9 @@ class RootCoveragePlugin : Plugin<Project> {
293
282
*/
294
283
private fun Project.applyConfiguration () {
295
284
tasks.withType(Test ::class .java) { testTask ->
296
- testTask.extensions.findByType(JacocoTaskExtension ::class .java)?.apply {
285
+ testTask.extensions.findByType(JacocoTaskExtension ::class .java)?.apply {
297
286
isIncludeNoLocationClasses = rootProjectExtension.includeNoLocationClasses
298
- if (isIncludeNoLocationClasses) {
287
+ if (isIncludeNoLocationClasses) {
299
288
// This Plugin is used for Android development and should support the Robolectric + Jacoco use-case
300
289
// flawlessly, therefore this "bugfix" is included in the plugin codebase:
301
290
// See: https://github.com/gradle/gradle/issues/5184#issuecomment-457865951
@@ -304,4 +293,11 @@ class RootCoveragePlugin : Plugin<Project> {
304
293
}
305
294
}
306
295
}
296
+
297
+ private fun Project.logJacocoHasBeenApplied () {
298
+ project.logger.info(
299
+ " Jacoco plugin was not found for project: '${project.name} ', it has been applied automatically:" +
300
+ " ${project.buildFile} "
301
+ )
302
+ }
307
303
}
0 commit comments