Skip to content

Change "Jacoco plugin applied" message log level from warn to info #33

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,8 @@ class RootCoveragePlugin : Plugin<Project> {
rootProjectExtension = project.extensions.create("rootCoverage", RootCoveragePluginExtension::class.java)

if (project.plugins.withType(JacocoPlugin::class.java).isEmpty()) {
project.logger.warn(
"Warning: Jacoco plugin was not found for project: '${project.name}', it has been" +
" applied automatically, but you should do this manually. Build file: ${project.buildFile}"
)
project.plugins.apply(JacocoPlugin::class.java)
project.logJacocoHasBeenApplied()
}

project.afterEvaluate {
Expand Down Expand Up @@ -162,7 +159,7 @@ class RootCoveragePlugin : Plugin<Project> {
task.reports.html.destination = project.file("${project.buildDir}/reports/jacoco")
task.reports.xml.destination = project.file("${project.buildDir}/reports/jacoco.xml")
task.reports.csv.destination = project.file("${project.buildDir}/reports/jacoco.csv")

// Add some run-time checks.
task.doFirst {
it.project.allprojects.forEach { subProject ->
Expand Down Expand Up @@ -223,12 +220,8 @@ class RootCoveragePlugin : Plugin<Project> {
extension.libraryVariants.all { variant ->
if (variant.buildType.isTestCoverageEnabled && variant.name.capitalize() == buildVariant.capitalize()) {
if (subProject.plugins.withType(JacocoPlugin::class.java).isEmpty()) {
subProject.logger.info(
"Jacoco plugin was not found for project: '${subProject.name}', it" +
" has been applied automatically but you should do this manually. Build file:" +
" ${subProject.buildFile}"
)
subProject.plugins.apply(JacocoPlugin::class.java)
subProject.logJacocoHasBeenApplied()
}
addSubProjectVariant(subProject, variant)
}
Expand All @@ -238,12 +231,8 @@ class RootCoveragePlugin : Plugin<Project> {
extension.applicationVariants.all { variant ->
if (variant.buildType.isTestCoverageEnabled && variant.name.capitalize() == buildVariant.capitalize()) {
if (subProject.plugins.withType(JacocoPlugin::class.java).isEmpty()) {
subProject.logger.info(
"Jacoco plugin was not found for project: '${subProject.name}', it" +
" has been applied automatically but you should do this manually. Build file:" +
" ${subProject.buildFile}"
)
subProject.plugins.apply(JacocoPlugin::class.java)
subProject.logJacocoHasBeenApplied()
}
addSubProjectVariant(subProject, variant)
}
Expand Down Expand Up @@ -293,9 +282,9 @@ class RootCoveragePlugin : Plugin<Project> {
*/
private fun Project.applyConfiguration() {
tasks.withType(Test::class.java) { testTask ->
testTask.extensions.findByType(JacocoTaskExtension::class.java)?.apply{
testTask.extensions.findByType(JacocoTaskExtension::class.java)?.apply {
isIncludeNoLocationClasses = rootProjectExtension.includeNoLocationClasses
if(isIncludeNoLocationClasses) {
if (isIncludeNoLocationClasses) {
// This Plugin is used for Android development and should support the Robolectric + Jacoco use-case
// flawlessly, therefore this "bugfix" is included in the plugin codebase:
// See: https://github.com/gradle/gradle/issues/5184#issuecomment-457865951
Expand All @@ -304,4 +293,11 @@ class RootCoveragePlugin : Plugin<Project> {
}
}
}

private fun Project.logJacocoHasBeenApplied() {
project.logger.info(
"Jacoco plugin was not found for project: '${project.name}', it has been applied automatically:" +
" ${project.buildFile}"
)
}
}