-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
122 lines (111 loc) · 4.11 KB
/
build.gradle.kts
File metadata and controls
122 lines (111 loc) · 4.11 KB
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
plugins {
id("java")
id("signing")
id("maven-publish")
id("project-report")
id("com.diffplug.spotless") version "8.4.0"
id("com.github.ben-manes.versions") version "0.54.0"
id("com.gradleup.nmcp").version("1.4.4")
}
group = "network.lightsail"
version = "3.0.0"
java {
toolchain {
// Build with the current LTS JDK while keeping published artifacts
// compatible with Java 8 bytecode via `options.release = 8`.
languageVersion = JavaLanguageVersion.of(21)
}
withJavadocJar()
withSourcesJar()
}
spotless {
java {
importOrder("java", "javax", "org.stellar")
removeUnusedImports()
googleJavaFormat()
}
}
repositories {
mavenCentral()
}
dependencies {
implementation("network.lightsail:stellar-sdk:3.0.0")
}
tasks {
register<Copy>("updateGitHook") {
from("scripts/pre-commit.sh") { rename { it.removeSuffix(".sh") } }
into(".git/hooks")
doLast {
file(".git/hooks/pre-commit").setExecutable(true)
}
}
compileJava {
options.encoding = "UTF-8"
options.release = 8
}
compileTestJava {
options.encoding = "UTF-8"
}
}
publishing {
publications {
create<MavenPublication>("mavenJava") {
artifactId = "stellar-sdk-android-spi"
from(components["java"])
pom {
name.set("stellar-sdk-android-spi")
description.set("Java Stellar SDK Android SPI implementation")
url.set("https://github.com/lightsail-network/java-stellar-sdk-android-spi")
licenses {
license {
name.set("The Apache License, Version 2.0")
url.set("https://github.com/lightsail-network/java-stellar-sdk-android-spi/blob/main/LICENSE")
distribution.set("https://github.com/lightsail-network/java-stellar-sdk-android-spi/blob/main/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-android-spi")
connection.set("scm:git:https://github.com/lightsail-network/java-stellar-sdk-android-spi.git")
developerConnection.set("scm:git:ssh://git@github.com/lightsail-network/java-stellar-sdk-android-spi.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 {
publishAllPublicationsToCentralPortal {
username = System.getenv("SONATYPE_USERNAME")
password = System.getenv("SONATYPE_PASSWORD")
// publish manually from the portal
publishingType = "USER_MANAGED"
// or if you want to publish automatically
// publishingType = "AUTOMATIC"
}
}