From 4bc2c68294cb1a31d7d220489a86325a02f2e386 Mon Sep 17 00:00:00 2001 From: Jared Burrows Date: Wed, 2 Aug 2017 00:29:32 -0700 Subject: [PATCH] Support popular JVM languages by default. (#75) --- .../junit/jacoco/GenerationPlugin.groovy | 20 +++++- .../junit/jacoco/GenerationTest.groovy | 68 ++++++++++++------- 2 files changed, 61 insertions(+), 27 deletions(-) diff --git a/src/main/groovy/com/vanniktech/android/junit/jacoco/GenerationPlugin.groovy b/src/main/groovy/com/vanniktech/android/junit/jacoco/GenerationPlugin.groovy index 83361ae..dcf2489 100644 --- a/src/main/groovy/com/vanniktech/android/junit/jacoco/GenerationPlugin.groovy +++ b/src/main/groovy/com/vanniktech/android/junit/jacoco/GenerationPlugin.groovy @@ -68,7 +68,11 @@ class GenerationPlugin implements Plugin { ) final def coverageSourceDirs = [ - 'src/main/java', + 'src/main/clojure', + 'src/main/groovy', + 'src/main/java', + 'src/main/kotlin', + 'src/main/scala' ] additionalSourceDirs = subProject.files(coverageSourceDirs) @@ -134,12 +138,24 @@ class GenerationPlugin implements Plugin { ) final def coverageSourceDirs = [ + "src/main/clojure", + "src/main/groovy", "src/main/java", - "src/$buildTypeName/java" + "src/main/kotlin", + "src/main/scala", + "src/$buildTypeName/clojure", + "src/$buildTypeName/groovy", + "src/$buildTypeName/java", + "src/$buildTypeName/kotlin", + "src/$buildTypeName/scala" ] if (productFlavorName) { + coverageSourceDirs.add("src/$productFlavorName/clojure") + coverageSourceDirs.add("src/$productFlavorName/groovy") coverageSourceDirs.add("src/$productFlavorName/java") + coverageSourceDirs.add("src/$productFlavorName/kotlin") + coverageSourceDirs.add("src/$productFlavorName/scala") } additionalSourceDirs = subProject.files(coverageSourceDirs) diff --git a/src/test/groovy/com/vanniktech/android/junit/jacoco/GenerationTest.groovy b/src/test/groovy/com/vanniktech/android/junit/jacoco/GenerationTest.groovy index 0e007b5..71a2e4c 100644 --- a/src/test/groovy/com/vanniktech/android/junit/jacoco/GenerationTest.groovy +++ b/src/test/groovy/com/vanniktech/android/junit/jacoco/GenerationTest.groovy @@ -9,7 +9,9 @@ import org.junit.Test import static com.vanniktech.android.junit.jacoco.ProjectHelper.ProjectType.* public class GenerationTest { - @Test + def LANGUAGES = ["clojure", "groovy", "java", "kotlin", "scala"] + + @Test public void addJacocoAndroidAppWithFlavors() { def androidAppProject = ProjectHelper.prepare(ANDROID_APPLICATION).withRedBlueFlavors().get() @@ -138,15 +140,19 @@ public class GenerationTest { assert executionData.singleFile == project.file("${project.buildDir}/jacoco/test${flavor.capitalize()}${buildType.capitalize()}UnitTest.exec") - assert additionalSourceDirs.size() == 3 - assert additionalSourceDirs.contains(project.file('src/main/java')) - assert additionalSourceDirs.contains(project.file("src/${buildType}/java")) - assert additionalSourceDirs.contains(project.file("src/${flavor}/java")) + assert additionalSourceDirs.size() == 15 + LANGUAGES.every { + assert additionalSourceDirs.contains(project.file("src/main/$it")) + assert additionalSourceDirs.contains(project.file("src/${buildType}/$it")) + assert additionalSourceDirs.contains(project.file("src/${flavor}/$it")) + } - assert sourceDirectories.size() == 3 - assert sourceDirectories.contains(project.file('src/main/java')) - assert sourceDirectories.contains(project.file("src/${buildType}/java")) - assert sourceDirectories.contains(project.file("src/${flavor}/java")) + assert sourceDirectories.size() == 15 + LANGUAGES.every { + assert sourceDirectories.contains(project.file("src/main/$it")) + assert sourceDirectories.contains(project.file("src/${buildType}/$it")) + assert sourceDirectories.contains(project.file("src/${flavor}/$it")) + } assert reports.xml.enabled assert reports.xml.destination.toString() == project.buildDir.absolutePath + "/reports/jacoco/${flavor}${buildType.capitalize()}/jacoco.xml" @@ -175,13 +181,17 @@ public class GenerationTest { assert executionData.singleFile == project.file("${project.buildDir}/jacoco/testDebugUnitTest.exec") - assert additionalSourceDirs.size() == 2 - assert additionalSourceDirs.contains(project.file('src/main/java')) - assert additionalSourceDirs.contains(project.file('src/debug/java')) + assert additionalSourceDirs.size() == 10 + LANGUAGES.every { + assert additionalSourceDirs.contains(project.file("src/main/$it")) + assert additionalSourceDirs.contains(project.file("src/debug/$it")) + } - assert sourceDirectories.size() == 2 - assert sourceDirectories.contains(project.file('src/main/java')) - assert sourceDirectories.contains(project.file('src/debug/java')) + assert sourceDirectories.size() == 10 + LANGUAGES.every { + assert sourceDirectories.contains(project.file("src/main/$it")) + assert sourceDirectories.contains(project.file("src/debug/$it")) + } assert reports.xml.enabled assert reports.xml.destination.toString() == project.buildDir.absolutePath + '/reports/jacoco/debug/jacoco.xml' @@ -204,13 +214,17 @@ public class GenerationTest { assert executionData.singleFile == project.file("${project.buildDir}/jacoco/testReleaseUnitTest.exec") - assert additionalSourceDirs.size() == 2 - assert additionalSourceDirs.contains(project.file('src/main/java')) - assert additionalSourceDirs.contains(project.file('src/release/java')) + assert additionalSourceDirs.size() == 10 + LANGUAGES.every { + assert additionalSourceDirs.contains(project.file("src/main/$it")) + assert additionalSourceDirs.contains(project.file("src/release/$it")) + } - assert sourceDirectories.size() == 2 - assert sourceDirectories.contains(project.file('src/main/java')) - assert sourceDirectories.contains(project.file('src/release/java')) + assert sourceDirectories.size() == 10 + LANGUAGES.every { + assert sourceDirectories.contains(project.file("src/main/$it")) + assert sourceDirectories.contains(project.file("src/release/$it")) + } assert reports.xml.enabled assert reports.xml.destination.toString() == project.buildDir.absolutePath + '/reports/jacoco/release/jacoco.xml' @@ -239,11 +253,15 @@ public class GenerationTest { assert executionData.singleFile == project.file("${project.buildDir}/jacoco/test.exec") - assert additionalSourceDirs.size() == 1 - assert additionalSourceDirs.contains(project.file('src/main/java')) + assert additionalSourceDirs.size() == 5 + LANGUAGES.every { + assert additionalSourceDirs.contains(project.file("src/main/$it")) + } - assert sourceDirectories.size() == 1 - assert sourceDirectories.contains(project.file('src/main/java')) + assert sourceDirectories.size() == 5 + LANGUAGES.every { + assert sourceDirectories.contains(project.file("src/main/$it")) + } assert classDirectories.dir == project.file('build/classes/main/')