forked from WeBankBlockchain/WeIdentity-Blockchain
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
442 lines (384 loc) · 13.4 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
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
// Due to a bug of spotbugs, the following lines have to be defined on top as well
buildscript {
dependencies {
classpath "org.springframework.boot:spring-boot-gradle-plugin:2.4.3"
// classpath "org.jsonschema2pojo:jsonschema2pojo-gradle-plugin:1.1.2"
}
}
plugins {
id 'com.github.spotbugs' version '4.7.0'
id "com.github.hierynomus.license-report" version "0.15.0"
}
import com.github.spotbugs.snom.SpotBugsTask
def gradleVer = "4"
println "gradleVersion:" + gradle.gradleVersion
if (gradle.gradleVersion.startsWith("6")
|| gradle.gradleVersion.startsWith("5")
|| gradle.gradleVersion.startsWith("4.10")
|| gradle.gradleVersion.startsWith("4.9")
|| gradle.gradleVersion.startsWith("4.8")
|| gradle.gradleVersion.startsWith("4.7")) {
println "Gradle with version >= 4.7 detected"
gradleVer = "5"
} else {
println "Gradle with version < 4.7 detected"
}
apply plugin: 'maven'
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'io.spring.dependency-management'
//apply plugin: 'jsonschema2pojo'
if (!gradle.startParameter.isOffline()) {
apply plugin: 'checkstyle'
apply plugin: 'jacoco'
apply plugin: 'signing'
}
group 'com.webank'
version = "0.0.0"
def versionFile = file("VERSION")
versionFile.eachLine { line ->
version = line
}
println 'Current product version: ' + version
def repo ="${repoType}"
// Specify JDK version - may vary in different scenarios
sourceCompatibility = 1.8
targetCompatibility = 1.8
[compileJava, compileTestJava, javadoc]*.options*.encoding = 'UTF-8'
// In this section you declare where to find the dependencies of your project
repositories {
if (!gradle.startParameter.isOffline()) {
mavenLocal()
if ("cn" == repo) {
println "use cn repo"
maven {url "http://maven.aliyun.com/nexus/content/groups/public/"}
} else {
println "use default repo"
mavenCentral()
}
maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
maven { url "https://oss.sonatype.org/content/groups/public/" }
maven { url "http://maven.aliyun.com/nexus/content/groups/public/" }
} else {
maven {
url 'dependencies'
}
}
}
List lombok = [
"org.projectlombok:lombok:1.18.10"
]
def log4j_version="2.20.0"
List logger = [
"org.slf4j:jul-to-slf4j:1.7.30",
"org.apache.logging.log4j:log4j-api:$log4j_version",
"org.apache.logging.log4j:log4j-core:$log4j_version",
"org.apache.logging.log4j:log4j-slf4j-impl:$log4j_version",
"org.apache.logging.log4j:log4j-web:$log4j_version",
"org.apache.logging.log4j:log4j-jcl:$log4j_version",
"com.lmax:disruptor:3.3.7"
]
// junit test
List junit = [
"junit:junit:4.13.1"
]
List apache_commons = [
"org.apache.commons:commons-collections4:4.1",
"org.apache.commons:commons-lang3:3.5",
"commons-cli:commons-cli:1.3.1"
]
List jmockit = [
"org.jmockit:jmockit:1.47"
]
def jackson_version="2.14.2"
List json = [
"com.fasterxml.jackson.core:jackson-databind:$jackson_version",
"com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:$jackson_version",
"com.fasterxml.jackson.module:jackson-module-jsonSchema:$jackson_version",
"org.jsonschema2pojo:jsonschema2pojo-core:1.1.2",
"org.jsonschema2pojo:jsonschema2pojo-gradle-plugin:1.1.2",
"com.networknt:json-schema-validator:1.0.71",
]
def gson_version = "2.10.1"
List gson = [
"com.google.code.gson:gson:$gson_version"
]
List mysql_driver = [
"mysql:mysql-connector-java:8.0.20", // todo runtime
"org.apache.commons:commons-dbcp2:2.5.0"
]
List zxing = [
"com.google.zxing:core:3.3.3",
"com.google.zxing:javase:3.3.3"
]
List rpc = [
'org.smartboot.socket:aio-core:1.4.2',
'org.smartboot.socket:aio-pro:1.4.2'
]
List pdfbox = [
"org.apache.pdfbox:pdfbox:2.0.24"
]
List protobuf = [
"com.google.protobuf:protobuf-java:3.22.2"
]
List caffeine = [
"com.github.ben-manes.caffeine:caffeine:2.8.0"
]
List oval = [
"net.sf.oval:oval:3.2.1"
]
List spring = [
"org.springframework:spring-core:5.3.21",
"org.springframework:spring-context:5.3.25"
]
configurations {
localDeps
all*.exclude group: "io.netty", module: "netty-tcnative"
}
configurations.all {
resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
}
dependencies {
localDeps 'org.projectlombok:lombok:1.18.10'
if (!gradle.startParameter.isOffline()) {
compile logger, lombok, apache_commons, json, mysql_driver, zxing, rpc, pdfbox, protobuf, caffeine, oval, gson, spring
//compile("com.webank:weid-contract-java:1.3.2-rc.1-SNAPSHOT")
compile("com.webank:weid-contract-java:1.3.2-rc.1")
compile fileTree(dir: 'lib', include: '*.jar')
implementation 'com.google.guava:guava:31.1-jre'
implementation group: 'commons-codec', name: 'commons-codec', version: '1.15'
implementation group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.5.13'
implementation group: 'org.apache.httpcomponents', name: 'httpcore', version: '4.4.15'
annotationProcessor lombok
testCompile logger, lombok, apache_commons, json, junit, jmockit, rpc, pdfbox, protobuf, caffeine, oval, spring, gson
testAnnotationProcessor lombok
}
if (gradleVer.startsWith("4")) {
if (gradle.startParameter.isOffline()) {
compile fileTree(dir: 'dist/lib', include: '*.jar')
}
}
if (gradleVer.startsWith("5")) {
if (!gradle.startParameter.isOffline()) {
compileOnly 'org.projectlombok:lombok:1.18.10'
annotationProcessor 'org.projectlombok:lombok:1.18.10'
testAnnotationProcessor 'org.projectlombok:lombok:1.18.10'
testCompileOnly 'org.projectlombok:lombok:1.18.10'
} else {
compileOnly files('dist/lib/lombok-1.18.10.jar')
annotationProcessor files('dist/lib/lombok-1.18.10.jar')
testAnnotationProcessor files('dist/lib/lombok-1.18.10.jar')
testCompileOnly files('dist/lib/lombok-1.18.10.jar')
compile fileTree(dir: 'dist/lib', include: '*.jar')
}
}
}
sourceSets {
main {
java {
srcDirs = ['src/main/java']
}
resources {
srcDirs = ['src/main/resources']
}
}
test {
java {
srcDirs = ['src/test/java']
}
resources {
srcDirs = ['src/test/resources']
}
}
}
processResources {
exclude '**/**'
}
clean {
delete "dist"
}
task sourcesJar(type: Jar) {
classifier = 'sources'
from sourceSets.main.allSource
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from 'build/docs/javadoc'
}
//tasks.withType(Javadoc).all { enabled = false}
test {
systemProperty "jdk.tls.namedGroups", "${jdkTlsNamedGroups}"
jvmArgs "-javaagent:${classpath.find { it.name.contains("jmockit") }.absolutePath}"
doFirst {
copy {
from file('src/main/resources/WeDPR_dynamic_lib')
into 'src/test/resources/WeDPR_dynamic_lib'
}
}
}
artifacts {
archives jar
archives sourcesJar
archives javadocJar
}
jar {
baseName = project.name
destinationDir file('dist/app')
archiveName project.name + "-" + version + ".jar"
exclude '**/*.xml'
exclude '**/*.properties'
doLast {
copy {
from file('src/main/resources/')
into 'dist/conf'
}
if (!gradle.startParameter.isOffline()) {
copy {
from configurations.runtime
from configurations.testCompile.allArtifacts.files
from configurations.testCompile
from configurations.localDeps
into 'dist/lib'
}
}
}
}
if (!gradle.startParameter.isOffline()) {
jacocoTestReport {
reports {
xml.enabled true
html.enabled false
}
}
jacoco {
toolVersion = "0.8.5"
}
check.dependsOn jacocoTestReport
checkstyle {
// ignoreFailures false
ignoreFailures true //todo
showViolations true
toolVersion '8.12'
configProperties.projectDir = project.projectDir
checkstyleMain.configFile = new File(project.projectDir, '/config/checkstyle/webank_google_checks.xml')
checkstyleTest.configFile = new File(project.projectDir, '/config/checkstyle/webank_google_checks.xml')
}
tasks.withType(Checkstyle) {
include '**/*.java'
exclude '**/contract/deploy/*.java'
exclude '**/contract/deploy/v1/*.java'
exclude '**/contract/deploy/v2/*.java'
exclude '**/contract/v1/*.java'
exclude '**/contract/v2/*.java'
exclude '**/protocol/response/timestamp/wesign/*.java'
exclude '**/protocol/request/timestamp/wesign/*.java'
reports {
xml.enabled false
html.enabled true
}
}
spotbugs {
ignoreFailures = true // todo
showProgress = true
toolVersion = "4.2.2"
effort = "max"
reportLevel = "low"
excludeFilter = file("${project.rootDir}/config/spotbugs/spotbugs_filter.xml")
}
tasks.withType(SpotBugsTask) {
reports {
xml.enabled false
html.enabled true
html.stylesheet resources.text.fromFile('config/spotbugs.xsl')
}
}
uploadArchives {
repositories {
mavenDeployer {
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
authentication(userName: sonatypeUsername, password: sonatypePassword)
}
snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots") {
authentication(userName: sonatypeUsername, password: sonatypePassword)
}
pom.project {
name project.name
packaging 'jar'
description 'WeIdentity Blockchain'
url 'https://github.com/WeBankBlockchain/WeIdentity'
scm {
url 'scm:[email protected]:WeBankBlockchain/WeIdentity.git'
connection 'scm:[email protected]:WeBankBlockchain/WeIdentity.git'
developerConnection '[email protected]:WeBankBlockchain/WeIdentity.git'
}
licenses {
license {
name 'Apache License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
distribution 'repo'
}
}
developers {
developer {
id 'tonychen'
name 'tonychen'
}
}
}
}
}
}
signing {
required { gradle.taskGraph.hasTask("uploadArchives") }
sign configurations.archives
}
}
gradle.taskGraph.whenReady { taskGraph ->
if (taskGraph.allTasks.any { it.name == 'build' || it.name == 'assemble' }) {
tasks.findAll {
it.name == 'signArchives' || it.name == 'signDocsJar' || it.name == 'signTestJar'
}.each { task ->
task.enabled = false
}
}
}
// Each configuration is set to the default value
//jsonSchema2Pojo {
//
// // Location of the JSON Schema file(s). This may refer to a single file or a directory of files.
//// source = files("${sourceSets.main.output.resourcesDir}/json")
// source = files("D:\\projects\\weid\\WeIdentity\\src\\test\\resources\\default_cpt")
//
// // Target directory for generated Java source files. The plugin will add this directory to the
// // java source set so the compiler will find and compile the newly generated source files.
// targetDirectory = file("${project.buildDir}/generated-sources/new/js2p")
//
// // Package name used for generated Java classes (for types where a fully qualified name has not
// // been supplied in the schema using the 'javaType' property).
// targetPackage = 'com.webank.weid.blockchain.protocol.cpt.v2'
//
//}
//downloadLicenses {
// ext.apacheTwo = license('Apache License, Version 2.0', 'http://opensource.org/licenses/Apache-2.0')
// ext.bsd = license('BSD License', 'http://www.opensource.org/licenses/bsd-license.php')
//
// includeProjectDependencies = true
// licenses = [
// (group('com.myproject.foo')) : license('My Company License'),
// 'org.apache.james:apache-mime4j:0.6' : apacheTwo,
// 'org.some-bsd:project:1.0' : bsd
// ]
//
// aliases = [
// (apacheTwo) : ['The Apache Software License, Version 2.0', 'Apache 2', 'Apache License Version 2.0', 'Apache License, Version 2.0', 'Apache License 2.0', license('Apache License', 'http://www.apache.org/licenses/LICENSE-2.0')],
// (bsd) : ['BSD', license('New BSD License', 'http://www.opensource.org/licenses/bsd-license.php')]
// ]
//
// excludeDependencies = [
// 'com.some-other-project.bar:foobar:1.0'
// ]
//
// dependencyConfiguration = 'compile'
//}