Skip to content

Commit

Permalink
Replace AGP-internal interface to achieve better compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
mannodermaus committed Oct 28, 2018
1 parent 76f4121 commit c7c52b9
Showing 1 changed file with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package de.mannodermaus.gradle.plugins.junit5.tasks

import com.android.build.gradle.api.BaseVariant
import com.android.build.gradle.internal.scope.TaskConfigAction
import de.mannodermaus.gradle.plugins.junit5.internal.android
import de.mannodermaus.gradle.plugins.junit5.internal.extensionByName
import de.mannodermaus.gradle.plugins.junit5.internal.junit5Info
Expand Down Expand Up @@ -34,7 +33,9 @@ open class AndroidJUnit5JacocoReport : JacocoReport() {
testTask: Test,
directoryProviders: Collection<DirectoryProvider>): AndroidJUnit5JacocoReport {
val configAction = ConfigAction(project, variant, testTask, directoryProviders)
return project.tasks.create(configAction.name, configAction.type, configAction)
return project.tasks.create(configAction.name, configAction.type) {
configAction.execute(it)
}
}
}

Expand All @@ -46,15 +47,15 @@ open class AndroidJUnit5JacocoReport : JacocoReport() {
val variant: BaseVariant,
val testTask: Test,
private val directoryProviders: Collection<DirectoryProvider>
) : TaskConfigAction<AndroidJUnit5JacocoReport> {
) {

private val scope = variant.variantData.scope

override fun getName(): String = scope.getTaskName(TASK_NAME_DEFAULT)
val name: String = scope.getTaskName(TASK_NAME_DEFAULT)

override fun getType() = AndroidJUnit5JacocoReport::class.java
val type = AndroidJUnit5JacocoReport::class.java

override fun execute(reportTask: AndroidJUnit5JacocoReport) {
fun execute(reportTask: AndroidJUnit5JacocoReport) {
// Project-level configuration
reportTask.dependsOn(testTask)
reportTask.group = GROUP_REPORTING
Expand Down

1 comment on commit c7c52b9

@drd
Copy link

@drd drd commented on c7c52b9 Oct 30, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! 🙌

Please sign in to comment.