forked from ichenkaihua/ssm-easy-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
156 lines (110 loc) · 3.88 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
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
144
145
146
147
148
149
150
151
152
version '2.0'
apply plugin: 'war'
apply plugin: 'idea'
apply plugin: 'eclipse-wtp'
apply plugin: 'org.akhikhl.gretty'
apply plugin: 'org.flywaydb.flyway'
//指定gradle wrapper版本
task wrapper(type: Wrapper) {
gradleVersion = '2.3'
}
configurations {
mybatisGenerator
}
//配置插件仓库
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'org.akhikhl.gretty:gretty:1.2.4'
classpath: 'mysql:mysql-connector-java:5.1.36'
classpath "org.flywaydb:flyway-gradle-plugin:3.2.1"
}
}
//gretty设置
gretty {
port = 8080
contextPath = "/"
}
ext{
def prop = new Properties();
file("src/main/resources/jdbc-mysql.properties").withInputStream {
prop.load(it)
}
prop.each {
project.extensions.add("$it.key",it.value);
}
}
flyway {
user = project['jdbc.user']
url= project['jdbc.url']
password = project['jdbc.pass']
locations=["filesystem:db/migration"]
}
repositories {
mavenCentral()
}
//统一编码为utf-8
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
//依赖
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.12'
testCompile 'org.springframework:spring-test:4.2.0.RELEASE'
testCompile 'org.hamcrest:hamcrest-core:1.3'
testCompile 'org.mockito:mockito-core:1.10.19'
//maven仓库中心没有的jar,则放入libs目录下
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'org.springframework:spring-webmvc:4.2.0.RELEASE'
compile 'org.springframework:spring-orm:4.2.0.RELEASE'
compile 'org.springframework:spring-context-support:4.2.0.RELEASE'
compile 'mysql:mysql-connector-java:5.1.36'
compile 'org.mybatis:mybatis:3.3.0'
compile 'org.mybatis:mybatis-spring:1.2.3'
compile 'com.github.pagehelper:pagehelper:4.0.0'
compile 'org.apache.shiro:shiro-spring:1.2.4'
compile 'org.apache.tomcat:tomcat-jdbc:8.0.24'
compile 'javax.mail:mail:1.4.7'
compile 'com.fasterxml.jackson.core:jackson-databind:2.6.1'
compile 'org.aspectj:aspectjweaver:1.8.6'
compile 'commons-fileupload:commons-fileupload:1.3.1'
compile 'org.slf4j:slf4j-log4j12:1.7.12'
compile 'tk.mybatis:mapper:3.3.1'
compile 'javax.servlet:javax.servlet-api:3.1.0'
mybatisGenerator 'org.mybatis.generator:mybatis-generator-core:1.3.2'
mybatisGenerator 'mysql:mysql-connector-java:5.1.36'
mybatisGenerator 'tk.mybatis:mapper:3.3.1'
}
//这是新测试
task mybatisGenerate << {
ant.properties['targetProject'] = projectDir.path
ant.properties['driverClass'] = project['jdbc.driverClassName']
ant.properties['connectionURL'] = project['jdbc.url']
ant.properties['userId'] = project['jdbc.user']
ant.properties['password'] = project['jdbc.pass']
ant.properties['src_main_java'] = sourceSets.main.java.srcDirs[0].path
ant.properties['src_main_resources'] = sourceSets.main.resources.srcDirs[0].path
ant.properties['modelPackage'] = this.modelPackage
ant.properties['mapperPackage'] = this.mapperPackage
ant.properties['sqlMapperPackage'] = this.sqlMapperPackage
ant.taskdef(
name: 'mbgenerator',
classname: 'org.mybatis.generator.ant.GeneratorAntTask',
classpath: configurations.mybatisGenerator.asPath
)
ant.mbgenerator(overwrite: true,
configfile: 'db/generatorConfig.xml', verbose: true) {
propertyset {
propertyref(name: 'targetProject')
propertyref(name: 'userId')
propertyref(name: 'driverClass')
propertyref(name: 'connectionURL')
propertyref(name: 'password')
propertyref(name: 'src_main_java')
propertyref(name: 'src_main_resources')
propertyref(name: 'modelPackage')
propertyref(name: 'mapperPackage')
propertyref(name: 'sqlMapperPackage')
}
}
}