-
Notifications
You must be signed in to change notification settings - Fork 208
/
Copy pathbuild.gradle
185 lines (159 loc) · 7.05 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
/**
* Copyright 2019 Yanzheng (https://github.com/micyo202). All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
plugins {
id 'org.springframework.boot' version '2.2.6.RELEASE'
id 'io.spring.dependency-management' version '1.0.9.RELEASE'
id 'com.bmuschko.docker-spring-boot-application' version '6.1.3'
}
allprojects {
version '2.0.9'
group 'com.lion'
description 'Lion project for Spring Boot / Spring Cloud / Alibaba Cloud'
apply plugin: 'io.spring.dependency-management'
repositories {
maven { url "https://maven.aliyun.com/nexus/content/groups/public/" }
maven { url "https://repo.spring.io/milestone" }
maven { url "https://plugins.gradle.org/m2/" }
mavenCentral()
jcenter()
}
ext {
//如果url不指定的话
//Mac默认:url = https://index.docker.io/v1/
//Unix默认: url = unix:///var/run/docker.sock
//Windows默认: url = tcp://127.0.0.1:2375
set('dockerUrl', "https://index.docker.io/v1/")
set('dockerUsername', "micyo202")
set('dockerPassword', "")
set('dockerEmail', "[email protected]")
set('dockerBaseImage', "openjdk:8")
set('dockerMaintainer', "Yanzheng (https://github.com/micyo202)")
set('springBootVersion', "2.2.6.RELEASE")
set('springBootAdminVersion', "2.2.1")
set('springCloudVersion', "Hoxton.SR2")
set('springCloudAlibabaVersion', "2.2.0.RELEASE")
set('lombokVersion', "1.18.12")
set('junitJupiterVersion', "5.6.2")
set('junitPlatformLauncherVersion', "1.6.2")
set('sentinelVersion', "1.7.1")
set('druidVersion', "1.1.23")
set('mybatisPlusVersion', "3.3.1")
set('velocityEngineVersion', "2.2")
set('pagehelperVersion', "1.2.13")
set('knife4jVersion', "2.0.2")
set('redissonVersion', "3.12.4")
set('commonsLangVersion', "3.10")
set('commonsCollections4Version', "4.4")
set('xstreamVersion', "1.4.12")
set('httpclientVersion', "4.5.12")
set('servletVersion', "4.0.1")
set('servoVersion', "0.13.0")
set('bouncyCastleVersion', "1.69")
}
dependencyManagement {
imports {
mavenBom "de.codecentric:spring-boot-admin-dependencies:${springBootAdminVersion}"
mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
mavenBom "com.alibaba.cloud:spring-cloud-alibaba-dependencies:${springCloudAlibabaVersion}"
}
dependencies {
dependency "com.alibaba:druid-spring-boot-starter:${druidVersion}"
dependency "com.baomidou:mybatis-plus-boot-starter:${mybatisPlusVersion}"
dependency "com.baomidou:mybatis-plus-generator:${mybatisPlusVersion}"
dependency "org.apache.velocity:velocity-engine-core:${velocityEngineVersion}"
dependency "com.github.pagehelper:pagehelper-spring-boot-starter:${pagehelperVersion}"
dependency "com.github.xiaoymin:knife4j-spring-boot-starter:${knife4jVersion}"
dependency "com.alibaba.csp:sentinel-spring-cloud-gateway-adapter:${sentinelVersion}"
dependency "org.springframework.boot:spring-boot-starter-data-redis:${springBootVersion}"
dependency "org.redisson:redisson:${redissonVersion}"
dependency "org.apache.commons:commons-lang3:${commonsLangVersion}"
dependency "org.apache.commons:commons-collections4:${commonsCollections4Version}"
dependency "com.thoughtworks.xstream:xstream:${xstreamVersion}"
dependency "org.bouncycastle:bcprov-jdk15on:${bouncyCastleVersion}"
dependency "org.apache.httpcomponents:httpclient:${httpclientVersion}"
dependency "javax.servlet:javax.servlet-api:${servletVersion}"
dependency "com.netflix.servo:servo-core:${servoVersion}"
}
}
gradle.projectsEvaluated {
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
}
}
}
subprojects {
apply plugin: 'java'
apply plugin: 'jacoco'
sourceCompatibility = '1.8'
configurations {
compileOnly {
extendsFrom annotationProcessor
}
// 排除 logback 依赖(使用 log4j2)
implementation.exclude group: 'org.springframework.boot', module: 'spring-boot-starter-logging'
// 排除 tomcat 依赖(使用 undertow)
implementation.exclude group: 'org.springframework.boot', module: 'spring-boot-starter-tomcat'
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-log4j2'
implementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-yaml' // 添加 yml 依赖(用于识别 log4j2.yml 文件)
implementation 'org.springframework.boot:spring-boot-starter-undertow'
compileOnly "org.projectlombok:lombok:${lombokVersion}"
annotationProcessor "org.projectlombok:lombok:${lombokVersion}"
testImplementation('org.springframework.boot:spring-boot-starter-test') {
exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
}
testImplementation "org.junit.jupiter:junit-jupiter-engine:${junitJupiterVersion}"
testImplementation "org.junit.jupiter:junit-jupiter-params:${junitJupiterVersion}"
testImplementation "org.junit.platform:junit-platform-launcher:${junitPlatformLauncherVersion}"
}
test {
useJUnitPlatform()
ignoreFailures = true
}
/**
* 添加jacoco测试覆盖率
*/
jacocoTestReport {
reports {
xml.enabled true
csv.enabled true
html.enabled true
xml.destination file("${buildDir}/jacoco/coverage-reports/jacoco.xml")
csv.destination file("${buildDir}/jacoco/coverage-reports/jacoco.csv")
html.destination file("${buildDir}/jacoco/coverage-reports/html")
}
}
tasks.check.dependsOn jacocoTestReport
/**
* clean 命令时删除 logs 目录
*/
task cleanOutDir(type: Delete) {
delete "${projectDir}/logs"
delete "${rootDir}/logs"
}
tasks.clean.dependsOn(cleanOutDir)
/**
* 该过滤器会导致resource下文件编码错误
* 根据环境打包默认dev开发环境,命令:./gradlew -x test clean bootJar -Denv=dev
*/
/*
def env = System.getProperty("env") ?: "dev"
processResources {
filter org.apache.tools.ant.filters.ReplaceTokens, tokens: [env: env]
}
*/
}