-
Notifications
You must be signed in to change notification settings - Fork 432
JacocoPluginExtension::applyTo can not be called from Kotlin #458
Comments
This is the workaround code that I'm using and I know works: /**
* Workaround fix for calling [org.gradle.testing.jacoco.plugins.JacocoPluginExtension.applyTo]
*
* [Issue details here](https://github.com/gradle/kotlin-dsl/issues/458)
*/
fun org.gradle.testing.jacoco.plugins.JacocoPluginExtension.applyToHelper(task : Task) {
val method = this::class.java.getMethod("applyTo", Task::class.java)
method.invoke(this, task)
} |
I think that this has been resolved? Not entirely sure. Are you waiting to close this until after there is a Gradle release with this fix? |
In hindsight, this may have simply been my problem, not an issue with the compiler. In my original example this didn't work which is sane because of the compiler: jacoco {
applyTo(tasks.getByName("junitPlatformTest") as Task)
} This, on the other hand does work: jacoco {
applyTo(tasks.getByName("junitPlatformTest") as JavaExec)
} Similarly, this didn't work: jacoco {
applyTo(tasks.matching { name == "junitPlatformTest" } as TaskCollection<*>)
} But this does work: jacoco {
applyTo<JavaExec>(tasks.matching { name == "junitPlatformTest" })
} The API in Gradle did need to be updated though. So we did the right thing there. |
Thanks @JLLeitschuh for following up! The Gradle API has not seen any recent changes wrt this issue. I believe it already worked as described in your last comment. Closing |
@eskatos there is a related change pending on Gradle that I intended to follow up on: gradle/gradle@40d0906 |
By mentioning the type parameter `T` in the parameter list so it can be inferred by a capable compiler. See gradle/kotlin-dsl-samples#458
By mentioning the type parameter `T` in the parameter list so it can be inferred by a capable compiler. See gradle/kotlin-dsl-samples#458
Fixed in upstream Gradle by gradle/gradle@f8f8618 Closing |
Expected Behavior
Ability to call:
OR:
OR:
OR:
jacoco { applyTo(tasks.getByName("junitPlatformTest")) }
This same problem exists even if you try wrapping the method names in backticks.
Current Behavior
When calling the
applyTo
with the signature<T extends Task & JavaForkOptions> void applyTo(TaskCollection tasks)
:When calling the
applyTo
with the signature<T extends Task & JavaForkOptions> void applyTo(final T task)
:Context
I'm trying to configure Jacoco to run with Junit 5
Steps to Reproduce (for bugs)
See above.
Your Environment
Gradle version:
4.1
.The text was updated successfully, but these errors were encountered: