Skip to content

Commit 8efcbeb

Browse files
staktracesvc-squareup-copybara
authored andcommitted
Turn on gradle caching for JooqGenerate
GitOrigin-RevId: 59bfc81c5f828d6d644afa5057d6b5e661d7c81b
1 parent 9588fb2 commit 8efcbeb

File tree

2 files changed

+22
-5
lines changed

2 files changed

+22
-5
lines changed

misk-jooq/README.md

+11-3
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,15 @@ plugins {
2424
alias(libs.plugins.flyway)
2525
alias(libs.plugins.jooq)
2626
}
27+
val dbMigrations = "src/main/resources/db-migrations"
2728
// We are using flyway here in order to run the migrations to create a schema.
2829
// Ensure the migration directory is not called `migrations`. There's more details as to why below.
2930
flyway {
3031
url = "jdbc:mysql://localhost:3500/misk-jooq-test-codegen"
3132
user = "root"
3233
password = "root"
3334
schemas = arrayOf("jooq")
34-
locations = arrayOf("filesystem:${project.projectDir}/src/main/resources/db-migrations")
35+
locations = arrayOf("filesystem:${project.projectDir}/${dbMigrations}")
3536
sqlMigrationPrefix = "v"
3637
}
3738
// More details about the jooq plugin here - https://github.com/etiennestuder/gradle-jooq-plugin
@@ -73,8 +74,15 @@ jooq {
7374
}
7475
7576
// Needed to generate jooq test db classes
76-
tasks.named("generateJooq") {
77+
tasks.withType<nu.studer.gradle.jooq.JooqGenerate>().configureEach {
7778
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)
7886
}
7987
8088
// Needed to generate jooq test db classes
@@ -162,4 +170,4 @@ ctx.select()
162170
[migrations](https://github.com/jOOQ/jOOQ/tree/main/jOOQ/src/main/resources/migrations)
163171
we don't care about in it. When the service starts up it finds this folder as well and tries
164172
to run those migrations. Renaming misk service migrations to somethinq like `db-migrations` works.
165-
173+

misk-jooq/build.gradle.kts

+11-2
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,15 @@ dependencies {
3535
jooqGenerator(libs.mysql)
3636
}
3737

38+
val dbMigrations = "src/test/resources/db-migrations"
39+
3840
// Needed to generate jooq test db classes
3941
flyway {
4042
url = "jdbc:mysql://localhost:3500/misk-jooq-test-codegen"
4143
user = "root"
4244
password = "root"
4345
schemas = arrayOf("jooq")
44-
locations = arrayOf("filesystem:${project.projectDir}/src/test/resources/db-migrations")
46+
locations = arrayOf("filesystem:${project.projectDir}/${dbMigrations}")
4547
sqlMigrationPrefix = "v"
4648
}
4749
// Needed to generate jooq test db classes
@@ -83,8 +85,15 @@ jooq {
8385
}
8486

8587
// Needed to generate jooq test db classes
86-
tasks.named("generateJooq") {
88+
tasks.withType<nu.studer.gradle.jooq.JooqGenerate>().configureEach {
8789
dependsOn("flywayMigrate")
90+
91+
// declare migration files as inputs on the jOOQ task and allow it to
92+
// participate in build caching
93+
inputs.files(fileTree(layout.projectDirectory.dir(dbMigrations)))
94+
.withPropertyName("migrations")
95+
.withPathSensitivity(PathSensitivity.RELATIVE)
96+
allInputsDeclared.set(true)
8897
}
8998

9099
// Needed to generate jooq test db classes

0 commit comments

Comments
 (0)