openrewrite / rewrite-gradle-plugin

OpenRewrite's Gradle plugin.
Apache License 2.0
60 stars 37 forks source link

OpenRewrite does not seem to support concurrent execution of Gradle tasks #244

Closed vlsi closed 10 months ago

vlsi commented 10 months ago

What version of OpenRewrite are you using?

org.openrewrite.rewrite.gradle.plugin:6.4.3

How are you running OpenRewrite?

./gradlew rewriteRun

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

See https://github.com/pgjdbc/pgjdbc/pull/2979

For instance, try running ./gradlew rewriteRun at https://github.com/pgjdbc/pgjdbc/pull/2979/commits/f816b65cd60ab12d442ac9109ff726bcd710c0af "chore: add junit5.JUnit5BestPractices and junit5.CleanupAssertions OpenRewrite recipes"

% ./gradlew rewriteRun

> Configure project :
Building pgjdbc 42.6.1-SNAPSHOT

> Task :pgjdbc-osgi-test:rewriteRun
Validating active recipes
Scanning sources in project :pgjdbc-osgi-test
Using active styles [io.github.pgjdbc.style.Style, org.openrewrite.java.Checkstyle]

> Task :benchmarks:rewriteRun
Validating active recipes
Scanning sources in project :benchmarks
Using active styles [io.github.pgjdbc.style.Style, org.openrewrite.java.Checkstyle]

> Task :postgresql:rewriteRun
Validating active recipes
Scanning sources in project :postgresql
Using active styles [io.github.pgjdbc.style.Style, org.openrewrite.java.Checkstyle]
All sources parsed, running active recipes: org.openrewrite.java.OrderImports, org.openrewrite.staticanalysis.MissingOverrideAnnotation, io.github.pgjdbc.staticanalysis.CodeCleanup, io.github.pgjdbc.staticanalysis.CommonStaticAnalysis, org.openrewrite.java.testing.junit5.JUnit5BestPractices, org.openrewrite.java.testing.junit5.CleanupAssertions
<===========--> 89% EXECUTING [2m 9s]
> :pgjdbc-osgi-test:rewriteRun > Resolve dependencies of :pgjdbc-osgi-test:rewritetestImplementation
> :benchmarks:rewriteRun > Resolve dependencies of :benchmarks:rewritejmhImplementation
> :postgresql:rewriteRun

What did you expect to see?

I expected that rewrite tasks for different projects could execute concurrently.

What did you see instead?

I captured several thread dumps during the execution of rewriteRun, and it looks like there's only one thread executing OpenRewrite, and the rest are locked.

rewriteRun_multiproject_locking.txt

Are you interested in contributing a fix to OpenRewrite?

timtebeek commented 10 months ago

Hi! Thanks for the suggestion; we have a previous discussion on this topic in

As much as I like the detail you've added here, I'll close this one since the other issue already has some more input into alternatives and what would be needed.