This repository has been archived by the owner on Jul 14, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
174 lines (160 loc) · 7.38 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
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
import java.net.URI
// Workaround for issue: https://youtrack.jetbrains.com/issue/KTIJ-19369
@Suppress("DSL_SCOPE_VIOLATION")
plugins {
`maven-publish`
signing
alias(libs.plugins.gitonium)
}
allprojects {
group = "org.metaborg.spoofax3"
extra["isReleaseVersion"] = !version.toString().endsWith("-SNAPSHOT")
extra["isDirtyVersion"] = version.toString().endsWith("+dirty")
extra["isCI"] = !System.getenv("CI").isNullOrEmpty()
repositories {
mavenCentral()
}
}
subprojects {
apply(plugin = "maven-publish")
apply(plugin = "signing")
publishing {
afterEvaluate {
publications {
withType<MavenPublication> {
pom {
description.set(project.description)
url.set("https://github.com/metaborg/spoofax3-depman")
inceptionYear.set("2024")
licenses {
// From: https://spdx.org/licenses/
license {
name.set("Apache-2.0")
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
distribution.set("repo")
}
}
developers {
developer {
id.set("virtlink")
name.set("Daniel A. A. Pelsmaeker")
email.set("[email protected]")
}
}
scm {
connection.set("scm:[email protected]:metaborg/spoofax3-depman.git")
developerConnection.set("scm:[email protected]:metaborg/spoofax3-depman.git")
url.set("scm:[email protected]:metaborg/spoofax3-depman.git")
}
}
}
}
}
repositories {
maven {
val releasesRepoUrl = uri("https://artifacts.metaborg.org/content/repositories/releases/")
val snapshotsRepoUrl = uri("https://artifacts.metaborg.org/content/repositories/snapshots/")
name = "MetaborgArtifacts"
url = if (project.extra["isReleaseVersion"] as Boolean) releasesRepoUrl else snapshotsRepoUrl
credentials {
username = project.findProperty("publish.repository.metaborg.artifacts.username") as String? ?: System.getenv("METABORG_ARTIFACTS_USERNAME")
password = project.findProperty("publish.repository.metaborg.artifacts.password") as String? ?: System.getenv("METABORG_ARTIFACTS_PASSWORD")
}
}
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/metaborg/spoofax3-depman")
credentials {
username = project.findProperty("gpr.user") as String? ?: System.getenv("GITHUB_ACTOR")
password = project.findProperty("gpr.publishKey") as String? ?: System.getenv("GITHUB_TOKEN")
}
}
}
}
// signing {
// if (!project.hasProperty("signing.secretKeyRingFile")) {
// // If no secretKeyRingFile was set, we assume an in-memory key in the SIGNING_KEY environment variable (used in CI)
// useInMemoryPgpKeys(
// project.findProperty("signing.keyId") as String? ?: System.getenv("SIGNING_KEY_ID"),
// System.getenv("SIGNING_KEY"),
// project.findProperty("signing.password") as String? ?: System.getenv("SIGNING_KEY_PASSWORD"),
// )
// }
// }
val checkNotDirty by tasks.registering {
doLast {
if (project.extra["isDirtyVersion"] as Boolean) {
throw GradleException("Cannot publish a dirty version: ${project.version}")
}
}
}
tasks.publish { dependsOn(checkNotDirty) }
}
// Normally, when you execute a task such as `test` in a multi-project build, you will execute
// all `:test` tasks in all projects. In contrast, when you specifically execute `:test`
// (prefixed with a colon), you execute the `:test` task only in the root project.
// Now, we would like to create a task in this composite build `testAll` that executes basically
// the equivalent of `test` in each of the included multi-project builds, which would execute
// `:test` in each of the projects. However, this seems to be impossible to write down. Instead,
// we call the root `:test` task in the included build, and in each included build's multi-project
// root project we'll extend the `test` task to depend on the `:test` tasks of the subprojects.
// Build tasks
tasks.register("assembleAll") {
group = "Build"
description = "Assembles the outputs of the subprojects and included builds."
dependsOn(tasks.named("assemble"))
dependsOn(gradle.includedBuilds.map { it.task(":assemble") })
dependsOn(project.subprojects.mapNotNull { it.tasks.findByName("assemble") })
}
tasks.register("buildAll") {
group = "Build"
description = "Assembles and tests the subprojects and included builds."
dependsOn(tasks.named("build"))
dependsOn(gradle.includedBuilds.map { it.task(":build") })
dependsOn(project.subprojects.mapNotNull { it.tasks.findByName("build") })
}
tasks.register("cleanAll") {
group = "Build"
description = "Cleans the outputs of the subprojects and included builds."
dependsOn(tasks.named("clean"))
dependsOn(gradle.includedBuilds.map { it.task(":clean") })
dependsOn(project.subprojects.mapNotNull { it.tasks.findByName("clean") })
}
// Publishing tasks
tasks.register("publishAll") {
group = "Publishing"
description = "Publishes all subprojects and included builds to a remote Maven repository."
dependsOn(tasks.named("publish"))
dependsOn(gradle.includedBuilds.map { it.task(":publish") })
dependsOn(project.subprojects.mapNotNull { it.tasks.findByName("publish") })
}
tasks.register("publishAllToMavenLocal") {
group = "Publishing"
description = "Publishes all subprojects and included builds to the local Maven repository."
dependsOn(tasks.named("publishToMavenLocal"))
dependsOn(gradle.includedBuilds.map { it.task(":publishToMavenLocal") })
dependsOn(project.subprojects.mapNotNull { it.tasks.findByName("publishToMavenLocal") })
}
// Verification tasks
tasks.register("checkAll") {
group = "Verification"
description = "Runs all checks on the subprojects and included builds."
dependsOn(tasks.named("check"))
dependsOn(gradle.includedBuilds.map { it.task(":check") })
dependsOn(project.subprojects.mapNotNull { it.tasks.findByName("check") })
}
tasks.register("testAll") {
group = "Verification"
description = "Runs all unit tests on the subprojects and included builds."
dependsOn(tasks.named("test"))
dependsOn(gradle.includedBuilds.map { it.task(":test") })
dependsOn(project.subprojects.mapNotNull { it.tasks.findByName("test") })
}
// Help tasks
tasks.register("allTasks") {
group = "Help"
description = "Displays all tasks of subprojects and included builds."
dependsOn(tasks.named("tasks"))
dependsOn(gradle.includedBuilds.map { it.task(":tasks") })
dependsOn(project.subprojects.mapNotNull { it.tasks.findByName("tasks") })
}