Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incompatible with the configuration cache (Round 2) #366

Open
jbduncan opened this issue Jan 24, 2025 · 1 comment
Open

Incompatible with the configuration cache (Round 2) #366

jbduncan opened this issue Jan 24, 2025 · 1 comment
Labels
bug Something isn't working

Comments

@jbduncan
Copy link
Contributor

jbduncan commented Jan 24, 2025

What version of OpenRewrite are you using?

I am using

  • Gradle plugin v7.0.4

No recipes are necessary to reproduce this issue.

How are you running OpenRewrite?

I am using the Gradle plugin, and my project is a single module project.

My minimal reproducer comprises of these files.

build.gradle.kts

plugins {
    id("org.openrewrite.rewrite") version "7.0.4"
}

group = "org.example"
version = "1.0-SNAPSHOT"

repositories {
    mavenCentral()
}

tasks.register<Task>("test") {
    doLast {
        println("Running unit tests...")
        Thread.sleep(1_000L)
        println("Unit tests succeeded")
    }
}

tasks.register<Task>("integrationTest") {
    doLast {
        println("Running integration tests...")
        Thread.sleep(1_000L)
        println("Integration tests succeeded")
    }
}

tasks.register<Task>("check") {
    dependsOn("test", "integrationTest", "rewriteDryRun")
}

gradle.properties

org.gradle.configuration-cache=true

settings.gradle.kts

rootProject.name = "openrewrite-gradle-plugin-configuration-cache-reproducer"
enableFeaturePreview("STABLE_CONFIGURATION_CACHE")

What is the smallest, simplest way to reproduce the problem?

Run the above project files on Gradle 8.12.1 and Java 21 (I suspect other versions of Gradle and Java work, too). Use the command ./gradlew check.

What did you expect to see?

The tasks test, integrationTest and rewriteDryRun should run in parallel.

If I configure check to just depend on test and integrationTest, it takes just over 1 second to run because each task takes 1 second to run and the configuration cache lets them run in parallel. For example:

Expected logs
$ ./gradlew check
Calculating task graph as no cached configuration is available for tasks: check

> Task :test
Running unit tests...
Unit tests succeeded

> Task :integrationTest
Running integration tests...
Integration tests succeeded

BUILD SUCCESSFUL in 1s
2 actionable tasks: 2 executed
Configuration cache entry stored.

What did you see instead?

When running check as above (depending on test, integrationTest and rewriteDryRun), the tasks run sequentially and configuration cache problems are reported, like so:

Actual logs
$ ./gradlew check
Calculating task graph as configuration cache cannot be reused because file 'build.gradle.kts' has changed.

> Task :integrationTest
Running integration tests...
Integration tests succeeded

> Task :rewriteDryRun
No recipes were activated. Activate a recipe with rewrite.activeRecipe("com.fully.qualified.RecipeClassName") in your build file, or on the command line with -DactiveRecipe=com.fully.qualified.RecipeClassName
Applying recipes would make no changes. No report generated.

> Task :test
Running unit tests...
Unit tests succeeded

2 problems were found storing the configuration cache.
- Task `:rewriteDryRun` of type `org.openrewrite.gradle.RewriteDryRunTask`: cannot serialize object of type 'org.gradle.api.internal.project.DefaultProject', a subtype of 'org.gradle.api.Project', as these are not supported with the configuration cache.
  See https://docs.gradle.org/8.12.1/userguide/configuration_cache.html#config_cache:requirements:disallowed_types
- Task `:rewriteDryRun` of type `org.openrewrite.gradle.RewriteDryRunTask`: invocation of 'Task.project' at execution time is unsupported.
  See https://docs.gradle.org/8.12.1/userguide/configuration_cache.html#config_cache:requirements:use_project_during_execution

See the complete report at file:///Users/jonathan.bluett-dunc/dev/openrewrite-gradle-plugin-configuration-cache-reproducer/build/reports/configuration-cache/9yj95qyh2pztrmbx6nutad2pr/ddgoq81bh219dx2b3f22zgeb6/configuration-cache-report.html

[Incubating] Problems report is available at: file:///Users/jonathan.bluett-dunc/dev/openrewrite-gradle-plugin-configuration-cache-reproducer/build/reports/problems/problems-report.html

BUILD SUCCESSFUL in 5s
3 actionable tasks: 3 executed
Configuration cache entry discarded with 2 problems.

What is the full stack trace of any errors you encountered?

No stack trace is reported when running ./gradlew check --stacktrace.

Are you interested in contributing a fix to OpenRewrite?

I'm not sure if I'll have time, but if so, then yes I'd love to!

@jbduncan jbduncan added the bug Something isn't working label Jan 24, 2025
@timtebeek timtebeek moved this to Backlog in OpenRewrite Feb 5, 2025
@timtebeek
Copy link
Contributor

Thanks for chiming back in here with a clear reproducer! Would indeed help performance for repeated runs if we managed to get this sorted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Backlog
Development

No branches or pull requests

2 participants