-
Notifications
You must be signed in to change notification settings - Fork 20
/
build.gradle
378 lines (328 loc) · 10.7 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
//TODO task for updating dependent libs (jar+native) from kernel
buildscript {
repositories {
mavenLocal()
mavenCentral()
jcenter()
}
}
plugins {
id "com.jfrog.bintray" version "1.7.3"
id "maven-publish"
id "java"
id "idea"
}
repositories {
mavenLocal()
mavenCentral()
jcenter()
maven {
url "https://dl.bintray.com/aionjayt/aion_api"
url "${rootDir}/lib/maven_repo"
}
flatDir { dirs './lib' }
}
ext.moduleName = 'aion.api.client'
targetCompatibility = 10
sourceCompatibility = 10
/**
* Name of Aion root project (not aion_api); used to detect if we're being called with
* as a subproject or root project.
*/
def AION_PROJECT_NAME = 'aion'
group = 'org.aion.network'
version = '0.1.15'
sourceSets {
main {
java.srcDirs = ['src']
}
test {
java.srcDirs = ['test']
}
integTest {
java {
srcDirs = ['integration-test']
compileClasspath += main.output + test.output
runtimeClasspath += main.output + test.output
}
}
}
afterEvaluate {
// Override java plug-in behaviour to make JDK9+ module logic work
// From: https://guides.gradle.org/building-java-9-modules/#step_2_produce_java_9_modules_for_all_subprojects
compileJava {
inputs.property("moduleName", moduleName)
doFirst {
options.compilerArgs = [
'--module-path', classpath.asPath,
]
classpath = files()
}
}
// Need to comment this out for now, modules-info.java doesn't have 'require' declarations
// used by the test code. The ant build.xml, similarly, uses module-path for build, but
// classpath for building the tests (at least in modRlp). Need to sort out how to properly set the module-path
// for the tests before using the stuff below.
/*
compileTestJava {
inputs.property("moduleName", moduleName)
doFirst {
options.compilerArgs = [
'--module-path', classpath.asPath,
'--add-modules', 'junit',
'--add-reads', "$moduleName=junit",
'--patch-module', "$moduleName=" + files(sourceSets.test.java.srcDirs).asPath,
]
classpath = files()
}
}
test {
inputs.property("moduleName", moduleName)
doFirst {
jvmArgs = [
'--module-path', classpath.asPath,
'--add-modules', 'ALL-MODULE-PATH',
'--add-reads', "$moduleName=junit",
'--patch-module', "$moduleName=" + files(sourceSets.test.java.outputDir).asPath,
]
classpath = files()
}
}
*/
}
dependencies {
compile 'network.aion:modAionBase:0.3.2'
compile 'network.aion:modCrypto:0.3.2'
compile 'network.aion:modLogger:0.3.2'
compile 'network.aion:modRlp:0.3.2'
compile 'network.aion:3rdParty.libnzmq:0.3.4'
compile 'com.madgag.spongycastle:prov:1.58.0.0'
compile 'com.madgag.spongycastle:core:1.58.0.0'
compile group: 'org.apache.commons', name: 'commons-collections4', version: '4.0'
compile 'org.slf4j:slf4j-api:1.7.25'
compile group: 'com.google.protobuf', name: 'protobuf-java', version: '3.5.0'
compile group: 'com.google.code.gson', name: 'gson', version: '2.7'
compile 'ch.qos.logback:logback-core:1.2.3'
compile 'ch.qos.logback:logback-classic:1.2.3'
compile 'com.google.code.findbugs:jsr305:3.0.2'
testCompile 'junit:junit:4.12'
testCompile 'com.google.truth:truth:0.42'
testCompile 'org.hamcrest:hamcrest-all:1.3'
}
// TODO just implement the script as Groovy here instead of calling sh
task preBuild(type: Exec) { commandLine 'sh', 'script/prebuild.sh' }
task getVersion(type: JavaExec) {
description "Execute the apiDemo to get the version of release"
classpath = sourceSets.main.runtimeClasspath
main = 'org.aion.api.tools.ApiDemo'
args '-v'
standardOutput = new ByteArrayOutputStream()
project.ext["compiled_version"] = "Unknown"
doLast {
def date = new Date().format('YY-MM-dd')
project.ext["compiled_version"] = standardOutput.toString().replace('\n', '') + '-' + date
}
}
task cleanPack {
delete "pack"
}
task configFatJar {
dependsOn getVersion
doLast {
fatJar.archiveName = "libAionApi-v${project.ext["compiled_version"]}.jar"
}
}
task fatJar(type: Jar) {
dependsOn configFatJar
description "Produce JAR containing all dependencies and runs demo as main class"
dependsOn getVersion
manifest {
attributes 'Main-Class': 'org.aion.api.tools.ApiDemo',
'Implementation-Vendor': 'The Aion Foundation',
'Implementation-Vendor-Id': 'aion.network',
'Specification-Title': 'Aion Foundation Java API'
}
from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
with jar
destinationDir file('build')
}
task collectDependentJars(type: Copy) {
description = "Put all runtime jars (mod* and dependencies) into jars directory"
into 'jars'
from { project.configurations.runtime }
from { project.jar }
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}
javadoc {
include "org/aion/api/I*.java"
include "org/aion/api/sol/I*.java"
include "org/aion/api/type/AccountDetails.java"
include "org/aion/api/type/ApiMsg.java"
include "org/aion/api/type/Block.java"
include "org/aion/api/type/BlockDetails.java"
include "org/aion/api/type/BlockSql.java"
include "org/aion/api/type/CompileResponse.java"
include "org/aion/api/type/ContractAbiEntry.java"
include "org/aion/api/type/ContractAbiIOParam.java"
include "org/aion/api/type/ContractDeploy.java"
include "org/aion/api/type/ContractEvent.java"
include "org/aion/api/type/ContractEventFilter.java"
include "org/aion/api/type/ContractResponse.java"
include "org/aion/api/type/DeployResponse.java"
include "org/aion/api/type/Event.java"
include "org/aion/api/type/JsonFmt.java"
include "org/aion/api/type/Key.java"
include "org/aion/api/type/KeyExport.java"
include "org/aion/api/type/MsgRsp.java"
include "org/aion/api/type/Node.java"
include "org/aion/api/type/Protocol.java"
include "org/aion/api/type/SyncInfo.java"
include "org/aion/api/type/Transaction.java"
include "org/aion/api/type/TxArgs.java"
include "org/aion/api/type/TxDetails.java"
include "org/aion/api/type/TxLog.java"
include "org/aion/api/type/TxReceipt.java"
options.bottom = '<i>Copyright (c) 2017-2018 Aion foundation</i>'
title "Aion API"
}
task javadocZip(type: Zip) {
dependsOn javadoc
dependsOn getVersion
classifier = 'javadoc'
doFirst {
archiveName = "Java-API-v${project.ext["compiled_version"]}-doc.zip"
}
destinationDir = file('build/')
from javadoc.outputs
}
task postBuildTar(type: Tar) {
description "Creates the full libAionApi-VERSION.tar.gz for distribution"
dependsOn fatJar
dependsOn getVersion
dependsOn javadocZip
compression = Compression.GZIP
destinationDir = file('pack/')
doFirst {
mkdir 'pack'
archiveName = "libAionApi-v${project.ext["compiled_version"]}.tar.gz"
ant.echo("Aion Api build ver - ${project.ext["compiled_version"]}")
}
into('/') {
from 'build'
include "Java-API-v*-doc.zip"
include "libAionApi-v*.jar"
}
into('/native') {
from 'native'
include '**'
}
// This is needed so Gradle notices in case pack dir gets deleted,
// and causes it to re-run this task to create the tar file again.
// Not sure why pack gets deleted by Gradle sometimes.
outputs.dir destinationDir
}
task configExtractTarToPack {
dependsOn postBuildTar
doLast {
extractTarToPack.from tarTree("${postBuildTar.destinationDir}/" + "libAionApi-v${project.ext["compiled_version"]}.tar.gz")
}
}
task extractTarToPack(type: Copy) {
dependsOn configExtractTarToPack
dependsOn postBuildTar
destinationDir = file('pack')
}
task postBuildRevertVersion(type: Exec) {
description "Reverts the in-code version change applied by prebuild"
commandLine 'git', 'checkout', './src/org/aion/api/IAionAPI.java'
}
build.dependsOn.remove("check") // these are integ tests
build.finalizedBy(extractTarToPack)
compileJava.dependsOn preBuild
compileJava.finalizedBy(postBuildRevertVersion)
clean.doFirst {
delete "pack"
}
def pomConfig = {
licenses {
license {
name = 'MIT License'
url = 'https://github.com/aionnetwork/aion_api/blob/master/LICENSE'
}
}
developers {
developer {
id = 'aion developers'
name = 'aion developers'
email = 'https://aion.network'
}
}
scm {
connection = 'scm:git:git://github.com/aionnetwork/aion_api.git'
developerConnection = 'scm:git:ssh://github.com:aionnetwork/aion_api.git'
url = 'https://github.com/aionnetwork/aion_api/tree/master'
}
}
task nativeZip(type: Zip) {
classifier = 'native'
from 'native/'
include '**'
archiveName 'native.zip'
destinationDir = file('build/')
}
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allSource
}
artifacts {
archives fatJar
archives javadocZip
archives nativeZip
archives sourcesJar
}
publishing {
publications {
mavenJava(MavenPublication) {
groupId 'org.aion.network'
artifactId = 'aionapi'
artifact fatJar
artifact javadocZip
artifact nativeZip
artifact sourcesJar
pom.withXml {
def root = asNode()
root.appendNode('description', 'Client api for aion kernel')
root.appendNode('name', 'aion_api')
root.appendNode('url', 'https://github.com/aionnetwork/aion_api/tree/master')
root.children().last() + pomConfig
}
}
}
}
def pomFile = 'aion_api-0.1.15.pom'
bintray {
user = System.getProperty('bintray.user')
key = System.getProperty('bintray.key')
publications = ['mavenPublication']
configurations = ['archives']
filesSpec {
from './'
include 'pom.xml'
into 'org/aion/network/aion_api/0.1.15/'
rename('pom.xml', 'aion_api-0.1.15.pom')
}
pkg {
repo = 'aion_api'
name = 'aion_api'
userOrg = 'aionjayt'
licenses = ['MIT']
vcsUrl = 'https://github.com/aionnetwork/aion_api.git'
version {
name = '0.1.15'
desc = '0.1.15'
released = new Date()
}
}
publish = true
override = true
}