forked from icon-project/btp2-java
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
175 lines (158 loc) · 5.61 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
import java.nio.file.Files
buildscript {
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
classpath 'foundation.icon:gradle-javaee-plugin:0.8.3'
}
}
subprojects {
repositories {
mavenLocal()
mavenCentral()
}
configurations.configureEach {
resolutionStrategy {
cacheChangingModulesFor 1, 'minutes'
}
}
apply plugin: 'java'
apply plugin: 'foundation.icon.javaee'
java {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
ext {
javaeeVersion = getProperty("javaee.version")
scorexVersion = getProperty("scorex.version")
javaeeUnittestVersion = getProperty("javaee-unittest.version")
scoreClientVersion = getProperty("score-client.version")
iconsdkVersion = getProperty("iconsdk.version")
jupiterVersion = getProperty("jupiter.version")
jacksonVersion = getProperty("jackson.version")
debugJar = Boolean.parseBoolean(getProperty("debugJar").toString())
integrationTest = Boolean.parseBoolean(getProperty("integrationTest").toString())
}
def loadProperties = {
def prefix = 'score-test.'
def props = project.getProperties()
def scoreTest = new HashMap<String, Object>()
def keySet = ['keyStore','keyPassword','keySecret']
props.each {
if (it.key.startsWith(prefix)) {
def splited = it.key.split("\\.")
if (splited.length == 3) {
def user = splited[1]
def key = splited[2]
if (keySet.contains(key)) {
def obj = scoreTest.getOrDefault(user, new HashMap<String, String>())
obj.put(key, it.value.toString())
scoreTest.put(user, obj)
}
}
}
}
scoreTest.each {
def resolvedKeyPassword = it.value.get('keyPassword')
if (resolvedKeyPassword == null) {
if (it.value.containsKey('keySecret')) {
resolvedKeyPassword = Files.readString(
java.nio.file.Path.of(it.value.get('keySecret').toString()))
}
}
it.value.put('resolvedKeyPassword', resolvedKeyPassword)
}
scoreTest.put('url', props.getOrDefault(prefix + 'url', 'http://localhost:9082/api/v3'))
scoreTest.put('nid', props.getOrDefault(prefix + 'nid', 3))
scoreTest.put('parseNid', { Object v ->
if (v instanceof String) {
return v.startsWith("0x") ?
Integer.parseInt(v.substring(2), 16) :
Integer.parseInt(v)
} else {
return v as int
}
})
if (!scoreTest.containsKey("default")) {
scoreTest.put("default", Map.of("keyStore","","keySecret","","resolvedKeyPassword",""))
}
if (!scoreTest.containsKey("tester")) {
scoreTest.put("tester", Map.of("keyStore","","keySecret","","resolvedKeyPassword",""))
}
ext['scoreTest'] = scoreTest
}
loadProperties()
}
configure([
project(':lib'),
project(':xcall'),
]) {
apply plugin: 'maven-publish'
apply plugin: 'signing'
task sourcesJar(type: Jar, dependsOn: classes) {
classifier 'sources'
from sourceSets.main.allSource
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier 'javadoc'
from javadoc.destinationDir
}
group = getProperty("group")
def projectName = 'btp2-'+ project.name.replaceAll("_","-")
def repoUrl = 'https://github.com/icon-project/btp2-java'
def pomConfig = {
licenses {
license {
name "The Apache Software License, Version 2.0"
url "http://www.apache.org/licenses/LICENSE-2.0.txt"
distribution "repo"
}
}
developers {
developer {
id "iconfoundation"
name "icon.foundation"
email "[email protected]"
}
}
scm {
url repoUrl
}
}
publishing {
repositories {
maven {
name = 'mavenCentral'
def releasesUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2"
def snapshotsUrl = "https://oss.sonatype.org/content/repositories/snapshots"
url = rootProject.hasProperty('release') ? releasesUrl : snapshotsUrl
credentials {
username = rootProject.hasProperty('mavenCentralUsername') ? "$mavenCentralUsername" : ''
password = rootProject.hasProperty('mavenCentralPassword') ? "$mavenCentralPassword" : ''
}
}
}
publications {
mavenJava(MavenPublication) {
groupId = group
artifactId = projectName
from components.java
artifact sourcesJar
artifact javadocJar
pom.withXml {
def root = asNode()
root.appendNode('name', projectName)
root.appendNode('description', 'Java Contracts for BTP2')
root.appendNode('url', repoUrl)
root.children().last() + pomConfig
}
}
}
}
signing {
required rootProject.hasProperty('release')
sign publishing.publications.mavenJava
}
}