-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
170 lines (146 loc) · 5.45 KB
/
build.gradle.kts
File metadata and controls
170 lines (146 loc) · 5.45 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
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
import java.io.FileInputStream
import java.util.*
plugins {
id("io.github.gradle-nexus.publish-plugin") version "2.0.0"
signing
`maven-publish`
`java-library`
id("com.diffplug.spotless") version "7.0.2"
}
group = "io.getstream"
description = "Stream official Java SDK"
java {
toolchain {
languageVersion = JavaLanguageVersion.of(21)
}
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
withSourcesJar()
withJavadocJar()
}
dependencies {
// Use JUnit Jupiter for testing.
testImplementation(libs.junit.jupiter)
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
implementation(platform("com.squareup.okhttp3:okhttp-bom:4.12.0"))
implementation("com.squareup.okhttp3:okhttp")
implementation("com.fasterxml.jackson.core:jackson-databind:2.18.2")
implementation("com.fasterxml.jackson.core:jackson-annotations:2.18.2")
implementation("io.jsonwebtoken:jjwt-api:0.12.6")
runtimeOnly("io.jsonwebtoken:jjwt-impl:0.12.6")
runtimeOnly("io.jsonwebtoken:jjwt-jackson:0.12.6")
testImplementation("org.junit.jupiter:junit-jupiter-engine:5.8.2")
testImplementation("org.apache.commons:commons-lang3:3.18.0")
compileOnly("org.projectlombok:lombok:1.18.32")
annotationProcessor("org.projectlombok:lombok:1.18.32")
testCompileOnly("org.projectlombok:lombok:1.18.32")
testAnnotationProcessor("org.projectlombok:lombok:1.18.32")
}
val localProperties = Properties()
val localPropertiesFile = project.rootProject.file("local.properties")
if (localPropertiesFile.exists()) {
localProperties.load(localPropertiesFile.inputStream())
}
tasks.named<Test>("test") {
// Use JUnit Platform for unit tests.
useJUnitPlatform()
doFirst {
// Inject local properties into tests runtime system properties
localProperties.forEach { (k, v) ->
systemProperty(k.toString(), v.toString())
}
}
}
val generatedVersionDir = layout.buildDirectory.dir("generated-version")
tasks.register("generateVersionProperties") {
doLast {
val f = layout.buildDirectory.file("generated-version/version.properties")
val propertiesFile = f.get().asFile
propertiesFile.parentFile.mkdirs()
val properties = Properties()
properties.setProperty("version", version.toString())
propertiesFile.writer().use { properties.store(it, null) }
}
}
sourceSets {
main {
output.dir(mapOf("builtBy" to "generateVersionProperties"), generatedVersionDir)
}
}
spotless {
java {
googleJavaFormat("1.28.0")
}
}
extra["ossrhUsername"] = ""
extra["ossrhPassword"] = ""
extra["signing.keyId"] = ""
extra["signing.password"] = ""
extra["signing.secretKeyRingFile"] = ""
extra["sonatypeStagingProfileId"] = ""
extra["signing.gpgkeycontents"] = ""
val secretPropsFile = project.rootProject.file("local.properties")
if (secretPropsFile.exists()) {
// Read local.properties file first if it exists
val properties = Properties()
FileInputStream(secretPropsFile).use { properties.load(it) }
properties.forEach { (name, value) -> extra[name.toString()] = value.toString() }
} else {
// Use system environment variables
extra["ossrhUsername"] = System.getenv("OSSRH_USERNAME") ?: ""
extra["ossrhPassword"] = System.getenv("OSSRH_PASSWORD") ?: ""
extra["signing.keyId"] = System.getenv("SIGNING_KEY_ID") ?: ""
extra["signing.password"] = System.getenv("SIGNING_PASSWORD") ?: ""
extra["signing.gpgkeycontents"] = System.getenv("GPG_KEY_CONTENTS") ?: ""
extra["sonatypeStagingProfileId"] = System.getenv("SONATYPE_STAGING_PROFILE_ID") ?: ""
}
publishing {
publications {
create<MavenPublication>("maven") {
artifactId = "stream-sdk-java"
from(components["java"])
pom {
name.set("Stream official Java SDK")
description.set("Stream Java SDK")
url.set("https://github.com/getstream/stream-sdk-java")
licenses {
license {
name.set("Stream License")
url.set("https://github.com/GetStream/stream-sdk-java/blob/main/LICENSE")
}
}
developers {
developer {
id.set("getstream-support")
name.set("Stream Support")
email.set("support@getstream.io")
}
}
scm {
url = "https://github.com/GetStream/stream-sdk-java"
connection = "scm:git:github.com/getstream/stream-java-sdk.git"
developerConnection = "scm:git:github.com/getstream/stream-java-sdk.git"
}
}
}
}
}
signing {
useInMemoryPgpKeys(
extra["signing.keyId"] as String,
extra["signing.gpgkeycontents"] as String,
extra["signing.password"] as String
)
sign(publishing.publications)
}
nexusPublishing {
repositories {
sonatype {
nexusUrl.set(uri("https://ossrh-staging-api.central.sonatype.com/service/local/"))
snapshotRepositoryUrl.set(uri("https://central.sonatype.com/repository/maven-snapshots/"))
username = extra["ossrhUsername"] as String
password = extra["ossrhPassword"] as String
stagingProfileId = extra["sonatypeStagingProfileId"] as String
}
}
}