gradleliquibaseincremental-build

Gradle liquibase plugin incremental build issue


I am using the liquibase plugin. I want it to participate in incremental builds, so I defined:

tasks.withType(org.liquibase.gradle.LiquibaseTask) {
//for incremental builds
outputs.dirs("$rootDir/liquibase/src/main/resources", 'build/generated')
}

Everything works fine, except that after I do a ./gradlew clean (which deletes the build/generated directory), the task is still considered UP-TO-DATE, so it doesn't execute again the migrations.

Full context of the issue: I am using the docker avast plugin, I am spinning up a PostgreSQL database, I run the liquibase update (db is empty, so all the migrations should run), then I use jooq codegen to generate Java classes based on the schema (they are generated in build/generated). The other tasks (composeUp, generateJooq) have the same outputs.dirs gradle configuration, but after I execute ./gradlew clean they are re-executed.


Solution

  • I fixed it by creating a dummy file in each task, define it as an output file and use that as an input for the next task.