The Openrewrite plugin is making the sources configuration of the jvm-test-suite plugin not work
Description When I use the jvm-test-suite plugin simulation with OpenRewrite, the configuration of the testing suite sources does not work, so no tests can run.
Basic project
build.gradle file
plugins {
id 'jvm-test-suite'
id 'java'
// id 'org.openrewrite.rewrite' version "6.15.1"
}
dependencies {
implementation 'org.junit.jupiter:junit-jupiter-api:5.10.2'
}
testing {
suites {
integrationTest(JvmTestSuite) {
dependencies {
implementation project()
}
sources {
java {
srcDirs = ['src/test/java']
}
resources {
srcDirs = [ 'src/test/resources' ]
}
}
}
}
}
Steps to Reproduce
When I use two plugins, jvm-test-suite and java, and run integrationTest with the command ./gradlew integrationTest, it executes the test in the BasicTests class and shows the failed test results because the tests in BasicTests always fail. However, when I uncomment the OpenRewrite plugin in the build.gradle file and run the ./gradlew integrationTest command again, it does nothing and shows Build Successful, which means no tests were executed.
Screenshots
Environment
Openrewrite version: 6.15.1 Gradle version: 8.7 Java version: 17 junit-jupiter version: 5.10.2
Additional Context I downgraded the OpenRewrite version to 5.7.0, but the problem remains the same
Hi @thaitangluc2412 ; thanks for the detailed report; no idea what might go into that not working as expected. As a workaround you might be able to run rewrite recipes exclusively through an init script instead of adding the plugin to your build.gradle file.
What I suspect is the issue is this little block of code: https://github.com/openrewrite/rewrite-gradle-plugin/blob/main/plugin%2Fsrc%2Fmain%2Fjava%2Forg%2Fopenrewrite%2Fgradle%2FRewritePlugin.java#L122-L138
In particular, your test and integrationTest source sets are both pointing to the source folder src/test/java. If you were to run build, you should actually see your test run twice with each task based upon the configuration that you've shared here.
With the jvm-test-suite plugin, Gradle intends for you to use a different folder for each test suite (ie. src/integrationTest/java) normally. Due to the clash, the OpenRewrite plugin disabled the integration test compile task which then means the outputs from that are not available for the test task resulting in a successful build.
To expand upon Tim's earlier workaround, you either need to:
- Use separate source folders for the additional test suite(s)
- Use OpenRewrite via the init script method documented here.
NOTE: I do find it a little weird that the OpenRewrite Gradle plugin is disabling other stuff during it's configuration phase. I know why it's doing it, but doing so results in weird issues such as this one.
Given the explanation above, and lack of reply since, I don't think there's something for us to pick up and change.
Sorry for the delayed response, I missed the notification. My issue is that I created a Java convention for all my sub-projects, and every sub-project is using it (including the test parts). The problem is that any sub-project using the jvm-testsuite can't use it due to the issue mentioned above.