-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
110 lines (93 loc) · 3.26 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
import liquibase.Contexts
import liquibase.Liquibase
import liquibase.database.core.H2Database
import liquibase.database.jvm.JdbcConnection
import liquibase.resource.DirectoryResourceAccessor
import org.h2.Driver
import org.jooq.codegen.GenerationTool
import org.jooq.meta.jaxb.*
import java.sql.Connection
import java.sql.Statement
buildscript {
repositories {
mavenCentral()
google()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
classpath "org.jooq:jooq-codegen:$jooqVersion"
classpath "com.h2database:h2:2.1.214"
classpath "org.liquibase:liquibase-core:$liquibaseVersion"
}
}
plugins {
id "com.github.ben-manes.versions" version "0.45.0"
id "org.jetbrains.kotlin.jvm" version "$kotlinVersion"
}
apply plugin: 'idea'
apply plugin: 'java'
kotlin {
jvmToolchain {
languageVersion.set(JavaLanguageVersion.of("17"))
}
}
repositories {
mavenCentral()
google()
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion"
// logging
implementation "org.slf4j:slf4j-api:2.0.6"
implementation "ch.qos.logback:logback-classic:1.4.5"
implementation "ch.qos.logback:logback-core:1.4.5"
// db
implementation "org.liquibase:liquibase-core:$liquibaseVersion"
implementation "org.xerial:sqlite-jdbc:3.40.0.0"
implementation "org.jooq:jooq:$jooqVersion"
}
sourceSets {
main {
java {
srcDirs "$buildDir/jooq"
}
}
}
//noinspection GroovyAssignabilityCheck
tasks.getByPath("compileKotlin").doFirst {
Connection conn = new Driver().connect("jdbc:h2:mem:test", null)
Statement stmt = conn.createStatement()
stmt.execute("drop all OBJECTS")
stmt.execute("create schema EXAMPLE_DB")
stmt.execute("set schema EXAMPLE_DB")
stmt.close()
def resourceAccessor = new DirectoryResourceAccessor(new File("${project.projectDir}/src/main/resources"))
def db = new H2Database()
db.setConnection(new JdbcConnection(conn))
def liquibase = new Liquibase("liquibase-changelog.xml", resourceAccessor, db)
liquibase.update(new Contexts())
conn.commit()
GenerationTool.generate(
new Configuration()
.withJdbc(new Jdbc()
.withDriver('org.h2.Driver')
.withUrl('jdbc:h2:mem:test')
.withUser('')
.withPassword(''))
.withGenerator(new Generator()
.withDatabase(
new Database()
.withExcludes("DATABASECHANGELOG|DATABASECHANGELOGLOCK")
.withInputSchema("EXAMPLE_DB")
)
.withGenerate(new Generate()
.withPojos(true)
.withDaos(true))
.withTarget(
new Target()
.withPackageName('dev.encelade.example.dao.codegen')
.withDirectory("$buildDir/jooq"))
)
)
conn.close()
}