-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathupload-github.gradle.kts
More file actions
64 lines (59 loc) · 2.76 KB
/
Copy pathupload-github.gradle.kts
File metadata and controls
64 lines (59 loc) · 2.76 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
apply(plugin = "maven-publish")
val artifactConfig = mapOf(
"group" to "com.tangem.tangem-sdk-kotlin",
"version" to if (project.hasProperty("artifactVersion")) project.property("artifactVersion") as String else "0.0.1",
)
val publishArtifactId = project.property("artifactId") as String
afterEvaluate {
configure<PublishingExtension> {
publications {
create<MavenPublication>("maven") {
groupId = artifactConfig["group"]
this.artifactId = publishArtifactId
version = artifactConfig["version"]
if (publishArtifactId == "android") {
from(components["release"])
pom.withXml {
val pomNode = asNode()
val depsList = pomNode.get("dependencies") as? groovy.util.NodeList ?: return@withXml
for (depsNode in depsList) {
val deps = (depsNode as groovy.util.Node).children().toMutableList()
// Remove internal module dependencies
deps.filterIsInstance<groovy.util.Node>()
.filter { dep ->
(dep.get("groupId") as groovy.util.NodeList).text() == artifactConfig["group"]
}
.forEach { dep -> dep.parent().remove(dep) }
// Change runtime scope to compile
(depsNode.children() as List<*>)
.filterIsInstance<groovy.util.Node>()
.filter { dep ->
(dep.get("scope") as groovy.util.NodeList).text() == "runtime"
}
.forEach { dep ->
val scopeNode = (
dep.get(
"scope",
) as groovy.util.NodeList
).first() as groovy.util.Node
scopeNode.setValue("compile")
}
}
}
} else if (publishArtifactId == "core") {
from(components["java"])
}
}
}
repositories {
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/tangem/tangem-sdk-android")
credentials {
username = findProperty("githubUser") as? String
password = findProperty("githubPass") as? String
}
}
}
}
}