flyway icon indicating copy to clipboard operation
flyway copied to clipboard

Support Gradle configuration cache

Open steven-sheehy opened this issue 5 months ago • 5 comments

The Flyway plugin does not support the Gradle configuration cache. With Gradle 9.0, the configuration cache becomes the default execution mode. Gradle states we should "prepare for a future where it becomes the only supported mode." There was a previous issue https://github.com/flyway/flyway/issues/3550 closed as not planned, but perhaps with this new importance being placed on the configuration cache by Gradle the maintainers can reconsider.

Workarounds like tasks.withType<AbstractFlywayTask> { notCompatibleWithConfigurationCache("") } also don't seem to work in my Gradle build.

- Task `:app:flywayMigrate` of type `org.flywaydb.gradle.task.FlywayMigrateTask`: invocation of 'Task.project' at execution time is unsupported.
  See https://docs.gradle.org/8.14/userguide/configuration_cache.html#config_cache:requirements:use_project_during_execution

steven-sheehy avatar Jul 15 '25 00:07 steven-sheehy

With Gradle 9.0, running ./gradlew flywayMigrate doesn't work anymore if configuration cache is on:

* What went wrong:
Execution failed for task ':flywayMigrate'.
> Error occurred while executing flywayMigrate
  Unable to connect to the database. Configure the url, user and password!

Turning configuration cache off makes it work: ./gradlew -Dorg.gradle.configuration-cache=false flywayMigrate

akheron avatar Aug 05 '25 10:08 akheron

Is there any workaround for a Gradle script? as @steven-sheehy said notCompatibleWithConfigurationCache is not working.

akhial avatar Aug 24 '25 12:08 akhial

My workaround was to remove the Flyway Gradle plugin and just use Flyway.migrate() directly in a doFirst or doLast. The plugin does almost nothing except wrap the flyway operations so it's easy to invoke. This is apparently what some blogs are recommending as well.

steven-sheehy avatar Aug 25 '25 15:08 steven-sheehy

Any news on a fix? As configuration cache will be the default in gradle 10, many user will probably have a problem.

laurentthiebaudezm avatar Sep 26 '25 08:09 laurentthiebaudezm

Invocation of Task.project at execution time has been deprecated. This will fail with an error in Gradle 10. This API is incompatible with the configuration cache, which will become the only mode supported by Gradle in a future release. Consult the upgrading guide for further information: https://docs.gradle.org/9.2.0/userguide/upgrading_version_7.html#task_project

This should be adressed as builds will error out in Gradle 10.

jordanamr avatar Nov 03 '25 00:11 jordanamr