@@ -24,14 +24,15 @@ plugins {
24
24
alias(libs.plugins.flyway)
25
25
alias(libs.plugins.jooq)
26
26
}
27
+ val dbMigrations = "src/main/resources/db-migrations"
27
28
// We are using flyway here in order to run the migrations to create a schema.
28
29
// Ensure the migration directory is not called `migrations`. There's more details as to why below.
29
30
flyway {
30
31
url = "jdbc:mysql://localhost:3500/misk-jooq-test-codegen"
31
32
user = "root"
32
33
password = "root"
33
34
schemas = arrayOf("jooq")
34
- locations = arrayOf("filesystem:${project.projectDir}/src/main/resources/db-migrations ")
35
+ locations = arrayOf("filesystem:${project.projectDir}/${dbMigrations} ")
35
36
sqlMigrationPrefix = "v"
36
37
}
37
38
// More details about the jooq plugin here - https://github.com/etiennestuder/gradle-jooq-plugin
@@ -73,8 +74,15 @@ jooq {
73
74
}
74
75
75
76
// Needed to generate jooq test db classes
76
- tasks.named("generateJooq") {
77
+ tasks.withType<nu.studer.gradle.jooq.JooqGenerate>().configureEach {
77
78
dependsOn("flywayMigrate")
79
+
80
+ // declare migration files as inputs on the jOOQ task and allow it to
81
+ // participate in build caching
82
+ inputs.files(fileTree(layout.projectDirectory.dir(dbMigrations)))
83
+ .withPropertyName("migrations")
84
+ .withPathSensitivity(PathSensitivity.RELATIVE)
85
+ allInputsDeclared.set(true)
78
86
}
79
87
80
88
// Needed to generate jooq test db classes
@@ -162,4 +170,4 @@ ctx.select()
162
170
[ migrations] ( https://github.com/jOOQ/jOOQ/tree/main/jOOQ/src/main/resources/migrations )
163
171
we don't care about in it. When the service starts up it finds this folder as well and tries
164
172
to run those migrations. Renaming misk service migrations to somethinq like ` db-migrations ` works.
165
-
173
+
0 commit comments