forked from JunManYuanLong/FunTester
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
executable file
·198 lines (179 loc) · 6.12 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
195
196
197
198
buildscript {
repositories {
maven {url 'http://maven.aliyun.com/nexus/content/groups/public/'}
// maven { url 'http://repo1.maven.apache.org/maven2/' }
//// maven { url 'http://repo2.maven.org/maven2/' }
//// maven { url 'http://maven.oschina.net/content/groups/public/' }
// google()
}
}
plugins {
id 'java'
}
group 'tester'
version '1.0'
apply plugin: 'groovy'
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'distribution' //打包tar包用到的插件
idea {
module {
downloadJavadoc = true
downloadSources = true
}
}
sourceCompatibility = 1.8
repositories {
mavenLocal()
maven {
url 'http://maven.aliyun.com/nexus/content/groups/public/'
}
// maven {
// url 'http://repo2.maven.org/maven2/'
// }
// maven {
// url 'http://repo1.maven.apache.org/maven2/'
// }
// maven { url 'http://maven.oschina.net/content/groups/public/' }
mavenCentral()
}
test {
useJUnitPlatform()
exclude "com/test/**"
}
sourceSets {
main {
groovy {
srcDirs 'src/main/groovy'
}
}
}
dependencies {
compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.7'
compile group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.5.5'
compile group: 'org.apache.httpcomponents', name: 'httpmime', version: '4.5.5'
compile group: 'org.apache.httpcomponents', name: 'httpasyncclient', version: '4.1.4'
compile group: 'commons-beanutils', name: 'commons-beanutils', version: '1.8.0'
compile group: 'commons-codec', name: 'commons-codec', version: '1.9'
compile group: 'com.sun.jna', name: 'jna', version: '3.0.9'
compile group: 'com.alibaba', name: 'fastjson', version: '1.2.62'
compile group: 'org.mongodb', name: 'mongo-java-driver', version: '3.9.0'
compile group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.12.1'
compile group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.12.1'
compile group: 'org.apache.logging.log4j', name: 'log4j-slf4j-impl', version: '2.12.1'
compile group: 'org.slf4j', name: 'slf4j-api', version: '1.7.25'
compile group: 'org.slf4j', name: 'jcl-over-slf4j', version: '1.7.25'
compile group: 'mysql', name: 'mysql-connector-java', version: '8.0.13'
compile group: 'javax.mail', name: 'javax.mail-api', version: '1.6.0'
compile group: 'com.sun.mail', name: 'javax.mail', version: '1.6.0'
compile group: 'org.codehaus.groovy', name: 'groovy-all', version: '2.5.7'
compile group: 'com.github.dreamhead', name: 'moco-core', version: '0.12.0'
compile group: 'redis.clients', name: 'jedis', version: '3.0.1'
compile group: 'com.alibaba', name: 'dubbo', version: '2.5.3'
compile group: 'com.jayway.jsonpath', name: 'json-path', version: '2.4.0'
testCompile 'org.mockito:mockito-core:2.7.22'
testCompile group: 'org.spockframework', name: 'spock-core', version: '1.3-groovy-2.5'
testCompile group: 'org.springframework', name: 'spring-test', version: '5.1.9.RELEASE'
testCompile group: 'org.hamcrest', name: 'hamcrest-library', version: '1.3'
testCompile group: 'junit', name: 'junit', version: '4.12'
testCompile group: 'org.powermock', name: 'powermock-module-junit4', version: '2.0.0'
testCompile group: 'org.powermock', name: 'powermock-api-mockito2', version: '2.0.2'
}
jar {
from {
//添加依懒到打包文件
configurations.compile.collect {it.isDirectory() ? it : zipTree(it)}
configurations.runtime.collect {zipTree(it)}
}
manifest {
attributes 'Main-Class': 'com.fun.main.Blog'
}
}
ext {
if (project.hasProperty('profile')) {
profile = project['profile']
} else {
profile = "FunTester"
}
println "项目环境:" + profile
}
//因为打包配置,这里会执行
task createDirs() {
doLast {
if (profile != "FunTester") {
file('build/package/lib').mkdirs()
file('build/package/bin').mkdirs()
file('build/package/logs').mkdirs()
file('build/package/conf').mkdirs()
println "文件夹创建成功!"
}
}
}
task copyFun(type: Copy) {
from('/Users/fv/Documents/workspace/fun/build/libs')
into('/Users/fv/Library/groovy-2.5.7/lib')
println "fun拷贝成功!"
}
task copyOkay(type: Copy) {
from('/Users/fv/Documents/workspace/okay_test/target/okay_test-1.0-SNAPSHOT.jar')
into('/Users/fv/Library/groovy-2.5.7/lib')
println "okay拷贝成功!"
}
task copyJarToGroovy(dependsOn: ['copyFun', 'copyOkay']) {}
task copyLibs(type: Copy) {
doLast {
from('build/libs')
into('build/package/lib')
println "依赖拷贝成功!"
}
}
task copyConf(type: Copy) {
doLast {
from('src/main/resources/' + profile)
into('build/package/conf')
println "从src/main/resources/" + profile + "拷贝配置文件"
}
}
task copyBin(type: Copy) {
doLast {
from('src/main/resources/bin')
into('build/package/bin')
fileMode 0744//可能会失效,检查执行权限
println "依赖脚本,并设置可执行权限成功!"
}
}
// task 用来复制启动所依赖的jar包
task copyDep(type: Copy) {
doLast {
from configurations.runtime
into 'build/package/lib'
println "复制启动所依赖的jar包成功!"
}
}
//把上述的task串联起来
task prepareFile(dependsOn: [
'createDirs',
'copyLibs',
'copyConf',
'copyBin',
'copyDep'
]) {}//如果没有内容的话,可以不需要大括号
//还有一种写法表示task之间的依赖:prepareFile.dependsOn createDirs,copyLibs,copyConf,copyBin,copyDep
//指定打包的tar包的名字,以及文件来源目录
distributions {
monitor {
baseName = 'azkaban-monitor'
contents {
from {'build/package'}
}
}
}
//distribution 插件的特性
monitorDistTar.dependsOn 'prepareFile'
monitorDistTar.compression = Compression.NONE
monitorDistTar.extension = 'tar'
//定义一个task,先build 然后再打包tar包
task buildTar(dependsOn: [
'build',
monitorDistTar
]) {}