Skip to content

Commit 4b6452f

Browse files
committed
Fix: Don't log "skipping module" message for Gradle (sub)projects without a build.gradle file
Fixes #45
1 parent 7bc51de commit 4b6452f

File tree

5 files changed

+22
-2
lines changed

5 files changed

+22
-2
lines changed

Diff for: plugin/src/main/kotlin/org/neotech/plugin/rootcoverage/RootCoveragePlugin.kt

+6-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import org.gradle.testing.jacoco.tasks.JacocoReport
1515
import org.neotech.plugin.rootcoverage.utilities.afterAndroidPluginApplied
1616
import org.neotech.plugin.rootcoverage.utilities.fileTree
1717
import org.neotech.plugin.rootcoverage.utilities.onVariant
18+
import java.io.File
1819

1920
class RootCoveragePlugin : Plugin<Project> {
2021

@@ -119,7 +120,11 @@ class RootCoveragePlugin : Plugin<Project> {
119120
private fun JacocoReport.addSubProject(subProject: Project) {
120121
subProject.afterAndroidPluginApplied(
121122
notFoundAction = {
122-
subProject.logger.info("Note: Skipping code coverage for module '${subProject.name}', reason: not an Android module.")
123+
// Only log if a build.gradle file was found in the project directory, if not it could just be an empty project that holds
124+
// child-projects
125+
if (File(subProject.projectDir, Project.DEFAULT_BUILD_FILE).exists()) {
126+
subProject.logger.info("Note: Skipping code coverage for module '${subProject.name}', reason: not an Android module.")
127+
}
123128
},
124129
action = {
125130
subProject.applyJacocoPluginIfRequired()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
plugins {
2+
id "java-library"
3+
}
4+
5+
dependencies {
6+
implementation fileTree(dir: 'libs', include: ['*.jar'])
7+
}
8+
9+
sourceCompatibility = JavaVersion.VERSION_1_8
10+
targetCompatibility = JavaVersion.VERSION_1_8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
package org.neotech.library.nested.java;
2+
3+
public class Stub {
4+
}

Diff for: plugin/src/test/test-fixtures/multi-module/settings.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ dependencyResolutionManagement {
1919
}
2020
}
2121

22-
include ':app', ':library_android', ':library_java'
22+
include ':app', ':library_android', ':library_java', ':library_nested:java'

0 commit comments

Comments
 (0)