-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.gradle.kts
144 lines (117 loc) · 4.64 KB
/
build.gradle.kts
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
import nu.studer.gradle.jooq.JooqEdition
import nu.studer.gradle.jooq.JooqGenerate
import org.flywaydb.gradle.task.FlywayMigrateTask
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.jooq.meta.jaxb.Logging
plugins {
id("org.springframework.boot") version "2.4.2"
id("io.spring.dependency-management") version "1.0.11.RELEASE"
id("org.flywaydb.flyway") version "7.7.0"
id("nu.studer.jooq") version "5.2"
kotlin("jvm") version "1.4.30"
kotlin("plugin.spring") version "1.4.30"
kotlin("kapt") version "1.4.30"
}
group = "com.goodchoice"
version = "0.0.1-SNAPSHOT"
java.sourceCompatibility = JavaVersion.VERSION_11
val dbDriver = "org.postgresql.Driver"
val dbUrl = System.getenv("JDBC_DATABASE_URL") ?: "jdbc:postgresql://localhost:5432/good-choice"
val dbUser = System.getenv("JDBC_DATABASE_USERNAME") ?: "good-choice-user"
val dbPassword = System.getenv("JDBC_DATABASE_PASSWORD") ?: "good-choice-pass"
val dbTestUrl = "jdbc:postgresql://localhost:5432/good-choice-test"
val dbTestUser = "good-choice-user"
val dbTestPassword = "good-choice-pass"
repositories {
mavenCentral()
}
val springdocVersion = "1.5.6"
val jooqVersion = dependencyManagement.importedProperties["jooq.version"]
dependencies {
jooqGenerator("org.postgresql:postgresql")
implementation("org.springframework.boot:spring-boot-starter-web")
implementation("org.springframework.boot:spring-boot-starter-thymeleaf")
implementation("org.springframework.boot:spring-boot-starter-security")
implementation("org.springframework.boot:spring-boot-starter-mail")
implementation("org.springframework.boot:spring-boot-starter-jooq")
implementation("org.jooq:jooq-kotlin:$jooqVersion")
implementation("org.springdoc:springdoc-openapi-ui:$springdocVersion")
implementation("org.springdoc:springdoc-openapi-security:$springdocVersion")
implementation("org.springdoc:springdoc-openapi-kotlin:$springdocVersion")
implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
implementation("org.jetbrains.kotlin:kotlin-reflect")
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
implementation("io.github.microutils:kotlin-logging-jvm:2.0.6")
runtimeOnly("org.postgresql:postgresql")
testImplementation("org.springframework.boot:spring-boot-starter-test")
kapt("org.springframework.boot:spring-boot-configuration-processor")
annotationProcessor("org.springframework.boot:spring-boot-configuration-processor")
developmentOnly("org.springframework.boot:spring-boot-devtools")
}
flyway {
driver = dbDriver
url = dbUrl
user = dbUser
password = dbPassword
}
jooq {
version.set(jooqVersion)
edition.set(JooqEdition.OSS)
configurations {
create("main") {
generateSchemaSourceOnCompilation.set(true)
jooqConfiguration.apply {
logging = Logging.WARN
jdbc.apply {
driver = dbDriver
url = dbUrl
user = dbUser
password = dbPassword
}
generator.apply {
database.apply {
name = "org.jooq.meta.postgres.PostgresDatabase"
inputSchema = "public"
}
generate.apply {
isDeprecated = false
isRecords = false
isNonnullAnnotation = true
nonnullAnnotationType = "org.jetbrains.annotations.NotNull"
isNullableAnnotation = true
nullableAnnotationType = "org.jetbrains.annotations.Nullable"
}
target.apply {
packageName = "com.goodchoice.domain.common.jooq"
directory = "build/generated/sources/jooq/main"
}
}
}
}
}
}
tasks.withType<JooqGenerate> {
dependsOn(tasks.named<FlywayMigrateTask>("flywayMigrate"))
inputs.files(fileTree("src/main/resources/db/migration"))
.withPropertyName("migrations")
.withPathSensitivity(PathSensitivity.RELATIVE)
allInputsDeclared.set(true)
outputs.cacheIf { true }
}
tasks.withType<KotlinCompile> {
kotlinOptions {
freeCompilerArgs = listOf("-Xjsr305=strict")
jvmTarget = "11"
allWarningsAsErrors = true
}
}
task<FlywayMigrateTask>("flywayMigrateTest") {
driver = dbDriver
url = dbTestUrl
user = dbTestUser
password = dbTestPassword
}
tasks.withType<Test> {
dependsOn(tasks.named<FlywayMigrateTask>("flywayMigrateTest"))
useJUnitPlatform()
}