-
Notifications
You must be signed in to change notification settings - Fork 5
/
build.gradle
executable file
·221 lines (177 loc) · 5.3 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
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
import java.text.SimpleDateFormat
plugins {
id 'java'
}
group 'recordins'
version '1.5'
version = version + ("master" == gitCurBranch() ? "-RELEASE" : "-SNAPSHOT")
def gitCurBranch() {
def process = "git rev-parse --abbrev-ref HEAD".execute()
return process.text.trim()
}
def date = buildTime();
def buildTime() {
def df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ") // you can change it
df.setTimeZone(TimeZone.getTimeZone("UTC"))
return df.format(new Date())
}
//sourceCompatibility = 1.8
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
sourceSets.main.resources { srcDirs = ["src/main/java"]; exclude "**/*.java" }
// need higher version than ide default to support java 11
// this is for legacy gradle < 5.0
task wrapper(type: Wrapper) {
gradleVersion = "4.9"
}
// this is for gradle >= 5.0
wrapper {
gradleVersion = "4.9"
}
repositories {
mavenCentral()
}
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.12'
/* used to retrive dependencies online*/
//compile group: 'com.auth0', name: 'java-jwt', version: '3.4.0'
//compile group: 'com.github.oshi', name: 'oshi-core', version: '3.9.0'
compile fileTree(dir: 'lib', include: '*.jar')
runtime fileTree(dir: 'lib', include: '*.jar')
}
task packageTests(type: Jar) {
baseName = rootProject.name + 'Test'
manifest {
attributes(
"Created-By": 'Philippe Schweitzer - Blockchain Recordin Solutions',
"Class-Path": 'lib/' + configurations.compile.collect { it.getName() }.join(' lib/'),// + ' lib/CheetahWebserver-' + version + '.jar',
"Main-Class": 'com.recordins.insidelog.InSideLogTest',
"Cheetah-Version": version,
"Build-Time-ISO-8601": date
)
}
from sourceSets.test.output
}
task customFatJar(type: Jar) {
doFirst {
libFolder()
}
manifest {
attributes(
"Created-By": 'Philippe Schweitzer - Blockchain Recordin Solutions',
"Class-Path": 'lib/' + configurations.compile.collect { it.getName() }.join(' lib/'),
"Main-Class": 'com.recordins.insidelog.InSideLog',
"Cheetah-Version": version,
"Build-Time-ISO-8601": date
)
}
baseName = rootProject.name + '-all-in-one-jar'
from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
exclude 'META-INF/*.RSA', 'META-INF/*.SF','META-INF/*.DSA'
with jar
}
jar {
dependsOn customFatJar
doFirst {
libFolder()
}
baseName = rootProject.name
manifest {
attributes(
"Created-By": 'Philippe Schweitzer - Blockchain Recordin Solutions',
"Class-Path": 'lib/' + configurations.compile.collect { it.getName() }.join(' lib/'),
"Main-Class": 'com.recordins.insidelog.InSideLog',
"Cheetah-Version": version,
"Build-Time-ISO-8601": date
)
}
}
/*
*
* Used to retrieve all dependencies and put them into lib/folder
*/
def libFolder() {
project.configurations.compile.resolvedConfiguration.resolvedArtifacts.each {
//println it.name // << the artifact name
//println it.file // << the file reference
def libfile = it.file;
copy {
from "$libfile"
into "lib"
}
}
}
clean {
doFirst {
def jarname = rootProject.name + "-" + version + ".jar"
def file = new File(jarname)
if(file.exists()){
delete jarname
}
jarname = rootProject.name + 'Test' + "-" + version + ".jar"
file = new File(jarname)
if(file.exists()){
delete jarname
}
}
}
//noinspection GroovyAssignabilityCheck
build {
//dependsOn packageTests
doLast {
def jarname = rootProject.name + "-" + version + ".jar"
def file = new File(jarname)
if(file.exists()){
delete jarname
}
copy{
from "$buildDir/libs/" + jarname
into "$projectDir/"
}
jarname = rootProject.name + 'Test' + "-" + version + ".jar"
file = new File(jarname)
if(file.exists()){
delete jarname
}
copy {
from "$buildDir/libs/" + jarname
into "$projectDir/"
}
}
}
test {
dependsOn packageTests
/*
print "RUN TEST\n"
copy{
from "$buildDir/libs/CheetahWebserver-" + version + '.jar'
into "$projectDir/lib"
}
def jarname = "CheetahWebserverTest" + "-" + version + ".jar"
def file = new File("$projectDir/" + jarname)
if(file.exists()){
delete "$projectDir/" + jarname
}
copy{
from "$buildDir/libs/" + jarname
into "$projectDir/"
}
//def file = new File("$projectDir/" + jarname)
if(file.exists()){
// def sout = new StringBuilder(), serr = new StringBuilder()
// def command = 'java -jar ' + jarname
// def proc = command.execute()
// proc.consumeProcessOutput(sout, serr)
// proc.waitForOrKill(1000000)
javaexec {
main="-jar";
args = [
jarname,
""
]
}
}
else{
print "jar executable: " + jarname + " does not exist \n"
}
*/
}