Skip to content

Commit 0fd50e1

Browse files
authored
Change "Jacoco plugin applied" message log level from warn to info (#33)
1 parent 569df63 commit 0fd50e1

File tree

1 file changed

+13
-17
lines changed

1 file changed

+13
-17
lines changed

plugin/src/main/kotlin/org/neotech/plugin/rootcoverage/RootCoveragePlugin.kt

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,8 @@ class RootCoveragePlugin : Plugin<Project> {
2929
rootProjectExtension = project.extensions.create("rootCoverage", RootCoveragePluginExtension::class.java)
3030

3131
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-
)
3632
project.plugins.apply(JacocoPlugin::class.java)
33+
project.logJacocoHasBeenApplied()
3734
}
3835

3936
project.afterEvaluate {
@@ -162,7 +159,7 @@ class RootCoveragePlugin : Plugin<Project> {
162159
task.reports.html.destination = project.file("${project.buildDir}/reports/jacoco")
163160
task.reports.xml.destination = project.file("${project.buildDir}/reports/jacoco.xml")
164161
task.reports.csv.destination = project.file("${project.buildDir}/reports/jacoco.csv")
165-
162+
166163
// Add some run-time checks.
167164
task.doFirst {
168165
it.project.allprojects.forEach { subProject ->
@@ -223,12 +220,8 @@ class RootCoveragePlugin : Plugin<Project> {
223220
extension.libraryVariants.all { variant ->
224221
if (variant.buildType.isTestCoverageEnabled && variant.name.capitalize() == buildVariant.capitalize()) {
225222
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-
)
231223
subProject.plugins.apply(JacocoPlugin::class.java)
224+
subProject.logJacocoHasBeenApplied()
232225
}
233226
addSubProjectVariant(subProject, variant)
234227
}
@@ -238,12 +231,8 @@ class RootCoveragePlugin : Plugin<Project> {
238231
extension.applicationVariants.all { variant ->
239232
if (variant.buildType.isTestCoverageEnabled && variant.name.capitalize() == buildVariant.capitalize()) {
240233
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-
)
246234
subProject.plugins.apply(JacocoPlugin::class.java)
235+
subProject.logJacocoHasBeenApplied()
247236
}
248237
addSubProjectVariant(subProject, variant)
249238
}
@@ -293,9 +282,9 @@ class RootCoveragePlugin : Plugin<Project> {
293282
*/
294283
private fun Project.applyConfiguration() {
295284
tasks.withType(Test::class.java) { testTask ->
296-
testTask.extensions.findByType(JacocoTaskExtension::class.java)?.apply{
285+
testTask.extensions.findByType(JacocoTaskExtension::class.java)?.apply {
297286
isIncludeNoLocationClasses = rootProjectExtension.includeNoLocationClasses
298-
if(isIncludeNoLocationClasses) {
287+
if (isIncludeNoLocationClasses) {
299288
// This Plugin is used for Android development and should support the Robolectric + Jacoco use-case
300289
// flawlessly, therefore this "bugfix" is included in the plugin codebase:
301290
// See: https://github.com/gradle/gradle/issues/5184#issuecomment-457865951
@@ -304,4 +293,11 @@ class RootCoveragePlugin : Plugin<Project> {
304293
}
305294
}
306295
}
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+
}
307303
}

0 commit comments

Comments
 (0)