-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
134 lines (120 loc) · 4.44 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
plugins {
`java-platform`
`maven-publish`
signing
}
val projGroupId: String by project
val projArtifactId: String by project
val projVersion: String by project
val projVcs: String by project
val projBranch: String by project
val orgName: String by project
val orgUrl: String by project
val developers: String by project
group = projGroupId
version = projVersion
val binPackingVersion: String by project
val binTagVersion: String by project
val platformVersion: String by project
val timerVersion: String by project
val unifontVersion: String by project
data class Artifact(val artifact: String, val version: String)
val utilities = arrayOf(
"bin-packing" to binPackingVersion,
"bin-tag" to binTagVersion,
"platform" to platformVersion,
"timer" to timerVersion,
"unifont" to unifontVersion
).map { (artifact, version) -> Artifact(artifact, version) }
repositories {
mavenCentral()
}
publishing {
publications {
fun MavenPom.setupPom(pomName: String, pomDescription: String, pomPackaging: String) {
name.set(pomName)
description.set(pomDescription)
url.set("https://github.com/$projVcs")
packaging = pomPackaging
licenses {
license {
name.set("MIT")
url.set("https://raw.githubusercontent.com/$projVcs/$projBranch/LICENSE")
}
}
organization {
name.set(orgName)
url.set(orgUrl)
}
developers {
developers.split(',')
.forEach { id1 ->
developer {
id.set(id1)
}
}
}
scm {
connection.set("scm:git:https://github.com/${projVcs}.git")
developerConnection.set("scm:git:https://github.com/${projVcs}.git")
url.set("https://github.com/${projVcs}.git")
}
}
create<MavenPublication>("utilitiesBOM") {
from(components["javaPlatform"])
artifactId = projArtifactId
pom {
setupPom("Utilities", "Utilities Bill of Materials.", "pom")
withXml {
asElement().getElementsByTagName("dependencyManagement").item(0).apply {
asElement().getElementsByTagName("dependencies").item(0).apply {
utilities.forEach {
ownerDocument.createElement("dependency").also(::appendChild).apply {
appendChild(
ownerDocument.createElement("groupId").also(::appendChild)
.apply { textContent = "io.github.over-run" })
appendChild(
ownerDocument.createElement("artifactId").also(::appendChild)
.apply { textContent = it.artifact })
appendChild(
ownerDocument.createElement("version").also(::appendChild)
.apply { textContent = it.version })
}
}
}
}
asNode()
}
}
}
}
// You have to add `OSSRH_USERNAME`, `OSSRH_PASSWORD`, `signing.keyId`,
// `signing.password` and `signing.secretKeyRingFile` to
// GRADLE_USER_HOME/gradle.properties
repositories {
maven {
name = "OSSRH"
credentials {
username = project.findProperty("OSSRH_USERNAME").toString()
password = project.findProperty("OSSRH_PASSWORD").toString()
}
url = uri(
if (projVersion.endsWith("-SNAPSHOT"))
"https://s01.oss.sonatype.org/content/repositories/snapshots/"
else "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
)
}
}
}
signing {
if (!projVersion.endsWith("-SNAPSHOT") && System.getProperty("gpg.signing", "true").toBoolean()) {
sign(publishing.publications)
}
}
dependencies {
constraints {
utilities.forEach {
api("io.github.over-run:${it.artifact}:${it.version}")
}
}
}