forked from domaframework/kotlin-sample
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle.kts
108 lines (93 loc) · 2.63 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
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath("com.h2database:h2:1.4.200")
}
}
plugins {
id("application")
id("com.diffplug.spotless") version "6.12.1"
id("org.seasar.doma.codegen") version "1.4.1"
id("org.domaframework.doma.compile") version "2.0.0"
kotlin("jvm") version "1.9.21"
kotlin("kapt") version "1.9.21"
}
application {
mainClass.set("sample.AppKt")
}
dependencies {
val domaVersion: String by project
kapt("org.seasar.doma:doma-processor:$domaVersion")
implementation("org.seasar.doma:doma-kotlin:$domaVersion")
implementation("org.seasar.doma:doma-slf4j:$domaVersion")
runtimeOnly("ch.qos.logback:logback-classic:1.4.14")
runtimeOnly("com.h2database:h2:1.4.200")
testImplementation("org.junit.jupiter:junit-jupiter-api:5.10.1")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.10.1")
}
repositories {
mavenCentral()
mavenLocal()
maven(url = "https://oss.sonatype.org/content/repositories/snapshots/")
}
spotless {
kotlin {
ktlint("0.38.1")
trimTrailingWhitespace()
endWithNewline()
}
}
val h2Url = "jdbc:h2:mem:tutorial;DB_CLOSE_DELAY=-1"
val h2User = "sa"
val h2Password = ""
domaCodeGen {
register("dev") {
url.set(h2Url)
user.set(h2User)
password.set(h2Password)
languageType.set(org.seasar.doma.gradle.codegen.desc.LanguageType.KOTLIN)
entity {
packageName.set("sample.entity")
val mappingFile = layout.projectDirectory.file("$projectDir/codegen-name-mapping.properties")
entityPropertyClassNamesFile.set(mappingFile)
}
}
}
tasks {
val jvmTarget = "11"
compileKotlin {
kotlinOptions.jvmTarget = jvmTarget
}
compileTestKotlin {
kotlinOptions.jvmTarget = jvmTarget
}
test {
maxHeapSize = "1g"
useJUnitPlatform()
}
jar {
duplicatesStrategy = DuplicatesStrategy.INCLUDE
}
val createDb by registering {
doLast {
val ds = org.seasar.doma.gradle.codegen.jdbc.SimpleDataSource()
ds.driver = org.h2.Driver()
ds.url = h2Url
ds.user = h2User
ds.password = h2Password
ds.connection.use { con ->
con.createStatement().use { stmt ->
stmt.execute("RUNSCRIPT FROM '${project.projectDir}/src/main/resources/META-INF/sample/dao/ScriptDao/create.script'")
}
}
}
}
named("domaCodeGenDevDbMeta") {
dependsOn(createDb)
}
build {
dependsOn(spotlessApply)
}
}