-
Notifications
You must be signed in to change notification settings - Fork 262
/
Copy pathbuild.gradle
194 lines (158 loc) · 5.95 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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
buildscript {
ext {
gradleDockerVersion = '1.2'
springBootVersion = '1.5.8.RELEASE'
ehcacheVersion = '2.10.4'
mysqlConnectorVersion = '5.1.44'
lombokVersion = '1.16.18'
mybatisVersion = '3.4.5'
mybatisStarterVersion = '1.3.0'
hikariCPVersion = '2.5.1'
commonMapperVersion = '3.4.4'
commonsIOVersion = '2.4'
commonsLangversion = '3.7'
commonsCodecVersion = '1.11'
fastJsonVersion = '1.2.41'
}
repositories {
maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' }
mavenCentral()
maven { url "http://repo.spring.io/release" }
maven { url "http://repo.spring.io/milestone" }
maven { url "http://repo.spring.io/snapshot" }
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
// Gradle-docker 插件
classpath("se.transmode.gradle:gradle-docker:${gradleDockerVersion}")
}
}
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'eclipse-wtp'
apply plugin: 'org.springframework.boot'
apply plugin: 'docker' // end::plugin[] // This is used as the docker image prefix (org) group = 'gregturn'
group = 'me.zbl'
version = '2.3-Release'
sourceCompatibility = 1.8
bootRun {
addResources = true
}
jar {
baseName = 'fsblog'
}
repositories {
maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' }
mavenCentral()
maven { url "http://repo.spring.io/release" }
maven { url "http://repo.spring.io/milestone" }
maven { url "http://repo.spring.io/snapshot" }
}
configurations {
providedRuntime
compile.exclude group: 'ch.qos.logback'
mybatisGenerator
}
dependencies {
//security
//compile("org.springframework.boot:spring-boot-starter-security:${springBootVersion}")
//web
compile("org.springframework.boot:spring-boot-starter-web:${springBootVersion}")
//aop
compile("org.springframework.boot:spring-boot-starter-aop:${springBootVersion}")
//jdbc
compile("org.springframework.boot:spring-boot-starter-jdbc:${springBootVersion}")
//模板引擎
compile("org.springframework.boot:spring-boot-starter-freemarker:${springBootVersion}")
//日志
compile("org.springframework.boot:spring-boot-starter-log4j2:${springBootVersion}")
//缓存
compile("net.sf.ehcache:ehcache:${ehcacheVersion}")
//数据库驱动
compile("mysql:mysql-connector-java:${mysqlConnectorVersion}")
//连接池
compile("com.zaxxer:HikariCP:${hikariCPVersion}")
//ORM
compile("org.mybatis:mybatis:${mybatisVersion}")
compile("org.mybatis.spring.boot:mybatis-spring-boot-starter:${mybatisStarterVersion}")
//lombok插件
compile("org.projectlombok:lombok:${lombokVersion}")
//
compile 'com.lmax:disruptor:3.3.6'
//common mapper
compile("tk.mybatis:mapper:${commonMapperVersion}")
//mybatis-generator-core
mybatisGenerator 'org.mybatis.generator:mybatis-generator-core:1.3.5'
//mybatis-common-mapper-generator
mybatisGenerator 'tk.mybatis:mapper:3.4.4'
//mybatis-mysql驱动
mybatisGenerator "mysql:mysql-connector-java:${mysqlConnectorVersion}"
//运行环境(采用 jar 部署的方式时需要)
providedRuntime("org.springframework.boot:spring-boot-starter-tomcat:${springBootVersion}")
//测试
testCompile("org.springframework.boot:spring-boot-starter-test:${springBootVersion}")
//热部署
compile("org.springframework.boot:spring-boot-devtools:${springBootVersion}")
//commons-io
compile("commons-io:commons-io:${commonsIOVersion}")
//commons-lang3
compile("org.apache.commons:commons-lang3:${commonsLangversion}")
//commons-codec
compile("commons-codec:commons-codec:${commonsCodecVersion}")
//fast-json
compile("com.alibaba:fastjson:$fastJsonVersion")
}
/* mybatisGenerator */
def getDbProperties = {
def properties = new Properties()
file("src/main/resources/mybatisGenerator/config.properties").withInputStream { inputStream ->
properties.load(inputStream)
}
properties
}
task mybatisGenerate << {
def properties = getDbProperties()
ant.properties['targetProject'] = projectDir.path
ant.properties['driverClass'] = properties.getProperty("jdbc.driverClassName")
ant.properties['connectionURL'] = properties.getProperty("jdbc.url")
ant.properties['userId'] = properties.getProperty("jdbc.username")
ant.properties['password'] = properties.getProperty("jdbc.password")
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'] = properties.getProperty("package.model")
ant.properties['mapperPackage'] = properties.getProperty("package.mapper")
ant.properties['sqlMapperPackage'] = properties.getProperty("package.xml")
ant.taskdef(
name: 'mbgenerator',
classname: 'org.mybatis.generator.ant.GeneratorAntTask',
classpath: configurations.mybatisGenerator.asPath
)
ant.mbgenerator(overwrite: true,
configfile: 'src/main/resources/mybatisGenerator/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')
}
}
}
// tag::task[]
task buildDocker(type: Docker, dependsOn: build) {
push = true
applicationName = jar.baseName
dockerfile = file('Dockerfile')
doFirst {
copy {
from jar
into stageDir
}
}
}
// end::task[]