-
Notifications
You must be signed in to change notification settings - Fork 159
/
build.gradle.kts
200 lines (177 loc) · 6.74 KB
/
build.gradle.kts
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
plugins {
id("java")
id("jacoco")
id("signing")
id("maven-publish")
id("project-report")
id("com.diffplug.spotless") version "6.25.0"
id("com.github.ben-manes.versions") version "0.51.0"
id("io.freefair.lombok") version "8.10.2"
id("com.gradleup.nmcp") version "0.0.9"
}
group = "network.lightsail"
version = "1.0.0"
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
spotless {
java {
importOrder("java", "javax", "org.stellar")
removeUnusedImports()
googleJavaFormat()
}
}
repositories {
mavenCentral()
}
dependencies {
val okhttpVersion = "4.12.0"
implementation("com.squareup.okhttp3:okhttp:${okhttpVersion}")
implementation("com.squareup.okhttp3:okhttp-sse:${okhttpVersion}")
implementation("com.moandjiezana.toml:toml4j:0.7.2")
implementation("com.google.code.gson:gson:2.11.0")
implementation("org.bouncycastle:bcprov-jdk18on:1.79")
implementation("commons-codec:commons-codec:1.17.1")
testImplementation("org.mockito:mockito-core:5.14.2")
testImplementation("com.squareup.okhttp3:mockwebserver:${okhttpVersion}")
testImplementation("junit:junit:4.13.2")
testImplementation("org.bouncycastle:bcpkix-jdk18on:1.79") // mock https
testRuntimeOnly("org.junit.vintage:junit-vintage-engine:5.11.3")
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
}
tasks {
test {
useJUnitPlatform()
}
val sourcesJar by creating(Jar::class) {
archiveClassifier = "sources"
from(sourceSets.main.get().allSource)
}
val uberJar by creating(Jar::class) {
// https://docs.gradle.org/current/userguide/working_with_files.html#sec:creating_uber_jar_exampl
archiveClassifier = "uber"
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
from(sourceSets.main.get().output)
dependsOn(configurations.runtimeClasspath)
from({
configurations.runtimeClasspath.get().filter { it.name.endsWith("jar") }.map { zipTree(it) }
})
exclude("META-INF/*.SF", "META-INF/*.DSA", "META-INF/*.RSA") // exclude signature files in org.bouncycastle:bcprov-jdk18on
}
javadoc {
setDestinationDir(file("javadoc"))
isFailOnError = false
options {
// https://docs.gradle.org/current/javadoc/org/gradle/external/javadoc/StandardJavadocDocletOptions.html
this as StandardJavadocDocletOptions
isSplitIndex = true
memberLevel = JavadocMemberLevel.PUBLIC
encoding = "UTF-8"
}
}
val javadocJar by creating(Jar::class) {
archiveClassifier = "javadoc"
dependsOn(javadoc)
from(javadoc.get().destinationDir) // It needs to be placed after the javadoc task, otherwise it cannot read the path we set.
}
register<Copy>("updateGitHook") {
from("scripts/pre-commit.sh") { rename { it.removeSuffix(".sh") } }
into(".git/hooks")
doLast {
file(".git/hooks/pre-commit").setExecutable(true)
}
}
jacocoTestReport {
reports {
html.required = true
xml.required = true
}
classDirectories.setFrom(files(classDirectories.files.map {
fileTree(it) {
exclude("org/stellar/sdk/xdr/**")
}
}))
}
check {
dependsOn(jacocoTestReport)
}
compileJava {
options.encoding = "UTF-8"
}
compileTestJava {
options.encoding = "UTF-8"
}
}
artifacts {
archives(tasks.jar)
archives(tasks["uberJar"])
archives(tasks["javadocJar"])
archives(tasks["sourcesJar"])
}
publishing {
publications {
create<MavenPublication>("mavenJava") {
artifactId = "stellar-sdk"
from(components["java"])
artifact(tasks["uberJar"])
artifact(tasks["javadocJar"])
artifact(tasks["sourcesJar"])
pom {
name.set("stellar-sdk")
description.set("The Java Stellar SDK library provides APIs to build transactions and connect to Horizon and Soroban-RPC server.")
url.set("https://github.com/lightsail-network/java-stellar-sdk")
licenses {
license {
name.set("The Apache License, Version 2.0")
url.set("https://github.com/lightsail-network/java-stellar-sdk/blob/master/LICENSE")
distribution.set("https://github.com/lightsail-network/java-stellar-sdk/blob/master/LICENSE")
}
}
developers {
developer {
id.set("overcat")
name.set("Jun Luo")
url.set("https://github.com/overcat")
}
organization {
name.set("Lightsail Network")
url.set("https://github.com/lightsail-network")
}
}
scm {
url.set("https://github.com/lightsail-network/java-stellar-sdk")
connection.set("scm:git:https://github.com/lightsail-network/java-stellar-sdk.git")
developerConnection.set("scm:git:ssh://[email protected]/lightsail-network/java-stellar-sdk.git")
}
}
}
}
}
signing {
val publishCommand = "publishAllPublicationsToCentralPortal"
isRequired = gradle.startParameter.taskNames.contains(publishCommand)
println("Need to sign? $isRequired")
// https://docs.gradle.org/current/userguide/signing_plugin.html#using_in_memory_ascii_armored_openpgp_subkeys
// export SIGNING_KEY=$(gpg2 --export-secret-keys --armor {SIGNING_KEY_ID} | grep -v '\-\-' | grep -v '^=.' | tr -d '\n')
val signingKey = System.getenv("SIGNING_KEY")
val signingKeyId = System.getenv("SIGNING_KEY_ID")
val signingPassword = System.getenv("SIGNING_PASSWORD")
if (isRequired && (signingKey == null || signingKeyId == null || signingPassword == null)) {
throw IllegalStateException("Please set the SIGNING_KEY, SIGNING_KEY_ID, and SIGNING_PASSWORD environment variables.")
}
println("Signing Key ID: $signingKeyId")
useInMemoryPgpKeys(signingKeyId, signingKey, signingPassword)
sign(publishing.publications["mavenJava"])
}
nmcp {
// https://github.com/GradleUp/nmcp
publishAllProjectsProbablyBreakingProjectIsolation {
username = System.getenv("SONATYPE_USERNAME")
password = System.getenv("SONATYPE_PASSWORD")
// publish manually from the portal
publicationType = "USER_MANAGED"
// or if you want to publish automatically
// publicationType = "AUTOMATIC"
}
}