forked from flashcatcloud/fc-sdk-android
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
198 lines (166 loc) · 5.84 KB
/
build.gradle.kts
File metadata and controls
198 lines (166 loc) · 5.84 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
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
/*
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
* This product includes software developed at Datadog (https://www.datadoghq.com/).
* Copyright 2016-Present Datadog, Inc.
*/
import com.datadog.gradle.config.AndroidConfig
import com.datadog.gradle.config.MavenConfig
import com.vanniktech.maven.publish.MavenPublishBaseExtension
import java.util.Base64
plugins {
`java-library`
id("com.gradleup.shadow")
`maven-publish`
signing
id("com.vanniktech.maven.publish.base")
}
dependencies {
implementation(libs.jctools)
implementation(libs.re2j)
}
tasks.named<Jar>("jar") {
// Move the default (empty) jar out of the way to avoid name collision
archiveClassifier.set("raw")
}
tasks.shadowJar {
// Make shadowJar the primary artifact by removing the 'all' classifier
archiveClassifier.set("")
relocate("org.jctools", "cloud.flashcat.shaded.jctools")
relocate("com.google.re2j", "cloud.flashcat.shaded.re2j")
// Use runtimeClasspath which is resolvable
configurations = listOf(project.configurations.runtimeClasspath.get())
}
// Use Vanniktech plugin ONLY for Maven Central Portal repository setup (not for artifact configuration)
// This ensures the same publishToSonatype / Central Portal API is used as other modules
configure<MavenPublishBaseExtension> {
publishToMavenCentral(automaticRelease = false)
}
// Manual publication configuration with shadow jar as the artifact
publishing {
publications {
register<MavenPublication>("maven") {
groupId = MavenConfig.GROUP_ID
artifactId = project.name
version = AndroidConfig.VERSION.name
artifact(tasks.shadowJar)
pom {
name.set(project.name)
description.set("Shaded dependencies for FlashCat Android SDK")
inceptionYear.set("2026")
url.set("https://github.com/flashcatcloud/fc-sdk-android/")
licenses {
license {
name.set("The Apache License, Version 2.0")
url.set("https://www.apache.org/licenses/LICENSE-2.0.txt")
distribution.set("repo")
}
}
organization {
name.set("FlashCat")
url.set("https://flashcat.cloud/")
}
developers {
developer {
id.set("flashcat")
name.set("FlashCat")
email.set("support@flashcat.cloud")
organization.set("FlashCat")
organizationUrl.set("https://flashcat.cloud/")
}
}
scm {
url.set("https://github.com/flashcatcloud/fc-sdk-android/")
connection.set("scm:git:git@github.com:flashcatcloud/fc-sdk-android.git")
developerConnection.set("scm:git:git@github.com:flashcatcloud/fc-sdk-android.git")
}
}
}
}
}
// Signing configuration (consistent with MavenConfig.publishingConfig())
signing {
val isLocalPublish = gradle.startParameter.taskNames.any {
it.contains("publishToMavenLocal", ignoreCase = true)
}
isRequired = !hasProperty("dd-skip-signing") && !isLocalPublish
val privateKey = System.getenv("GPG_PRIVATE_KEY")
val password = System.getenv("GPG_PASSWORD")
if (privateKey != null && password != null) {
val decodedKey = try {
String(Base64.getDecoder().decode(privateKey))
} catch (e: Exception) {
privateKey // Already decoded / plain text
}
useInMemoryPgpKeys(decodedKey, password)
}
sign(publishing.publications["maven"])
}
// Force the shadowJar to be the ONLY exported artifact for this module
// This prevents R8 duplicate class errors while ensuring the file exists for KSP
configurations.apiElements {
outgoing.artifacts.clear()
outgoing.artifact(tasks.shadowJar)
}
configurations.runtimeElements {
outgoing.artifacts.clear()
outgoing.artifact(tasks.shadowJar)
}
tasks.assemble {
dependsOn(tasks.shadowJar)
}
if (tasks.findByName("assembleDebug") == null) {
tasks.register("assembleDebug") {
dependsOn("assemble")
}
}
if (tasks.findByName("assembleRelease") == null) {
tasks.register("assembleRelease") {
dependsOn("assemble")
}
}
// Shadow tasks to satisfy Android aggregation tasks
if (tasks.findByName("testDebugUnitTest") == null) {
tasks.register("testDebugUnitTest") {
dependsOn("test")
}
}
if (tasks.findByName("testReleaseUnitTest") == null) {
tasks.register("testReleaseUnitTest") {
dependsOn("test")
}
}
if (tasks.findByName("lintRelease") == null) {
tasks.register("lintRelease") {
// No-op for this Java library
}
}
if (tasks.findByName("checkDependencyLicenses") == null) {
tasks.register("checkDependencyLicenses") {
// No-op for this Java library
}
}
if (tasks.findByName("checkApiSurfaceChanges") == null) {
tasks.register("checkApiSurfaceChanges") {
// No-op for this Java library
}
}
if (tasks.findByName("checkCompilerMetadataChanges") == null) {
tasks.register("checkCompilerMetadataChanges") {
// No-op for this Java library
}
}
if (tasks.findByName("checkTransitiveDependenciesList") == null) {
tasks.register("checkTransitiveDependenciesList") {
// No-op for this Java library
}
}
if (tasks.findByName("koverXmlReportRelease") == null) {
tasks.register("koverXmlReportRelease") {
// No-op or depends on koverXmlReport if applied
}
}
if (tasks.findByName("printDetektClasspath") == null) {
tasks.register("printDetektClasspath") {
// No-op
}
}