Skip to content

Commit

Permalink
Support popular JVM languages by default. (#75)
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredsburrows authored and vanniktech committed Aug 2, 2017
1 parent 6816927 commit 4bc2c68
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,11 @@ class GenerationPlugin implements Plugin<Project> {
)

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)
Expand Down Expand Up @@ -134,12 +138,24 @@ class GenerationPlugin implements Plugin<Project> {
)

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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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'
Expand All @@ -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'
Expand Down Expand Up @@ -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/')

Expand Down

0 comments on commit 4bc2c68

Please sign in to comment.