diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5e6fe96..c33e269 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -9,7 +9,7 @@ jobs: strategy: matrix: - java_version: [11] + java_version: [17] steps: - name: Checkout diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml index 5f689a5..614dba4 100644 --- a/.github/workflows/publish-release.yml +++ b/.github/workflows/publish-release.yml @@ -15,10 +15,10 @@ jobs: - name: Checkout uses: actions/checkout@v2 - - name: Install JDK 11 + - name: Install JDK 17 uses: actions/setup-java@v1 with: - java-version: 11 + java-version: 17 - name: Upload release run: ./gradlew publishAllPublicationsToMavenCentralRepository --no-daemon --no-parallel diff --git a/build.gradle b/build.gradle index 6d2880f..1555780 100644 --- a/build.gradle +++ b/build.gradle @@ -9,8 +9,7 @@ buildscript { } dependencies { - classpath 'com.gradle.publish:plugin-publish-plugin:0.10.1' - classpath 'com.vanniktech:gradle-android-junit-jacoco-plugin:0.16.0' + classpath "com.gradle.publish:plugin-publish-plugin:1.2.0" classpath 'com.vanniktech:gradle-maven-publish-plugin:0.16.0' } } @@ -18,19 +17,9 @@ buildscript { apply plugin: 'groovy' apply plugin: 'java-library' apply plugin: 'java-gradle-plugin' -apply plugin: 'com.vanniktech.android.junit.jacoco' apply plugin: "com.vanniktech.maven.publish" apply plugin: 'com.gradle.plugin-publish' -gradlePlugin { - plugins { - androidJUnitJacocoPlugin { - id = 'com.vanniktech.android.junit.jacoco' - implementationClass = 'com.vanniktech.android.junit.jacoco.GenerationPlugin' - } - } -} - repositories { mavenCentral() google() @@ -41,12 +30,12 @@ dependencies { api gradleApi() api localGroovy() - compileOnly 'com.android.tools.build:gradle:7.1.2' + compileOnly 'com.android.tools.build:gradle:8.0.0' - testImplementation 'com.android.tools.build:gradle:7.1.2' - testImplementation 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.10' - testImplementation 'junit:junit:4.13' - testImplementation 'org.spockframework:spock-core:2.2-M1-groovy-3.0', { exclude module: "groovy-all" } // Use localGroovy() + testImplementation 'com.android.tools.build:gradle:8.0.0' + testImplementation 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.21' + testImplementation 'org.junit.jupiter:junit-jupiter-api:5.9.3' + testImplementation 'org.spockframework:spock-core:2.4-M1-groovy-3.0', { exclude module: "groovy-all" } // Use localGroovy() // https://github.com/gradle/gradle/issues/16774#issuecomment-893493869 def toolingApiBuildersJar = (project as ProjectInternal).services.get(ModuleRegistry.class) @@ -57,17 +46,19 @@ dependencies { testRuntimeOnly(files(toolingApiBuildersJar)) } -sourceCompatibility = JavaVersion.VERSION_1_8 +sourceCompatibility = JavaVersion.VERSION_17 -pluginBundle { +gradlePlugin { website = POM_URL vcsUrl = POM_SCM_URL plugins { androidJUnitJacocoPlugin { + id = POM_ARTIFACT_ID + implementationClass = POM_IMPLEMENTATION_CLASS displayName = POM_NAME - tags = ['gradle', 'android', 'jacoco', 'app module', 'library module', 'junit', 'unit', 'testing', 'coverage'] description = POM_DESCRIPTION + tags.set(['gradle', 'android', 'jacoco', 'app module', 'library module', 'junit', 'unit', 'testing', 'coverage']) } } } @@ -79,6 +70,6 @@ tasks.withType(Test).configureEach { } wrapper { - gradleVersion = '7.4' + gradleVersion = '8.0' distributionType = Wrapper.DistributionType.ALL } diff --git a/gradle.properties b/gradle.properties index ec12e58..8673a72 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,7 +1,8 @@ GROUP=com.vanniktech -VERSION_NAME=0.17.0-SNAPSHOT +VERSION_NAME=0.17.0 -POM_ARTIFACT_ID=gradle-android-junit-jacoco-plugin +POM_ARTIFACT_ID=com.vanniktech.android.junit.jacoco +POM_IMPLEMENTATION_CLASS =com.vanniktech.android.junit.jacoco.GenerationPlugin POM_NAME=Gradle Android Jacoco Plugin POM_PACKAGING=jar @@ -18,4 +19,4 @@ POM_LICENCE_URL=http://www.apache.org/licenses/LICENSE-2.0.txt POM_LICENCE_DIST=repo POM_DEVELOPER_ID=vanniktech -POM_DEVELOPER_NAME=Niklas Baudy \ No newline at end of file +POM_DEVELOPER_NAME=Niklas Baudy diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index b1159fc..3a02907 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-all.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists 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 0dea3a2..5702a89 100644 --- a/src/main/groovy/com/vanniktech/android/junit/jacoco/GenerationPlugin.groovy +++ b/src/main/groovy/com/vanniktech/android/junit/jacoco/GenerationPlugin.groovy @@ -4,7 +4,6 @@ import com.android.build.gradle.api.BaseVariant import org.gradle.api.Plugin import org.gradle.api.Project import org.gradle.api.tasks.testing.Test -import org.gradle.testing.jacoco.tasks.JacocoMerge import org.gradle.testing.jacoco.tasks.JacocoReport class GenerationPlugin implements Plugin { @@ -15,12 +14,12 @@ class GenerationPlugin implements Plugin { final def hasSubProjects = rootProject.subprojects.size() > 0 if (hasSubProjects) { - final def (JacocoMerge mergeTask, JacocoReport mergedReportTask) = addJacocoMergeToRootProject(rootProject, rootProject.junitJacoco) + final def JacocoReport mergedReportTask = addJacocoMergeToRootProject(rootProject, rootProject.junitJacoco) rootProject.subprojects { subProject -> afterEvaluate { final def extension = rootProject.junitJacoco - addJacoco(subProject, extension, mergeTask, mergedReportTask) + addJacoco(subProject, extension, mergedReportTask) } } } else { @@ -33,22 +32,22 @@ class GenerationPlugin implements Plugin { } protected static boolean addJacoco(final Project subProject, final JunitJacocoExtension extension) { - return addJacoco(subProject, extension, null, null) + return addJacoco(subProject, extension, null) } - protected static boolean addJacoco(final Project subProject, final JunitJacocoExtension extension, JacocoMerge mergeTask, JacocoReport mergedReportTask) { + protected static boolean addJacoco(final Project subProject, final JunitJacocoExtension extension, JacocoReport mergedReportTask) { if (!shouldIgnore(subProject, extension)) { if (isAndroidProject(subProject)) { - return addJacocoAndroid(subProject, extension, mergeTask, mergedReportTask) + return addJacocoAndroid(subProject, extension, mergedReportTask) } else if (isJavaProject(subProject) || isKotlinMultiplatform(subProject)) { - return addJacocoJava(subProject, extension, mergeTask, mergedReportTask) + return addJacocoJava(subProject, extension, mergedReportTask) } } return false } - private static boolean addJacocoJava(final Project subProject, final JunitJacocoExtension extension, JacocoMerge mergeTask, JacocoReport mergedReportTask) { + private static boolean addJacocoJava(final Project subProject, final JunitJacocoExtension extension, JacocoReport mergedReportTask) { subProject.plugins.apply('jacoco') subProject.jacoco { @@ -62,9 +61,9 @@ class GenerationPlugin implements Plugin { description = 'Generate Jacoco coverage reports.' reports { - xml.enabled = extension.xml.enabled - csv.enabled = extension.csv.enabled - html.enabled = extension.html.enabled + xml.required = extension.xml.enabled + csv.required = extension.csv.enabled + html.required = extension.html.enabled } getClassDirectories().from(subProject.fileTree( @@ -89,10 +88,8 @@ class GenerationPlugin implements Plugin { getExecutionData().from(subProject.files(subProject.files("${subProject.buildDir}/jacoco/test.exec"))) } - if (mergeTask != null) { - mergeTask.executionData.setFrom(executionData.files + mergeTask.executionData.files) - } if (mergedReportTask != null) { + mergedReportTask.executionData.setFrom(executionData.files + mergedReportTask.executionData.files) mergedReportTask.classDirectories.setFrom(classDirectories.getFrom() + mergedReportTask.classDirectories.getFrom()) mergedReportTask.additionalSourceDirs.setFrom(additionalSourceDirs.getFrom() + mergedReportTask.additionalSourceDirs.getFrom()) mergedReportTask.sourceDirectories.setFrom(sourceDirectories.getFrom() + mergedReportTask.sourceDirectories.getFrom()) @@ -103,7 +100,7 @@ class GenerationPlugin implements Plugin { return true } - private static boolean addJacocoAndroid(final Project subProject, final JunitJacocoExtension extension, JacocoMerge mergeTask, JacocoReport mergedReportTask) { + private static boolean addJacocoAndroid(final Project subProject, final JunitJacocoExtension extension, JacocoReport mergedReportTask) { subProject.plugins.apply('jacoco') subProject.jacoco { @@ -146,11 +143,11 @@ class GenerationPlugin implements Plugin { final def jvmTestTaskName = "test${sourceName.capitalize()}UnitTest" final def instrumentationTestTaskName = "create${sourceName.capitalize()}CoverageReport" - addJacocoTask(false, subProject, extension, mergeTask, mergedReportTask, jvmTaskName, + addJacocoTask(false, subProject, extension, mergedReportTask, jvmTaskName, jvmTestTaskName, instrumentationTestTaskName, sourceName, sourcePath, productFlavorName, buildTypeName) if (buildType.testCoverageEnabled) { - addJacocoTask(true, subProject, extension, mergeTask, mergedReportTask, combinedTaskName, + addJacocoTask(true, subProject, extension, mergedReportTask, combinedTaskName, jvmTestTaskName, instrumentationTestTaskName, sourceName, sourcePath, productFlavorName, buildTypeName) } } @@ -159,7 +156,7 @@ class GenerationPlugin implements Plugin { } private static void addJacocoTask(final boolean combined, final Project subProject, final JunitJacocoExtension extension, - JacocoMerge mergeTask, JacocoReport mergedReportTask, final String taskName, + JacocoReport mergedReportTask, final String taskName, final String jvmTestTaskName, final String instrumentationTestTaskName, final String sourceName, final String sourcePath, final String productFlavorName, final String buildTypeName) { def destinationDir @@ -181,15 +178,15 @@ class GenerationPlugin implements Plugin { reports { xml { - enabled = extension.xml.enabled + required = extension.xml.enabled destination subProject.file("$destinationDir/${sourceName}/jacoco.xml") } csv { - enabled = extension.csv.enabled + required = extension.csv.enabled destination subProject.file("$destinationDir/${sourceName}/jacoco.csv") } html { - enabled = extension.html.enabled + required = extension.html.enabled destination subProject.file("$destinationDir/${sourceName}") } } @@ -240,27 +237,17 @@ class GenerationPlugin implements Plugin { if (combined) { // add instrumentation coverage execution data - doFirst { - def instrumentationTestCoverageDirs = subProject.fileTree("${subProject.buildDir}/outputs/code_coverage") - .matching { include "**/*.ec" } - def allCodeCoverageFiles = instrumentationTestCoverageDirs.files + executionData.files - subProject.logger.with { - info("using following code coverage files for ${taskName}") - allCodeCoverageFiles.each { coverageFile -> - info(coverageFile.path) - } - } - executionData.setFrom(allCodeCoverageFiles) + def codeCoverageDirs = subProject.fileTree("${subProject.buildDir}/outputs/code_coverage").matching { + include "**/*.ec" } + executionData.setFrom(codeCoverageDirs.files + executionData.files) } // add if true in extension or for the unit test Jacoco task def addToMergeTask = !combined || extension.includeInstrumentationCoverageInMergedReport - if (mergeTask != null && addToMergeTask) { - mergeTask.executionData.setFrom(executionData.files + mergeTask.executionData.files) - } if (mergedReportTask != null && addToMergeTask) { + mergedReportTask.executionData.setFrom(executionData.files + mergedReportTask.executionData.files) mergedReportTask.classDirectories.setFrom(classDirectories.getFrom() + mergedReportTask.classDirectories.getFrom()) mergedReportTask.additionalSourceDirs.setFrom(additionalSourceDirs.getFrom() + mergedReportTask.additionalSourceDirs.getFrom()) mergedReportTask.sourceDirectories.setFrom(sourceDirectories.getFrom() + mergedReportTask.sourceDirectories.getFrom()) @@ -280,38 +267,20 @@ class GenerationPlugin implements Plugin { } } - def mergeTask = project.task("mergeJacocoReports", type: JacocoMerge) { + def mergedReportTask = project.task("jacocoTestReportMerged", type: JacocoReport) { executionData project.files().asFileTree // Start with an empty collection. - destinationFile project.file("${project.buildDir}/jacoco/mergedReport.exec") - - doFirst { - // Filter non existing files. - def realExecutionData = project.files() - - executionData.each { - if (it.exists()) { - realExecutionData.setFrom(project.files(it) + realExecutionData.files) - } - } - - executionData = realExecutionData - } - } - - def mergedReportTask = project.task("jacocoTestReportMerged", type: JacocoReport, dependsOn: mergeTask) { - executionData mergeTask.destinationFile reports { xml { - enabled = extension.xml.enabled + required = extension.xml.enabled destination project.file("${project.buildDir}/reports/jacoco/jacoco.xml") } csv { - enabled = extension.csv.enabled + required = extension.csv.enabled destination project.file("${project.buildDir}/reports/jacoco/jacoco.csv") } html { - enabled = extension.html.enabled + required = extension.html.enabled destination project.file("${project.buildDir}/reports/jacoco") } } @@ -322,7 +291,7 @@ class GenerationPlugin implements Plugin { getSourceDirectories().from(project.files()) } - return [mergeTask, mergedReportTask] + return mergedReportTask } static List getExcludes(final JunitJacocoExtension extension) { diff --git a/src/main/groovy/com/vanniktech/android/junit/jacoco/JunitJacocoExtension.groovy b/src/main/groovy/com/vanniktech/android/junit/jacoco/JunitJacocoExtension.groovy index 8fedca4..2603c17 100644 --- a/src/main/groovy/com/vanniktech/android/junit/jacoco/JunitJacocoExtension.groovy +++ b/src/main/groovy/com/vanniktech/android/junit/jacoco/JunitJacocoExtension.groovy @@ -9,7 +9,7 @@ class JunitJacocoExtension { * define the version of jacoco which should be used * @since 0.3.0 */ - String jacocoVersion = '0.8.7' + String jacocoVersion = '0.8.10' /** * subprojects that should be ignored diff --git a/src/test/groovy/com/vanniktech/android/junit/jacoco/GenerationPluginSpec.groovy b/src/test/groovy/com/vanniktech/android/junit/jacoco/GenerationPluginSpec.groovy index eb8ca7c..5b55afd 100644 --- a/src/test/groovy/com/vanniktech/android/junit/jacoco/GenerationPluginSpec.groovy +++ b/src/test/groovy/com/vanniktech/android/junit/jacoco/GenerationPluginSpec.groovy @@ -6,9 +6,9 @@ import spock.lang.Unroll final class GenerationPluginSpec extends Specification { final static ANDROID_PLUGINS = ["com.android.application", "com.android.library", "com.android.test", "com.android.dynamic-feature"] - final static COMPILE_SDK_VERSION = 28 - final static BUILD_TOOLS_VERSION = "28.0.3" - final static APPLICATION_ID = "com.example" + final static COMPILE_SDK_VERSION = 33 + final static BUILD_TOOLS_VERSION = "33.0.0" + final static APPLICATION_ID = "com.vanniktech" def project 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 d28fba8..55f1047 100644 --- a/src/test/groovy/com/vanniktech/android/junit/jacoco/GenerationTest.groovy +++ b/src/test/groovy/com/vanniktech/android/junit/jacoco/GenerationTest.groovy @@ -4,7 +4,7 @@ import org.gradle.api.Project import org.gradle.api.Task import org.gradle.testing.jacoco.plugins.JacocoPlugin import org.gradle.testing.jacoco.tasks.JacocoReport -import org.junit.Test +import org.junit.jupiter.api.Test import java.nio.file.Paths @@ -213,15 +213,13 @@ class GenerationTest { @Test void mergedJacocoReportDoesNotHaveDependencies() { def rootProject = ProjectHelper.prepare(ROOT).get() - def mergeJacocoReports = rootProject.tasks.findByName("mergeJacocoReports") def jacocoTestReportMerged = rootProject.tasks.findByName("jacocoTestReportMerged") - assert mergeJacocoReports != null assert jacocoTestReportMerged != null values().findAll { it != ROOT && it != ANDROID_TEST }.each { def project = ProjectHelper.prepare(it, rootProject).get() - GenerationPlugin.addJacoco(project, new JunitJacocoExtension(), mergeJacocoReports, jacocoTestReportMerged) + GenerationPlugin.addJacoco(project, new JunitJacocoExtension(), jacocoTestReportMerged) if (it == JAVA) { assertJacocoJava(project) } else { @@ -229,9 +227,7 @@ class GenerationTest { } } - assert mergeJacocoReports.dependsOn.isEmpty() - assert jacocoTestReportMerged.dependsOn.size() == 1 - assert jacocoTestReportMerged.dependsOn.contains(mergeJacocoReports) + assert jacocoTestReportMerged.dependsOn.size() == 0 } private void assertJacocoAndroidWithFlavors(final Project project) { @@ -270,12 +266,12 @@ class GenerationTest { assert sourceDirectories.contains(project.file("src/${flavor}/$it")) } - assert reports.xml.enabled - assert reports.xml.destination.toPath() == Paths.get(project.buildDir.absolutePath, "/reports/jacoco/${flavor}${buildType.capitalize()}/jacoco.xml") - assert reports.csv.enabled - assert reports.csv.destination.toPath() == Paths.get(project.buildDir.absolutePath, "/reports/jacoco/${flavor}${buildType.capitalize()}/jacoco.csv") - assert reports.html.enabled - assert reports.html.destination.toPath() == Paths.get(project.buildDir.absolutePath, "/reports/jacoco/${flavor}${buildType.capitalize()}") + assert reports.xml.required + assert reports.xml.outputLocation.get().asFile.toPath() == Paths.get(project.buildDir.absolutePath, "/reports/jacoco/${flavor}${buildType.capitalize()}/jacoco.xml") + assert reports.csv.required + assert reports.csv.outputLocation.get().asFile.toPath() == Paths.get(project.buildDir.absolutePath, "/reports/jacoco/${flavor}${buildType.capitalize()}/jacoco.csv") + assert reports.html.required + assert reports.html.outputLocation.get().asFile.toPath() == Paths.get(project.buildDir.absolutePath, "/reports/jacoco/${flavor}${buildType.capitalize()}") assert classDirectories.getFrom().first().dir == project.file("build/") @@ -332,12 +328,12 @@ class GenerationTest { assert sourceDirectories.contains(project.file("src/debug/$it")) } - assert reports.xml.enabled - assert reports.xml.destination.toPath() == Paths.get(project.buildDir.absolutePath, "/reports/jacoco/debug/jacoco.xml") - assert reports.csv.enabled - assert reports.csv.destination.toPath() == Paths.get(project.buildDir.absolutePath, "/reports/jacoco/debug/jacoco.csv") - assert reports.html.enabled - assert reports.html.destination.toPath() == Paths.get(project.buildDir.absolutePath, "/reports/jacoco/debug") + assert reports.xml.required + assert reports.xml.outputLocation.get().asFile.toPath() == Paths.get(project.buildDir.absolutePath, "/reports/jacoco/debug/jacoco.xml") + assert reports.csv.required + assert reports.csv.outputLocation.get().asFile.toPath() == Paths.get(project.buildDir.absolutePath, "/reports/jacoco/debug/jacoco.csv") + assert reports.html.required + assert reports.html.outputLocation.get().asFile.toPath() == Paths.get(project.buildDir.absolutePath, "/reports/jacoco/debug") assert classDirectories.getFrom().first().dir == project.file("build/") if (hasKotlin(project)) { @@ -381,12 +377,12 @@ class GenerationTest { assert sourceDirectories.contains(project.file("src/debug/$it")) } - assert reports.xml.enabled - assert reports.xml.destination.toPath() == Paths.get(project.buildDir.absolutePath, '/reports/jacocoCombined/debug/jacoco.xml') - assert reports.csv.enabled - assert reports.csv.destination.toPath() == Paths.get(project.buildDir.absolutePath, '/reports/jacocoCombined/debug/jacoco.csv') - assert reports.html.enabled - assert reports.html.destination.toPath() == Paths.get(project.buildDir.absolutePath, '/reports/jacocoCombined/debug') + assert reports.xml.required + assert reports.xml.outputLocation.get().asFile.toPath() == Paths.get(project.buildDir.absolutePath, '/reports/jacocoCombined/debug/jacoco.xml') + assert reports.csv.required + assert reports.csv.outputLocation.get().asFile.toPath() == Paths.get(project.buildDir.absolutePath, '/reports/jacocoCombined/debug/jacoco.csv') + assert reports.html.required + assert reports.html.outputLocation.get().asFile.toPath() == Paths.get(project.buildDir.absolutePath, '/reports/jacocoCombined/debug') assert classDirectories.getFrom().first().dir == project.file("build/") if (hasKotlin(project)) { @@ -434,12 +430,12 @@ class GenerationTest { assert sourceDirectories.contains(project.file("src/release/$it")) } - assert reports.xml.enabled - assert reports.xml.destination.toPath() == Paths.get(project.buildDir.absolutePath, '/reports/jacoco/release/jacoco.xml') - assert reports.csv.enabled - assert reports.csv.destination.toPath() == Paths.get(project.buildDir.absolutePath, '/reports/jacoco/release/jacoco.csv') - assert reports.html.enabled - assert reports.html.destination.toPath() == Paths.get(project.buildDir.absolutePath, '/reports/jacoco/release') + assert reports.xml.required + assert reports.xml.outputLocation.get().asFile.toPath() == Paths.get(project.buildDir.absolutePath, '/reports/jacoco/release/jacoco.xml') + assert reports.csv.required + assert reports.csv.outputLocation.get().asFile.toPath() == Paths.get(project.buildDir.absolutePath, '/reports/jacoco/release/jacoco.csv') + assert reports.html.required + assert reports.html.outputLocation.get().asFile.toPath() == Paths.get(project.buildDir.absolutePath, '/reports/jacoco/release') assert classDirectories.getFrom().first().dir == project.file("build/") if (hasKotlin(project)) { @@ -484,12 +480,12 @@ class GenerationTest { assert sourceDirectories.contains(project.file("src/release/$it")) } - assert reports.xml.enabled - assert reports.xml.destination.toPath() == Paths.get(project.buildDir.absolutePath, '/reports/jacocoCombined/release/jacoco.xml') - assert reports.csv.enabled - assert reports.csv.destination.toPath() == Paths.get(project.buildDir.absolutePath, '/reports/jacocoCombined/release/jacoco.csv') - assert reports.html.enabled - assert reports.html.destination.toPath() == Paths.get(project.buildDir.absolutePath, '/reports/jacocoCombined/release') + assert reports.xml.required + assert reports.xml.outputLocation.get().asFile.toPath() == Paths.get(project.buildDir.absolutePath, '/reports/jacocoCombined/release/jacoco.xml') + assert reports.csv.required + assert reports.csv.outputLocation.get().asFile.toPath() == Paths.get(project.buildDir.absolutePath, '/reports/jacocoCombined/release/jacoco.csv') + assert reports.html.required + assert reports.html.outputLocation.get().asFile.toPath() == Paths.get(project.buildDir.absolutePath, '/reports/jacocoCombined/release') assert classDirectories.getFrom().first().dir == project.file("build/") if (hasKotlin(project)) { @@ -545,9 +541,9 @@ class GenerationTest { assert classDirectories.getFrom()[1].dir == project.file("build/") assert contentEquals(classDirectories.getFrom()[1].includes, ['**/classes/**/main/**']) - assert reports.xml.enabled - assert reports.csv.enabled - assert reports.html.enabled + assert reports.xml.required + assert reports.csv.required + assert reports.html.required assert taskDependsOn(task, 'test') } diff --git a/src/test/groovy/com/vanniktech/android/junit/jacoco/JunitJacocoExtensionTest.groovy b/src/test/groovy/com/vanniktech/android/junit/jacoco/JunitJacocoExtensionTest.groovy index 40268fe..a970b2b 100644 --- a/src/test/groovy/com/vanniktech/android/junit/jacoco/JunitJacocoExtensionTest.groovy +++ b/src/test/groovy/com/vanniktech/android/junit/jacoco/JunitJacocoExtensionTest.groovy @@ -1,6 +1,6 @@ package com.vanniktech.android.junit.jacoco -import org.junit.Test +import org.junit.jupiter.api.Test class JunitJacocoExtensionTest { @Test void defaults() { diff --git a/src/test/groovy/com/vanniktech/android/junit/jacoco/ProjectHelper.groovy b/src/test/groovy/com/vanniktech/android/junit/jacoco/ProjectHelper.groovy index 2551f02..ee04865 100644 --- a/src/test/groovy/com/vanniktech/android/junit/jacoco/ProjectHelper.groovy +++ b/src/test/groovy/com/vanniktech/android/junit/jacoco/ProjectHelper.groovy @@ -1,9 +1,9 @@ package com.vanniktech.android.junit.jacoco +import com.android.build.api.variant.ApplicationVariant import com.android.build.gradle.AppExtension import com.android.build.gradle.LibraryExtension import com.android.build.gradle.TestExtension -import com.android.build.gradle.api.BaseVariant import com.android.build.gradle.internal.coverage.JacocoOptions import com.android.builder.model.BuildType import groovy.mock.interceptor.MockFor @@ -40,7 +40,8 @@ final class ProjectHelper { case ProjectType.ANDROID_APPLICATION: case ProjectType.ANDROID_KOTLIN_APPLICATION: case ProjectType.ANDROID_DYNAMIC_FEATURE: - project = builder.withName('android app').build() + def name = "android app ${projectType.name()}" + project = builder.withName(name).build() def androidMock = new MockFor(AppExtension) def buildTypesMock = ["debug", "release"].collect { bt -> def type = new MockFor(BuildType) @@ -50,7 +51,7 @@ final class ProjectHelper { } androidMock.metaClass.getBuildTypes = { buildTypesMock } def appVariants = buildTypesMock.collect { bt -> - def variant = new MockFor(BaseVariant) + def variant = new MockFor(ApplicationVariant) variant.metaClass.getFlavorName = { null } variant.metaClass.getBuildType = { bt } variant @@ -64,7 +65,8 @@ final class ProjectHelper { break case ProjectType.ANDROID_LIBRARY: case ProjectType.ANDROID_KOTLIN_MULTIPLATFORM: - project = builder.withName('android library').build() + def name = "android library ${projectType.name()}" + project = builder.withName(name).build() def androidMock = new MockFor(LibraryExtension) def buildTypesMock = ["debug", "release"].collect { bt -> def type = new MockFor(BuildType) @@ -74,7 +76,7 @@ final class ProjectHelper { } androidMock.metaClass.getBuildTypes = { buildTypesMock } def appVariants = buildTypesMock.collect { bt -> - def variant = new MockFor(BaseVariant) + def variant = new MockFor(ApplicationVariant) variant.metaClass.getFlavorName = { null } variant.metaClass.getBuildType = { bt } variant @@ -123,7 +125,7 @@ final class ProjectHelper { def variants = customFlavors.collect { flavorName, config -> project.android.buildTypes.collect { buildType -> - def variant = new MockFor(BaseVariant) + def variant = new MockFor(ApplicationVariant) variant.metaClass.getBuildType = { def type = new MockFor(BuildType) type.metaClass.getName = { buildType.name }