-
Notifications
You must be signed in to change notification settings - Fork 4
/
build.gradle
215 lines (179 loc) · 7.64 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
import groovy.swing.SwingBuilder
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'foundation.icon:gradle-javaee-plugin:0.8.0'
// classpath files('.deployment/')
}
}
apply plugin: 'deploy-contracts'
deployOMMContracts {
envs {
local {
env = "local"
configFile = "staking-sicx.json"
keystore = 'godWallet.json'
password = 'gochain'
outputFile = "temp.json"
}
berlin {
env = "berlin"
configFile = "contracts-sample.json"
keystore = rootProject.findProperty('keystoreName') ?: ''
password = rootProject.findProperty('keystorePass') ?: ''
}
}
}
executeOMMActions {
contractAddressFile = "addresses-BERLIN-1649835786824.json"
propertiesFile = 'sample.properties'
actionsFile = 'actions-sample.json'
keystore = rootProject.findProperty('keystoreName') ?: ''
password = rootProject.findProperty('keystorePass') ?: ''
}
def scoreIntegrationTest = new HashMap<String, String>()
subprojects {
repositories {
mavenCentral()
flatDir {
dirs "$rootProject.projectDir/libs/jars"
}
}
apply plugin: 'foundation.icon.javaee'
sourceSets {
intTest {
compileClasspath += sourceSets.main.output
runtimeClasspath += sourceSets.main.output
java {
}
}
}
configurations {
intTestImplementation.extendsFrom testImplementation
intTestAnnotationProcessor.extendsFrom testAnnotationProcessor
intTestRuntimeOnly.extendsFrom testRuntimeOnly
}
ext {
env = has("network") ? getProperty("network") : 'dev'
javaeeVersion = findProperty("javaee.version") ?: '0.9.0'
scorexVersion = findProperty("scorex.version") ?: '0.5.2'
javaeeUnittestVersion = findProperty("javaee-unittest.version") ?: '0.9.2'
scoreClientVersion = findProperty("score-client.version") ?: '0.9.0'
iconsdkVersion = findProperty("iconsdk.version") ?: '2.0.0'
jacksonVersion = findProperty("jackson.version") ?: '2.13.2'
mockitoVersion = findProperty("mockito.version") ?: '4.3.1'
junitVersion = findProperty("junit.version") ?: '5.8.1'
javafakerVersion = findProperty("javafaker.version") ?: '1.0.2'
commonIOVersion = findProperty("common-io.version") ?: '2.11.0'
}
dependencies {
compileOnly "foundation.icon:javaee-api:$javaeeVersion"
implementation "foundation.icon:javaee-scorex:$scorexVersion"
implementation "com.github.sink772:minimal-json:0.9.6"
// compileOnly "foundation.icon:javaee-score-client:$scoreClientVersion"
compileOnly name: "score-client-$scoreClientVersion"
annotationProcessor "foundation.icon:javaee-score-client:$scoreClientVersion"
// annotationProcessor name:"score-client-0.9.0"
// Use JUnit Jupiter for testing.
// testImplementation "foundation.icon:javaee-score-client:$scoreClientVersion"
testImplementation name: "score-client-$scoreClientVersion"
testAnnotationProcessor "foundation.icon:javaee-score-client:$scoreClientVersion"
// testAnnotationProcessor name:"score-client-0.9.0"
testImplementation "foundation.icon:javaee-unittest:$javaeeUnittestVersion"
testImplementation "org.junit.jupiter:junit-jupiter:$junitVersion"
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$junitVersion"
testImplementation "org.mockito:mockito-core:$mockitoVersion"
testImplementation "foundation.icon:icon-sdk:$iconsdkVersion"
testImplementation("com.fasterxml.jackson.core:jackson-databind:$jacksonVersion")
testImplementation group: "org.json", name: "json", version: "20211205"
}
java {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
// need to add this option to retrieve formal parameter names
compileJava {
options.compilerArgs += ['-parameters']
}
def loadProperties = {
def prefix = 'score-test.'
def props = project.getProperties()
def scoreTest = new HashMap<String, Object>()
scoreTest.put('keystoreName', props.getOrDefault(prefix + 'keystoreName', "$rootDir/gochain-local/data/godWallet.json"))
scoreTest.put('keystorePass', props.getOrDefault(prefix + 'keystorePass', "gochain"))
scoreTest.put('url', props.getOrDefault(prefix + 'url', 'http://localhost:9082/api/v3'))
scoreTest.put('nid', props.getOrDefault(prefix + 'nid', 3))
ext['scoreTest'] = scoreTest
}
loadProperties()
//dummy
// scoreIntegrationTest.put('sICX', "https://raw.githubusercontent.com/openmoneymarket/omm-scores/master/dummy/sicx.zip");
// scoreIntegrationTest.put('Staking', "https://raw.githubusercontent.com/openmoneymarket/omm-scores/master/dummy/staking.jar");
scoreIntegrationTest.put('BandOracle', "https://raw.githubusercontent.com/openmoneymarket/omm-scores/master/dummy/proxy-band-oracle.zip");
scoreIntegrationTest.put('StableCoin', "https://raw.githubusercontent.com/openmoneymarket/omm-scores/master/dummy/stable-coin.zip");
scoreIntegrationTest.put('DEX', "https://raw.githubusercontent.com/openmoneymarket/omm-scores/master/dummy/dex.jar");
afterEvaluate { project ->
scoreIntegrationTest.put(project.name, project.getTasks().getByName("optimizedJar").outputJarName.toString())
}
}
gradle.taskGraph.beforeTask { Task task ->
if (task.name == 'integrationTest') {
scoreIntegrationTest.each { key, val ->
task.systemProperty key, val
}
task.systemProperty "DEBUG_ENABLED", false
task.systemProperty "BLOCK_INTERVAL", 50
task.systemProperty "DEFAULT_RESULT_RETRY_WAIT", 100
}
}
gradle.taskGraph.whenReady { taskGraph ->
def keystorePassword = rootProject.findProperty("keystorePass")
if (keystorePassword != null && !keystorePassword.toString().isEmpty()) {
return;
}
def moduleName = null;
def hasDeployTask = taskGraph.getAllTasks().any { it ->
def result = it.name == "deployToMainnet"
moduleName = it.project;
return result
}
if (hasDeployTask && moduleName != null) {
def pass = ''
if (System.console() == null) {
new SwingBuilder().edt {
dialog(modal: true,
title: 'Keystore password',
alwaysOnTop: true,
resizable: false,
locationRelativeTo: null,
pack: true,
show: true
) {
vbox {
hbox {
label(text: 'Please enter key passphrase: ')
}
hbox {
input = passwordField(columns: 20, id: 'password')
}
hbox {
button(defaultButton: true, text: 'OK', actionPerformed: {
pass = input.password;
dispose();
})
}
}
}
}
} else {
pass = System.console().readPassword("\nPlease enter key passphrase: ")
pass = new String(pass)
}
if (pass.size() <= 0) {
throw new InvalidUserDataException("You must enter a password to proceed.")
}
moduleName.extensions.findByName("deployJar").password = pass.toString()
}
}