unbroken-dome / gradle-testsets-plugin

A plugin for the Gradle build system that allows specifying test sets (like integration or acceptance tests).
MIT License
230 stars 50 forks source link

TestSetBase uses deprecated API which gets removed in Gradle 7.0 #117

Closed cpiotr closed 3 years ago

cpiotr commented 3 years ago

TestSetBase class calls sourceSet.compileConfigurationName: https://github.com/unbroken-dome/gradle-testsets-plugin/blob/1c6fc3fa1d23af767c6c6fb276308adf89aaf2e9/src/main/kotlin/org/unbrokendome/gradle/plugins/testsets/dsl/TestSetBase.kt#L74 This method has been removed in Gradle 7: https://github.com/gradle/gradle/blob/v7.0.0-RC2/subprojects/plugins/src/main/java/org/gradle/api/tasks/SourceSet.java

The use of problematic API causes the following build script:

plugins {
    id "org.unbroken-dome.test-sets" version "3.0.1"
}

apply plugin: 'java'

testSets {
    benchmark
}

to fail with the following message:

FAILURE: Build failed with an exception.

* Where:
Build file './failure-test/build.gradle' line: 8

* What went wrong:
A problem occurred evaluating root project 'failure-test'.
> 'java.lang.String org.gradle.api.tasks.SourceSet.getCompileConfigurationName()'

* Try:
Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Exception is:
org.gradle.api.GradleScriptException: A problem occurred evaluating root project 'failure-test'.
        at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:93)
        at org.gradle.configuration.DefaultScriptPluginFactory$ScriptPluginImpl.lambda$apply$0(DefaultScriptPluginFactory.java:133)
        at org.gradle.configuration.ProjectScriptTarget.addConfiguration(ProjectScriptTarget.java:77)
        at org.gradle.configuration.DefaultScriptPluginFactory$ScriptPluginImpl.apply(DefaultScriptPluginFactory.java:136)
        at org.gradle.configuration.BuildOperationScriptPlugin$1.run(BuildOperationScriptPlugin.java:65)
        at org.gradle.internal.operations.DefaultBuildOperationRunner$1.execute(DefaultBuildOperationRunner.java:29)
        at org.gradle.internal.operations.DefaultBuildOperationRunner$1.execute(DefaultBuildOperationRunner.java:26)
       ...
Caused by: java.lang.NoSuchMethodError: 'java.lang.String org.gradle.api.tasks.SourceSet.getCompileConfigurationName()'
        at org.unbrokendome.gradle.plugins.testsets.dsl.TestSetBase$DefaultImpls.getCompileConfigurationName(TestSetBase.kt:74)
        at org.unbrokendome.gradle.plugins.testsets.dsl.AbstractTestSetBase.getCompileConfigurationName(TestSetBase.kt:177)
        at org.unbrokendome.gradle.plugins.testsets.dsl.DefaultTestSet_Decorated.getCompileConfigurationName(Unknown Source)
        at org.unbrokendome.gradle.plugins.testsets.internal.ConfigurationObserver$Companion$inheritedConfigurationNames$1.get(ConfigurationObserver.kt:15)
        at kotlin.jvm.internal.PropertyReference1.invoke(PropertyReference1.java:35)
        at org.unbrokendome.gradle.plugins.testsets.internal.ConfigurationObserver.addConfigurationExtension(ConfigurationObserver.kt:55)
        at org.unbrokendome.gradle.plugins.testsets.internal.ConfigurationObserver.extendsFromAdded(ConfigurationObserver.kt:26)
        at org.unbrokendome.gradle.plugins.testsets.dsl.AbstractTestSetBase.addObserver(TestSetBase.kt:258)
        at org.unbrokendome.gradle.plugins.testsets.dsl.TestSetBaseInternal.addObservers(TestSetBase.kt:168)
        at org.unbrokendome.gradle.plugins.testsets.dsl.TestSetBaseInternal.addObservers$default(TestSetBase.kt:167)
        at org.unbrokendome.gradle.plugins.testsets.TestSetsPlugin$apply$1.execute(TestSetsPlugin.kt:62)
        at org.unbrokendome.gradle.plugins.testsets.TestSetsPlugin$apply$1.execute(TestSetsPlugin.kt:33)
        at org.gradle.internal.ImmutableActionSet$SetWithFewActions.execute(ImmutableActionSet.java:285)

Setup:

$ ./gradlew --version         

------------------------------------------------------------
Gradle 7.0-rc-1
------------------------------------------------------------

Build time:   2021-03-23 01:02:30 UTC
Revision:     f5bf7ade373b74058e49f07749083b4c3075549a

Kotlin:       1.4.31
Groovy:       3.0.7
Ant:          Apache Ant(TM) version 1.10.9 compiled on September 27 2020
JVM:          16 (AdoptOpenJDK 16+36)
OS:           Linux 5.4.0-70-generic amd64
binkley commented 3 years ago

What is the timeline to release the commits which address this?

It is blocking upgrading to Gradle 7.0 (release version) for my projects (ie, https://github.com/binkley/modern-java-practices) and is now manifesting as a CVE for commons-io 2.6 from the older PMD plugin bundled with Gradle 6.x which to fix needs Gradle 7.0.

If there are instructions for using a published SNAPSHOT-type build, I'd happy to try that out, but didn't see any directions in README.md. I experimented with jitpack.io, but wasn't sure how to get Gradle to use that for a plugin.

cpiotr commented 3 years ago

Fix available in https://github.com/unbroken-dome/gradle-testsets-plugin/releases/tag/v4.0.0 Thanks @tkrullmann!