-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle
More file actions
98 lines (85 loc) · 2.35 KB
/
Copy pathbuild.gradle
File metadata and controls
98 lines (85 loc) · 2.35 KB
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
import org.h2.Driver
import org.seasar.doma.gradle.codegen.jdbc.SimpleDataSource
buildscript {
ext.domaVersion = '2.36.0'
ext.h2Version= '1.4.200'
repositories {
mavenCentral()
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath 'gradle.plugin.org.seasar.doma:codegen:1.0.0'
classpath 'gradle.plugin.org.seasar.doma:compile:1.0.0'
classpath "com.h2database:h2:$h2Version"
}
}
apply plugin: 'java'
apply plugin: 'org.seasar.doma.compile'
apply plugin: 'org.seasar.doma.codegen'
group 'org.seasar.doma'
version '1.0'
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
test {
useJUnitPlatform()
}
repositories {
mavenCentral()
}
dependencies {
implementation "org.seasar.doma:doma-core:$domaVersion"
annotationProcessor "org.seasar.doma:doma-processor:$domaVersion"
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.6.1'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.6.1'
testRuntimeOnly "com.h2database:h2:$h2Version"
}
def _url = "jdbc:h2:file:$projectDir/data/db"
def _user = ''
def _password = ''
domaCodeGen {
dev {
def basePackage = 'sample'
url = _url
user = _user
password = _password
entity {
packageName = "${basePackage}.entity"
}
dao {
packageName = "${basePackage}.dao"
}
}
}
task createDb {
doLast {
def ds = new SimpleDataSource()
ds.setDriver(new Driver())
ds.setUrl(_url)
ds.setUser(_user)
ds.setPassword(_password)
def sql = """
drop all objects;
create table department(
department_id integer not null primary key,
department_no integer not null,
department_name varchar(20),
location varchar(20) default 'tokyo',
version integer
);
create table employee(
employee_id integer not null primary key,
employee_no integer not null,
employee_name varchar(20)
);
"""
ds.connection.withCloseable {
it.createStatement().withCloseable {
it.execute(sql)
}
}
}
}