forked from YongChengHQ/yongan-java-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
301 lines (270 loc) · 9.01 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
// Apply the java-library plugin to add support for Java Library
plugins {
id 'maven-publish'
id 'java-library'
id 'java'
id 'org.ajoberstar.grgit' version '4.1.1'
id 'com.github.sherter.google-java-format' version '0.9'
}
println("Notice: current gradle version is " + gradle.gradleVersion)
// Additional attribute definition
ext {
if (!project.hasProperty("ossrhUsername")) {
ossrhUsername = "glpat-NYtyzzohCkNmeczymdmB"
}
if (!project.hasProperty("ossrhPassword")) {
ossrhPassword = "xxx"
}
jacksonVersion = '2.13.2.2'
commonsIOVersion = '2.4'
commonsLang3Version = '3.12.0'
toml4jVersion = "0.7.2"
bcprovJDK15onVersion = '1.69'
webankJavaCryptoVersion = "1.0.3"
junitVersion = '4.13.2'
commonsCollections4Version = "4.4"
guavaVersion = '30.1.1-jre'
bcosSdkJniVersion = "3.0.0"
slf4jApiVerison = "1.7.36"
mockitoVersion = '4.7.0'
}
// check.dependsOn integrationTest
// integrationTest.mustRunAfter test
allprojects {
group = 'tech.yongcheng.yongan.java-sdk'
version = '3.0.1-SNAPSHOT'
apply plugin: 'maven-publish'
apply plugin: 'idea'
apply plugin: 'eclipse'
apply plugin: 'java'
apply plugin: 'java-library'
apply plugin: 'jacoco'
apply plugin: 'signing'
configurations.all {
resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
}
jacoco {
toolVersion = "0.8.6"
}
jacocoTestReport {
reports {
xml.enabled true
html.enabled false
}
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
// In this section you declare where to find the dependencies of your project
repositories {
mavenLocal()
mavenCentral()
maven { url "https://maven.aliyun.com/nexus/content/groups/public/" }
maven { url "https://oss.sonatype.org/service/local/staging/deploy/maven2" }
maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
}
dependencies {
api("org.slf4j:slf4j-api:${slf4jApiVerison}")
testImplementation("junit:junit:${junitVersion}")
testImplementation("org.apache.commons:commons-collections4:${commonsCollections4Version}")
testImplementation("com.google.guava:guava:${guavaVersion}")
testImplementation("org.mockito:mockito-core:${mockitoVersion}")
}
clean.doLast {
file("dist/apps/").deleteDir()
file("dist/conf/").deleteDir()
file("dist/lib/").deleteDir()
}
}
sourceSets {
main {
java {
srcDir "src/main/java"
}
buildscript
resources {
srcDir 'src/main/resources'
}
}
test {
java {
srcDir "src/test/java"
}
resources {
srcDir "src/test/resources"
}
}
integrationTest {
java {
compileClasspath += main.output + test.output
runtimeClasspath += main.output + test.output
srcDir file('src/integration-test/java')
}
resources.srcDir file('src/integration-test/resources')
}
integrationWasmTest {
java {
compileClasspath += main.output + test.output
runtimeClasspath += main.output + test.output
srcDir file('src/integration-wasm-test/java')
}
resources.srcDir file('src/integration-wasm-test/resources')
}
}
googleJavaFormat {
toolVersion = '1.7'
options style: 'AOSP'
source = sourceSets*.allJava
include '**/*.java'
exclude '**/*Test.java'
exclude '**/Test*.java'
exclude '**/Mock*.java'
}
dependencies {
api("org.fisco-bcos:bcos-sdk-jni:${bcosSdkJniVersion}") {
exclude group : "org.slf4j"
exclude group : "com.fasterxml.jackson.core"
}
api("org.bouncycastle:bcprov-jdk15on:${bcprovJDK15onVersion}")
api("org.apache.commons:commons-lang3:${commonsLang3Version}")
api("com.fasterxml.jackson.core:jackson-databind:${jacksonVersion}")
api("commons-io:commons-io:${commonsIOVersion}")
// api("com.webank:key-mini-toolkit:${keyMiniToolkit}")
api("com.webank:webank-blockchain-java-crypto:${webankJavaCryptoVersion}")
api("com.moandjiezana.toml:toml4j:${toml4jVersion}")
// api("org.apache.commons:commons-configuration2:${config2Version}"){
// exclude group: "commons-logging"
// }
integrationTestImplementation project
integrationWasmTestImplementation project
}
configurations.all {
resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
exclude group: 'ch.qos.logback', module: 'logback-classic'
exclude group: 'io.zipkin.brave', module: 'brave-tests'
}
configurations {
integrationTestImplementation.extendsFrom testImplementation
integrationTestRuntimeOnly.extendsFrom testRuntimeOnly
integrationWasmTestImplementation.extendsFrom testImplementation
integrationWasmTestImplementation.extendsFrom testRuntimeOnly
}
task integrationTest(type: Test) {
testClassesDirs = sourceSets.integrationTest.output.classesDirs
classpath = sourceSets.integrationTest.runtimeClasspath
}
task integrationWasmTest(type: Test) {
testClassesDirs = sourceSets.integrationWasmTest.output.classesDirs
classpath = sourceSets.integrationWasmTest.runtimeClasspath
}
javadoc {
options.addStringOption('Xdoclint:none', '-quiet')
options.addStringOption('encoding', 'UTF-8')
options.addStringOption('charSet', 'UTF-8')
}
/*task sourcesJar(type: Jar) {
from sourceSets.main.allJava
archiveClassifier = 'sources'
}*/
task javadocJar(type: Jar) {
from javadoc
archiveClassifier = 'javadoc'
}
publishing {
publications {
library(MavenPublication) {
from components.java
}
mavenJava(MavenPublication) {
artifactId "yongan-" + project.name
groupId project.group
version project.version
from components.java
//artifact sourcesJar
artifact javadocJar
pom {
name = 'yongan'
description = 'yongan java-sdk'
url = 'http://www.yong-cheng.org'
licenses {
license {
name = 'The Apache License, Version 2.0'
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
}
developers {
developer {
id = 'zhangsan'
name = 'zhangsan'
email = '[email protected]'
}
}
scm {
connection = 'https://github.com/FISCO-BCOS/java-sdk.git'
url = 'https://github.com/FISCO-BCOS/java-sdk.git'
}
}
}
}
repositories {
maven {
mavenLocal()
def releasesRepoURL = "https://git.yongcheng.tech/api/v4/projects/33/packages/maven"
def snapshotsRepoURL = "https://git.yongcheng.tech/api/v4/projects/33/packages/maven"
url = !version.endsWith("SNAPSHOT") ? releasesRepoURL : snapshotsRepoURL
credentials(HttpHeaderCredentials) {
name = 'Private-Token'
value = 'glpat-TA_TzM5ZLvsqn2E_Ro1b'
}
authentication {
header(HttpHeaderAuthentication)
}
}
}
/*signing {
sign publishing.publications.mavenJava
}*/
}
jar {
// destinationDir file('dist/apps')
archiveName "yongan-" + project.name + '-' + project.version + '.jar'
exclude '**/*.xml'
exclude '**/*.properties'
manifest {
try {
def repo = grgit.open(currentDir: project.rootDir)
if (repo != null) {
def date = new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
def branch = repo.branch.getCurrent().getName()
def commit = repo.head().getAbbreviatedId(40)
attributes(["Implementation-Timestamp": date,
"Git-Branch" : branch,
"Git-Commit" : commit
])
logger.info(" Commit : ")
logger.info(" => date: {}", date)
logger.info(" => branch: {}", branch)
logger.info(" => commit: {}", commit)
}
} catch (Exception e) {
logger.warn(' .git not exist, cannot found commit info, e: {}', e)
}
} from sourceSets.main.output
doLast {
copy {
from destinationDirectory
into 'dist/apps'
}
copy {
from configurations.runtimeClasspath
into 'dist/lib'
}
copy {
from file('src/test/resources/config-example.toml')
from file('src/test/resources/clog.ini')
from file('src/test/resources/applicationContext-sample.xml')
from file('src/test/resources/log4j.properties')
into 'dist/conf'
}
}
}
check.dependsOn jacocoTestReport