-
Notifications
You must be signed in to change notification settings - Fork 80
/
Copy pathbuild.gradle
69 lines (61 loc) · 2.15 KB
/
build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
plugins {
id 'org.flywaydb.flyway' version '9.7.0'
id 'nu.studer.jooq' version '9.0'
id 'java'
}
repositories {
mavenCentral()
}
configurations {
flywayMigration
}
dependencies {
flywayMigration 'com.h2database:h2:2.1.214'
jooqGenerator 'com.h2database:h2:2.1.214'
}
flyway {
configurations = ['flywayMigration']
url = 'jdbc:h2:~/test;AUTO_SERVER=TRUE'
user = 'sa'
password = ''
}
jooq {
configurations {
main {
generationTool {
logging = org.jooq.meta.jaxb.Logging.WARN
jdbc {
driver = 'org.h2.Driver'
url = flyway.url
user = flyway.user
password = flyway.password
}
generator {
name = 'org.jooq.codegen.DefaultGenerator'
database {
name = 'org.jooq.meta.h2.H2Database'
includes = '.*'
excludes = ''
}
target {
packageName = 'nu.studer.sample'
}
}
}
}
}
}
// configure jOOQ task such that it only executes when something has changed that potentially affects the generated JOOQ sources
// - the jOOQ configuration has changed (Jdbc, Generator, Strategy, etc.)
// - the classpath used to execute the jOOQ generation tool has changed (jOOQ library, database driver, strategy classes, etc.)
// - the schema files from which the schema is generated and which is used by jOOQ to generate the sources have changed (scripts added, modified, etc.)
tasks.named('generateJooq').configure {
// ensure database schema has been prepared by Flyway before generating the jOOQ sources
dependsOn tasks.named('flywayMigrate')
// declare Flyway migration scripts as inputs on the jOOQ task
inputs.files(fileTree('src/main/resources/db/migration'))
.withPropertyName('migrations')
.withPathSensitivity(PathSensitivity.RELATIVE)
// make jOOQ task participate in incremental builds (and build caching)
allInputsDeclared = true
}