diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 9f84fc2..7d5e09b 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,28 +1,28 @@ [versions] -androidMinSdk = "19" +androidMinSdk = "21" androidTargetSdk = "34" androidCompileSdk = "34" kotlin = "1.9.23" -androidGradlePlugin = "8.3.1" +androidGradlePlugin = "8.6.0" [libraries] -appCompat = { module = "androidx.appcompat:appcompat", version = "1.6.1" } +appCompat = { module = "androidx.appcompat:appcompat", version = "1.7.0" } androidGradlePlugin = { module = "com.android.tools.build:gradle", version.ref = "androidGradlePlugin" } androidGradlePluginApi = { module = "com.android.tools.build:gradle-api", version.ref = "androidGradlePlugin" } # Test dependencies junit = { module = "junit:junit", version = "4.13.2" } -truth = { module = "com.google.truth:truth", version = "1.4.2" } -supportTestRunner = { module = "androidx.test:runner", version = "1.5.2" } testOrchestrator = { module = "androidx.test:orchestrator", version = "1.4.2" } -espressoCore = { module = "androidx.test.espresso:espresso-core", version = "3.5.1" } -androidJUnit = { module = "androidx.test.ext:junit", version = "1.1.5" } -commonsCsv = { module = "org.apache.commons:commons-csv", version = "1.10.0" } +truth = { module = "com.google.truth:truth", version = "1.4.4" } +supportTestRunner = { module = "androidx.test:runner", version = "1.6.2" } +espressoCore = { module = "androidx.test.espresso:espresso-core", version = "3.6.1" } +androidJUnit = { module = "androidx.test.ext:junit", version = "1.2.1" } +commonsCsv = { module = "org.apache.commons:commons-csv", version = "1.11.0" } kotlinTest = { module = "org.jetbrains.kotlin:kotlin-test", version.ref = "kotlin" } -robolectric = { module = "org.robolectric:robolectric", version = "4.12.1" } -mockk = { module = "io.mockk:mockk", version = "1.13.10" } -jacksonYaml = { module = "com.fasterxml.jackson.dataformat:jackson-dataformat-yaml", version = "2.17.0"} -jacksonKotlin = { module = "com.fasterxml.jackson.module:jackson-module-kotlin", version = "2.17.0"} +robolectric = { module = "org.robolectric:robolectric", version = "4.13" } +mockk = { module = "io.mockk:mockk", version = "1.13.12" } +jacksonYaml = { module = "com.fasterxml.jackson.dataformat:jackson-dataformat-yaml", version = "2.17.2"} +jacksonKotlin = { module = "com.fasterxml.jackson.module:jackson-module-kotlin", version = "2.17.2"} [bundles] androidInstrumentedTest = ["supportTestRunner", "espressoCore", "androidJUnit"] @@ -33,8 +33,8 @@ jvmTest = ["kotlinTest", "junit", "truth", "commonsCsv"] kotlinJvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" } kotlinAndroid = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" } kotlinDokka = { id = "org.jetbrains.dokka", version = "1.9.20" } -pluginPortalPublish = { id = "com.gradle.plugin-publish", version = "0.21.0" } -mavenPublish = { id = "com.vanniktech.maven.publish", version = "0.28.0" } +pluginPortalPublish = { id = "com.gradle.plugin-publish", version = "1.2.2" } +mavenPublish = { id = "com.vanniktech.maven.publish", version = "0.29.0" } versionCheck = { id = "com.github.ben-manes.versions", version = "0.51.0" } androidApp = { id = "com.android.application", version.ref = "androidGradlePlugin"} androidLibrary = { id = "com.android.library", version.ref = "androidGradlePlugin"} \ No newline at end of file diff --git a/plugin/build.gradle b/plugin/build.gradle index 2ea1001..d1a3ea4 100644 --- a/plugin/build.gradle +++ b/plugin/build.gradle @@ -50,31 +50,17 @@ mavenPublishing { } gradlePlugin { + setWebsite(POM_URL) + setVcsUrl(POM_SCM_URL) plugins { rootCoverage { id = 'nl.neotech.plugin.rootcoverage' implementationClass = 'org.neotech.plugin.rootcoverage.RootCoveragePlugin' - } - } -} - -pluginBundle { - setWebsite(POM_URL) - vcsUrl = POM_SCM_URL - setDescription(POM_DESCRIPTION) - tags = ['android', 'coverage', 'jacoco', 'code-coverage', 'coverage-report', 'aggregated-report'] - - plugins { - rootCoverage { displayName = 'Android-Root-Coverage-Plugin' + description = POM_DESCRIPTION + tags.set(['android', 'coverage', 'jacoco', 'code-coverage', 'coverage-report', 'aggregated-report']) } } - - mavenCoordinates { - groupId = GROUP - artifactId = POM_ARTIFACT_ID - version = VERSION_NAME - } } test { diff --git a/plugin/src/main/kotlin/org/neotech/plugin/rootcoverage/JacocoTaskFactory.kt b/plugin/src/main/kotlin/org/neotech/plugin/rootcoverage/JacocoTaskFactory.kt index cf44404..afb4bab 100644 --- a/plugin/src/main/kotlin/org/neotech/plugin/rootcoverage/JacocoTaskFactory.kt +++ b/plugin/src/main/kotlin/org/neotech/plugin/rootcoverage/JacocoTaskFactory.kt @@ -1,6 +1,7 @@ package org.neotech.plugin.rootcoverage import org.gradle.api.Project +import org.neotech.plugin.rootcoverage.utilities.getReportOutputDir import org.neotech.plugin.rootcoverage.utilities.getReportOutputFile private const val JACOCO_PLUGIN_NAME = "jacoco" @@ -30,7 +31,7 @@ internal fun Project.createJacocoReportTask( task.group = taskGroup task.description = taskDescription task.reports.apply { - html.outputLocation.set(getReportOutputFile("jacoco")) + html.outputLocation.set(getReportOutputDir("jacoco")) xml.outputLocation.set(getReportOutputFile("jacoco.xml")) csv.outputLocation.set(getReportOutputFile("jacoco.csv")) } diff --git a/plugin/src/main/kotlin/org/neotech/plugin/rootcoverage/RootCoveragePlugin.kt b/plugin/src/main/kotlin/org/neotech/plugin/rootcoverage/RootCoveragePlugin.kt index 4b72754..c775c7a 100644 --- a/plugin/src/main/kotlin/org/neotech/plugin/rootcoverage/RootCoveragePlugin.kt +++ b/plugin/src/main/kotlin/org/neotech/plugin/rootcoverage/RootCoveragePlugin.kt @@ -5,6 +5,7 @@ import com.android.build.api.artifact.ScopedArtifact import com.android.build.api.dsl.BuildType import com.android.build.api.variant.AndroidComponentsExtension import com.android.build.api.variant.ScopedArtifacts +import com.android.build.api.variant.ScopedArtifactsOperation import com.android.build.api.variant.Variant import com.android.build.gradle.BaseExtension import org.gradle.api.GradleException @@ -12,6 +13,7 @@ import org.gradle.api.NamedDomainObjectContainer import org.gradle.api.Plugin import org.gradle.api.Project import org.gradle.api.Task +import org.gradle.api.file.RegularFile import org.gradle.api.tasks.TaskProvider import org.gradle.api.tasks.testing.Test import org.gradle.testing.jacoco.plugins.JacocoPlugin @@ -164,7 +166,6 @@ class RootCoveragePlugin : Plugin { sourceDirectories.from(variant.sources.java?.all) - val taskProvider = variant.artifacts.forScope(ScopedArtifacts.Scope.PROJECT).use( project.tasks.named(this.name) as TaskProvider ) diff --git a/plugin/src/main/kotlin/org/neotech/plugin/rootcoverage/utilities/ProjectExtensions.kt b/plugin/src/main/kotlin/org/neotech/plugin/rootcoverage/utilities/ProjectExtensions.kt index d05441b..4a300ad 100644 --- a/plugin/src/main/kotlin/org/neotech/plugin/rootcoverage/utilities/ProjectExtensions.kt +++ b/plugin/src/main/kotlin/org/neotech/plugin/rootcoverage/utilities/ProjectExtensions.kt @@ -1,9 +1,19 @@ package org.neotech.plugin.rootcoverage.utilities import org.gradle.api.Project +import org.gradle.api.file.Directory +import org.gradle.api.file.RegularFile +import org.gradle.api.provider.Provider import java.io.File /** - * Returns the output report path composed from the given [fileName] as a [File]. + * Returns the output report file composed from the given [fileName] as a [RegularFile]. */ -internal fun Project.getReportOutputFile(fileName: String): File = file("$buildDir/reports/$fileName") +internal fun Project.getReportOutputFile(fileName: String): Provider = + layout.buildDirectory.file("reports/$fileName") + +/** + * Returns the output report path composed from the given [directory] as a [Directory]. + */ +internal fun Project.getReportOutputDir(directory: String): Provider = + layout.buildDirectory.dir("reports/$directory") diff --git a/plugin/src/test/kotlin/org/neotech/plugin/rootcoverage/IntegrationTest.kt b/plugin/src/test/kotlin/org/neotech/plugin/rootcoverage/IntegrationTest.kt index 3d623ef..ea069a4 100644 --- a/plugin/src/test/kotlin/org/neotech/plugin/rootcoverage/IntegrationTest.kt +++ b/plugin/src/test/kotlin/org/neotech/plugin/rootcoverage/IntegrationTest.kt @@ -230,7 +230,7 @@ class IntegrationTest( val fixture = File("src/test/test-fixtures/multi-module") - val gradleVersions = arrayOf("8.4") + val gradleVersions = arrayOf("8.7", "8.10") val configurations = File(fixture, "configurations").listFiles() ?: error("Configurations folder not found in $fixture") return configurations.flatMap { configuration ->