forked from ether-camp/ethereum-harmony
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
392 lines (314 loc) · 11.9 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
/*
* Copyright 2015, 2016 Ether.Camp Inc. (US)
* This file is part of Ethereum Harmony.
*
* Ethereum Harmony is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Ethereum Harmony is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Ethereum Harmony. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* Tasks:
* - runMain
* - runClassic
* - runRopsten
* - runTest
* - runPrivate
* - bootRun
*
* Gradle options (supplied with `-P` prefix):
* - jvmArgs - adding Java VM options;
* - useMavenLocal - prefer locally installed maven libraries.
*
* System properties (supplied with `-D` prefix):
* - see `user.conf` or https://github.com/ethereum/ethereumj/blob/master/ethereumj-core/src/main/resources/ethereumj.conf
*
* Default heap size is 1.5G, unless user change via command line or run `runPrivate` task,
* which sets 3.5 GB.
*/
ext.maxHeapSize = '-Xmx1500m' // default is 1G, but could be changed via command line or launched task type
buildscript {
repositories {
mavenCentral()
maven { url "https://plugins.gradle.org/m2/" }
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.4.1.RELEASE")
classpath "com.github.jengelman.gradle.plugins:shadow:1.2.4"
classpath "co.riiid:gradle-github-plugin:0.4.2" // github releases
}
}
apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'spring-boot'
apply plugin: 'application'
apply plugin: "com.github.johnrengelman.shadow"
// check if -PuseMavenLocal is supplied
if (project.hasProperty('useMavenLocal')) {
println "Flag enabled: using EthereumJ jar from maven local repo if exist"
repositories {
mavenLocal()
}
}
repositories {
// mavenLocal()
jcenter()
mavenCentral()
maven { url "https://oss.jfrog.org/libs-snapshot/" }
maven { url "https://dl.bintray.com/ethereum/maven/" }
maven { url "https://repo.spring.io/libs-snapshot" }
}
dependencies {
if (JavaVersion.current().ordinal() > 7) { // Java 9+ compatibility
compile 'javax.xml.bind:jaxb-api:2.2.11'
compile 'com.sun.xml.bind:jaxb-core:2.2.11'
compile 'com.sun.xml.bind:jaxb-impl:2.2.11'
compile 'javax.xml.ws:jaxws-api:2.2.11'
}
compile "org.springframework.boot:spring-boot-starter-web"
compile "org.springframework.boot:spring-boot-starter-actuator"
compile "org.springframework.boot:spring-boot-starter-websocket"
compile "org.springframework.boot:spring-boot-starter-data-jpa"
// compile "org.springframework.boot:spring-boot-devtools"
compile "org.hsqldb:hsqldb"
compile 'com.h2database:h2:1.4.191'
// compile "com.google.guava:guava:19.0"
// Be sure also change value inside `ContractsTests.java`
compile "org.ethereum:solcJ-all:0.4.8" // Solidity Compiler win/mac/linux binaries
// don't forget to adjust {ethereumJ.version} in application.properties
compile ("org.ethereum:ethereumj-core:1.7.0-SNAPSHOT") {
changing = true
exclude group: "log4j"
exclude group: "org.slf4j", module: "log4j-over-slf4j"
exclude group: "org.slf4j", module: "slf4j-log4j12"
exclude group: "org.ethereum", module: "solcJ-all"
}
compile "com.ethercamp:contract-data:1.4.0"
compile "org.projectlombok:lombok:1.16.20"
compile "com.maxmind.geoip:geoip-api:1.3.1"
compile "com.github.briandilley.jsonrpc4j:jsonrpc4j:1.5.3"
compile "javax.portlet:portlet-api:2.0"
compile "org.apache.commons:commons-io:1.3.2"
compile "org.functionaljava:functionaljava:4.6"
compile "org.functionaljava:functionaljava-java8:4.6"
compile "com.mashape.unirest:unirest-java:1.3.1"
/* WEB DEPENDENCIES */
compile("org.webjars.bower:bootstrap:3.3.6")
compile("org.webjars:jquery:2.2.4")
// compile("org.webjars.bower:angular:1.5.8")
compile("org.webjars.bower:angular-route:1.5.8")
compile("org.webjars.bower:angular-animate:1.5.8")
compile("org.webjars.bower:sockjs-client:1.1.1")
compile("org.webjars.bower:filesize:3.2.1")
compile("org.webjars.bower:toastr:2.1.2")
compile("org.webjars.bower:pace:1.0.2")
compile("org.webjars.bower:font-awesome:4.6.3")
compile("org.webjars.bower:animate.css:3.5.2")
compile("org.webjars.bower:moment:2.14.1")
compile("org.webjars.bower:datamaps:0.5.7")
compile("org.webjars.bower:d3:3.5.17")
compile("org.webjars.bower:topojson:1.6.26")
// compile("org.webjars:jquery.terminal:0.10.11")
compile("org.webjars.bower:jquery-mousewheel:3.1.13")
compile("org.webjars.bower:malihu-custom-scrollbar-plugin:3.1.5")
// compile("org.webjars.bower:ng-scrollbars:0.0.10")
compile("org.webjars.bower:angular-ui:0.4.0")
compile("org.webjars.bower:underscore:1.8.3")
compile("org.webjars.npm:bignumber.js:2.4.0")
// desktop GUI
compile group: 'com.dorkbox', name: 'SystemTray', version: '2.20'
compile group: 'org.codehaus.janino', name: 'janino', version: '3.0.6' // for having if-statement in logback.xml
testCompile "junit:junit"
testCompile "org.springframework:spring-test"
testCompile "org.springframework.boot:spring-boot-starter-test"
// compile group: 'org.springframework', name: 'spring-test', version: '2.5'
}
apply from: 'desktop.gradle'
mainClassName = 'com.ethercamp.harmony.Application'
def defaultJvmArgs = ["-server",
"-Xss2M",
"-XX:+UseCompressedOops",
"-XX:+HeapDumpOnOutOfMemoryError",
"-XX:-OmitStackTraceInFastThrow"]
applicationDefaultJvmArgs = []
task wrapper(type: Wrapper) {
gradleVersion = '4.6'
}
task stage {
dependsOn bootRepackage
}
// note that the code in the block below get executed at early beginning
// when gradle parses script
bootRun {
// point logback to config to use
// without this line logback will warn that it finds 2 files (in core.jar and in this app)
putIfEmpty System.properties, "logback.configurationFile", "src/main/resources/logback.xml"
systemProperties = System.properties
addResources = true
def args = []
args.addAll(defaultJvmArgs)
if ( project.hasProperty('jvmArgs') ) {
println "Adding properties from jvmArgs " + project.jvmArgs
project.jvmArgs.split('\\s+').each {
if (it) { // prevent empty string, which could cause "Error: Could not find or load main class"
args.add(it)
}
}
}
jvmArgs.addAll(args)
// println "After adding " + jvmArgs
}
bootRepackage {
excludeDevtools = true
}
springBoot {
mainClass = "com.ethercamp.harmony.Application"
}
test {
dependsOn cleanTest
testLogging.showStandardStreams = true
}
sourceCompatibility=1.8
// to keep method arguments names in bytecode
// used for terminal code completion
[compileJava, compileTestJava]*.options*.compilerArgs = ['-parameters']
//configurations.all {
// // check for updates every build
// resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
//}
/**
* Tasks for connecting to predefined networks.
* It is not possible to override task defined values from command line.
*/
task runMain() {
doLast {
addJvmArgIfEmpty "database.dir", getDatabaseDir("database")
addJvmArgIfEmpty "sync.fast.enabled", "true"
addJvmArgIfEmpty "ethereumj.conf.res", "ethereumj.conf"
addJvmArgIfEmpty "database.name", "database"
addJvmArgIfEmpty "networkProfile", "main"
bootRunWithNetworkConfig('main', false)
}
}
task runRopsten() {
doLast {
bootRunWithNetworkConfig('ropsten', true)
}
}
task runTest() {
doLast {
bootRunWithNetworkConfig('test', true)
}
}
task runPrivate() {
doLast {
// change default max heap value for this task as it involves mining
maxHeapSize = "-Xmx3500M"
bootRunWithNetworkConfig('private', true)
}
}
task runClassic() {
doLast {
addJvmArgIfEmpty "sync.fast.enabled", "true"
bootRunWithNetworkConfig('classic', true)
}
}
task runCustom() {
doLast {
def newArgs = []
newArgs.add('-DnetworkProfile=custom')
if (System.getProperty('ethereumj.conf.file') == null) {
addJvmArgIfEmpty "database.dir", getDatabaseDir("database-custom")
}
// set heap size configure in task
if (!project.hasProperty('jvmArgs') || project.jvmArgs.indexOf('-Xmx') == -1) {
println('Set default heap size for task ' + maxHeapSize)
newArgs.add(maxHeapSize)
} else {
println('Using heap size from user input ' + project.jvmArgs)
}
bootRun.jvmArgs.addAll(newArgs)
println 'Running Java with ' + bootRun.jvmArgs
tasks.compileJava.execute()
tasks.bootRun.execute()
}
}
def getDatabaseDir(String name) {
return System.getProperty("user.home") + "/ethereumj/" + name
}
def bootRunWithNetworkConfig(String name, boolean includePresets) {
def newArgs = []
if (includePresets) {
addJvmArgIfEmpty "database.dir", getDatabaseDir("database-" + name)
newArgs.addAll([
'-Dethereumj.conf.res=' + name + '.conf',
'-Ddatabase.name=database-' + name,
'-DnetworkProfile=' + name])
}
// set heap size configure in task
if (!project.hasProperty('jvmArgs') || project.jvmArgs.indexOf('-Xmx') == -1) {
println('Set default heap size for task ' + maxHeapSize)
newArgs.add(maxHeapSize)
} else {
println('Using heap size from user input ' + project.jvmArgs)
}
bootRun.jvmArgs.addAll(newArgs)
println 'Running Java with ' + bootRun.jvmArgs
tasks.compileJava.execute()
tasks.bootRun.execute()
}
def putIfEmpty(Properties properties, String key, String value) {
// don't use System.hasProperty as it is groovy wrapper
if (System.getProperty(key) == null) {
properties.put key, value
}
}
def addJvmArgIfEmpty(String key, String value) {
boolean hasSystemProperty = System.getProperty(key) != null;
if (!hasSystemProperty) {
bootRun.jvmArgs.add('-D' + key + '=' + value)
}
}
task webjar(type: Jar, dependsOn: "jar") {
from(fileTree("dist")) {
into "META-INF/resources"
}
}
/**
* Run import blocks action.
* Be sure to pass genesis, database location and path to blocks.
* @example `./gradlew
* -Ddatabase.dir=database-private -Dgenesis=frontier-private.json
* -Dblocks.loader=blocks.rlp -Dblocks.format=rlp`
*/
task importBlocks(type: JavaExec) {
main "org.ethereum.Start"
classpath sourceSets.main.runtimeClasspath
description "Running import blocks"
// pass CLI properties (set of -Dprop=value) to forked java process
systemProperties System.properties
systemProperty "logback.configurationFile", "src/main/resources/logback.xml"
systemProperty "peer.discovery.enabled", false
systemProperty "peer.listen.port", 0
systemProperty "sync.enabled", false
}
//
//tasks.processResources.doLast() {
// println 'This will be printed after the build task even if something else calls the build task'
//
// File versionfile = file(new File('build/resources/main/build-info.properties'))
// versionfile.text = [
//// 'build.hash=' + gitCommitHash(),
//// 'build.time=' + buildTime(),
//// 'build.branch=' + gitCurBranch(),
// 'build.number=' + getNextBuildNumber()
// ].join('\n')
//}