Skip to content

Conversation

@timtebeek
Copy link
Member

Use this link to re-run the recipe: https://app.moderne.io/builder/Sh3Bg6DMd?organizationId=QUxML09wZW4gU291cmNlL09wZW5SZXdyaXRl

Co-authored-by: Moderne <team@moderne.io>
@github-project-automation github-project-automation bot moved this to In Progress in OpenRewrite Oct 29, 2025
@timtebeek timtebeek self-assigned this Oct 29, 2025
@greg-at-moderne
Copy link
Contributor

1261 tests completed, 2 failed, 9 skipped

One is:

CleanupMockitoImportsTest > doNotRemoveMockitoImportsForKotlin() FAILED
    java.lang.IllegalStateException: LST contains missing or invalid type information
    MethodInvocation->Block->MethodDeclaration->Block->ClassDeclaration->CompilationUnit
    /*~~(MethodInvocation type is missing or malformed)~~>*/org.mockito.Mockito.mock(Foo::class.java)

The other one is:

GradleUseJunitJupiterTest > tasksWithTypeTest() FAILED
    org.opentest4j.AssertionFailedError: [Unexpected result in "build.gradle":
[...]
    expected: 
      "plugins {
          id 'java'
      }
      tasks.withType(Test) {
          useJUnitPlatform()
      }"
     but was: 
      "plugins {
          id 'java'
      }
      tasks.withType(Test) {
      }
      tasks.withType(Test).configureEach {
          useJUnitPlatform()
      }"

@Laurens-W
Copy link
Contributor

Laurens-W commented Oct 30, 2025

Second test failure is also due to type information on the Gradle API missing, tasks is of type java.lang.Object whilst the recipe expects org.gradle.api.tasks.TaskContainer

@timtebeek
Copy link
Member Author

Ah that might be the Gradle 9 use of Groovy 4 not quite working well for us then I suppose; let me see if we can work around the issue.

@timtebeek
Copy link
Member Author

timtebeek commented Oct 30, 2025

Hmm; I've adjusted the failing test, but that already fails on the main branch as well:

    @Test
    void tasksWithTypeTest() {
        rewriteRun(
          //language=groovy
          buildGradle(
            """
              plugins {
                  id 'java'
              }
              tasks.withType(Test) {
              }
              """,
            """
              plugins {
                  id 'java'
              }
              tasks.withType(Test) {
                  useJUnitPlatform()
              }
              """,
            spec -> spec.beforeRecipe(cu -> {
                String string = TreeVisitingPrinter.printTree(cu);
                System.out.println(string);
                JavaType tasksType = ((J.MethodInvocation) cu.getStatements().getLast()).getSelect().getType();
                assertTrue(TypeUtils.isAssignableTo("org.gradle.api.tasks.TaskContainer", tasksType), tasksType.toString());
            })
          )
        );
    }

If I pin back the plugins on the main branch then the above passes;

plugins {
    id("org.openrewrite.build.recipe-library") version "2.5.6"
    id("org.openrewrite.build.moderne-source-available-license") version "2.5.6"
}

@timtebeek timtebeek merged commit 37e86b7 into main Oct 31, 2025
2 checks passed
@timtebeek timtebeek deleted the feature/gradle-9-2-0 branch October 31, 2025 09:20
@github-project-automation github-project-automation bot moved this from In Progress to Done in OpenRewrite Oct 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants