diff --git a/demo-project/build.gradle.kts b/demo-project/build.gradle.kts
index 1ea187b..93484bf 100644
--- a/demo-project/build.gradle.kts
+++ b/demo-project/build.gradle.kts
@@ -49,7 +49,7 @@ tasks.jacocoAggregatedReport {
}
val reportsSpec = copySpec {
- val tookRegEx = "\\b\\d+\\.\\d+s\\b".toRegex()
+ val tookRegEx = "\\b\\d+(?:\\.\\d+)?s\\b".toRegex()
from(tasks.jacocoAggregatedReport) { include("**/*.csv") }
from(tasks.testAggregatedReport) {
diff --git a/demo-project/kmp/build.gradle.kts b/demo-project/kmp/build.gradle.kts
index 6a18942..f20cc3b 100644
--- a/demo-project/kmp/build.gradle.kts
+++ b/demo-project/kmp/build.gradle.kts
@@ -1,5 +1,4 @@
import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootExtension
-import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootPlugin
import org.jetbrains.kotlin.gradle.targets.js.yarn.YarnRootExtension
plugins {
diff --git a/demo-project/specs/aggregated-reports/tests/classes/com.example.kmp.KMPObjectTest.html b/demo-project/specs/aggregated-reports/tests/classes/com.example.kmp.KMPObjectTest.html
index f46c5ae..ddbe37c 100644
--- a/demo-project/specs/aggregated-reports/tests/classes/com.example.kmp.KMPObjectTest.html
+++ b/demo-project/specs/aggregated-reports/tests/classes/com.example.kmp.KMPObjectTest.html
@@ -90,7 +90,7 @@
Tests
testKMPObject |
testKMPObject |
-0s |
+0.100s |
passed |
diff --git a/demo-project/ui-tests/build.gradle.kts b/demo-project/ui-tests/build.gradle.kts
index ece49a6..ad9d6ba 100644
--- a/demo-project/ui-tests/build.gradle.kts
+++ b/demo-project/ui-tests/build.gradle.kts
@@ -14,7 +14,7 @@ android {
minSdk = libs.versions.android.minSDK.get().toInt()
}
- targetProjectPath = projects.demoProject.app.dependencyProject.path
+ targetProjectPath = projects.demoProject.app.path
defaultConfig {
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
diff --git a/plugin/src/main/kotlin/io/github/gmazzo/android/test/aggregation/AndroidTestBaseAggregationPlugin.kt b/plugin/src/main/kotlin/io/github/gmazzo/android/test/aggregation/AndroidTestBaseAggregationPlugin.kt
index 57ebe9d..9b3789f 100644
--- a/plugin/src/main/kotlin/io/github/gmazzo/android/test/aggregation/AndroidTestBaseAggregationPlugin.kt
+++ b/plugin/src/main/kotlin/io/github/gmazzo/android/test/aggregation/AndroidTestBaseAggregationPlugin.kt
@@ -2,7 +2,6 @@
package io.github.gmazzo.android.test.aggregation
-import com.android.build.api.dsl.BuildType
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.plugins.ExtensionAware
diff --git a/plugin/src/main/kotlin/io/github/gmazzo/android/test/aggregation/AndroidTestCoverageAggregationPlugin.kt b/plugin/src/main/kotlin/io/github/gmazzo/android/test/aggregation/AndroidTestCoverageAggregationPlugin.kt
index 649363e..9322d54 100644
--- a/plugin/src/main/kotlin/io/github/gmazzo/android/test/aggregation/AndroidTestCoverageAggregationPlugin.kt
+++ b/plugin/src/main/kotlin/io/github/gmazzo/android/test/aggregation/AndroidTestCoverageAggregationPlugin.kt
@@ -6,6 +6,7 @@ import com.android.build.api.artifact.ScopedArtifact
import com.android.build.api.variant.HasUnitTest
import com.android.build.api.variant.ScopedArtifacts
import com.android.build.api.variant.Variant
+import com.android.build.gradle.tasks.factory.AndroidUnitTest
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.artifacts.type.ArtifactTypeDefinition
@@ -17,9 +18,7 @@ import org.gradle.api.attributes.VerificationType
import org.gradle.api.file.Directory
import org.gradle.api.file.DuplicatesStrategy
import org.gradle.api.file.RegularFile
-import org.gradle.api.internal.provider.Providers
import org.gradle.api.plugins.ExtensionAware
-import org.gradle.api.provider.Provider
import org.gradle.api.tasks.Sync
import org.gradle.api.tasks.TaskProvider
import org.gradle.api.tasks.testing.AbstractTestTask
@@ -35,9 +34,7 @@ import org.gradle.kotlin.dsl.property
import org.gradle.kotlin.dsl.provideDelegate
import org.gradle.kotlin.dsl.registering
import org.gradle.kotlin.dsl.the
-import org.gradle.kotlin.dsl.invoke
import org.gradle.testing.jacoco.plugins.JacocoTaskExtension
-import org.jetbrains.kotlin.gradle.plugin.KotlinCompilation
import org.jetbrains.kotlin.gradle.plugin.KotlinCompilation.Companion.MAIN_COMPILATION_NAME
abstract class AndroidTestCoverageAggregationPlugin : Plugin {
@@ -201,6 +198,11 @@ abstract class AndroidTestCoverageAggregationPlugin : Plugin {
}
private val TaskProvider.execData
- get() = map { it.the().destinationFile!! }
+ get() = map {
+ when (it) {
+ is AndroidUnitTest -> it.jacocoCoverageOutputFile
+ else -> it.the().destinationFile
+ }
+ }
}
diff --git a/plugin/src/main/kotlin/io/github/gmazzo/android/test/aggregation/AndroidTestResultsAggregationPlugin.kt b/plugin/src/main/kotlin/io/github/gmazzo/android/test/aggregation/AndroidTestResultsAggregationPlugin.kt
index db682ad..76be0fd 100644
--- a/plugin/src/main/kotlin/io/github/gmazzo/android/test/aggregation/AndroidTestResultsAggregationPlugin.kt
+++ b/plugin/src/main/kotlin/io/github/gmazzo/android/test/aggregation/AndroidTestResultsAggregationPlugin.kt
@@ -3,7 +3,6 @@ package io.github.gmazzo.android.test.aggregation
import com.android.build.api.variant.HasUnitTest
import org.gradle.api.Plugin
import org.gradle.api.Project
-import org.gradle.api.Task
import org.gradle.api.attributes.Category
import org.gradle.api.attributes.TestSuiteType
import org.gradle.api.attributes.Usage
diff --git a/plugin/src/main/kotlin/io/github/gmazzo/android/test/aggregation/InternalDSL.kt b/plugin/src/main/kotlin/io/github/gmazzo/android/test/aggregation/InternalDSL.kt
index 5cd8811..7afe98b 100644
--- a/plugin/src/main/kotlin/io/github/gmazzo/android/test/aggregation/InternalDSL.kt
+++ b/plugin/src/main/kotlin/io/github/gmazzo/android/test/aggregation/InternalDSL.kt
@@ -7,20 +7,17 @@ import com.android.build.gradle.BaseExtension
import org.gradle.api.Project
import org.gradle.api.artifacts.Configuration
import org.gradle.api.tasks.testing.AbstractTestTask
-import org.gradle.configurationcache.extensions.capitalized
import org.gradle.kotlin.dsl.aggregateTestCoverage
import org.gradle.kotlin.dsl.create
import org.gradle.kotlin.dsl.findByType
import org.gradle.kotlin.dsl.get
-import org.gradle.kotlin.dsl.withType
import org.gradle.kotlin.dsl.getByName
import org.gradle.kotlin.dsl.named
import org.gradle.kotlin.dsl.testAggregation
import org.gradle.kotlin.dsl.the
+import org.gradle.kotlin.dsl.withType
import org.jetbrains.kotlin.gradle.plugin.KotlinTarget
import org.jetbrains.kotlin.gradle.plugin.KotlinTargetsContainer
-import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinAndroidTarget
-import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinMetadataTarget
import org.jetbrains.kotlin.gradle.targets.jvm.KotlinJvmTarget
internal val Project.android
@@ -64,7 +61,7 @@ internal fun TestAggregationExtension.aggregateProject(project: Project, config:
config.dependencies.add(project.dependencies.testAggregation(project))
private fun TestAggregationExtension.Modules.includes(project: Project) =
- (includes.get().isEmpty() || project in includes.get()) && project !in excludes.get()
+ (includes.get().isEmpty() || project.path in includes.get()) && project.path !in excludes.get()
internal fun Project.unitTestTaskOf(variant: Variant) = (variant as? HasUnitTest)
?.unitTest
diff --git a/plugin/src/main/kotlin/io/github/gmazzo/android/test/aggregation/TestAggregationExtension.kt b/plugin/src/main/kotlin/io/github/gmazzo/android/test/aggregation/TestAggregationExtension.kt
index 3bfa66d..a907d30 100644
--- a/plugin/src/main/kotlin/io/github/gmazzo/android/test/aggregation/TestAggregationExtension.kt
+++ b/plugin/src/main/kotlin/io/github/gmazzo/android/test/aggregation/TestAggregationExtension.kt
@@ -19,31 +19,37 @@ abstract class TestAggregationExtension {
*/
abstract class Modules {
- abstract val includes: SetProperty
+ /**
+ * List of [Project.getPath] that should be included in the aggregation. If empty, all projects are included
+ */
+ abstract val includes: SetProperty
- abstract val excludes: SetProperty
+ /**
+ * List of [Project.getPath] that should be excluded from the aggregation
+ */
+ abstract val excludes: SetProperty
fun include(vararg includes: Project) = apply {
- this.includes.addAll(*includes)
+ this.includes.addAll(includes.map { it.path })
}
fun include(includes: Iterable) = apply {
- this.includes.addAll(includes)
+ this.includes.addAll(includes.map { it.path })
}
fun include(vararg includes: ProjectDependency) =
- include(includes.map { it.dependencyProject })
+ this.includes.addAll(includes.map { it.path })
fun exclude(vararg excludes: Project) = apply {
- this.excludes.addAll(*excludes)
+ this.excludes.addAll(excludes.map { it.path })
}
fun exclude(excludes: Iterable) = apply {
- this.excludes.addAll(excludes)
+ this.excludes.addAll(excludes.map { it.path })
}
fun exclude(vararg excludes: ProjectDependency) =
- exclude(excludes.map { it.dependencyProject })
+ this.excludes.addAll(excludes.map { it.path })
}
diff --git a/plugin/src/main/kotlin/org/gradle/kotlin/dsl/TestAggregationDSL.kt b/plugin/src/main/kotlin/org/gradle/kotlin/dsl/TestAggregationDSL.kt
index a2cd496..e9347b5 100644
--- a/plugin/src/main/kotlin/org/gradle/kotlin/dsl/TestAggregationDSL.kt
+++ b/plugin/src/main/kotlin/org/gradle/kotlin/dsl/TestAggregationDSL.kt
@@ -7,19 +7,21 @@ import org.gradle.api.artifacts.Dependency
import org.gradle.api.artifacts.ProjectDependency
import org.gradle.api.artifacts.dsl.DependencyHandler
import org.gradle.api.attributes.Usage
+import org.gradle.api.internal.artifacts.dependencies.AbstractModuleDependency
import org.gradle.api.plugins.ExtensionAware
import org.gradle.api.provider.Property
-import org.jetbrains.kotlin.gradle.plugin.KotlinTarget
import org.jetbrains.kotlin.gradle.targets.jvm.KotlinJvmTarget
const val USAGE_TEST_AGGREGATION = "test-aggregation"
fun DependencyHandler.testAggregation(dependency: Any): Dependency = create(dependency).also {
(it as? ProjectDependency)?.apply {
- UsageTestAggregationCompatibilityRule.bind(dependencyProject)
+ val objects = (this as AbstractModuleDependency).objectFactory
+
+ UsageTestAggregationCompatibilityRule.bind(attributesSchema)
attributes {
- attribute(Usage.USAGE_ATTRIBUTE, dependencyProject.objects.named(USAGE_TEST_AGGREGATION))
+ attribute(Usage.USAGE_ATTRIBUTE, objects.named(USAGE_TEST_AGGREGATION))
}
}
}