-
Notifications
You must be signed in to change notification settings - Fork 17
/
build.gradle.kts
97 lines (89 loc) · 3.88 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
import XdkDistribution.Companion.DISTRIBUTION_TASK_GROUP
import org.gradle.api.publish.plugins.PublishingPlugin.PUBLISH_TASK_GROUP
/*
* Main build file for the XVM project, producing the XDK.
*/
plugins {
alias(libs.plugins.xdk.build.versioning)
alias(libs.plugins.xdk.build.aggregator)
alias(libs.plugins.tasktree)
}
/**
* Installation and distribution tasks that aggregate publishable/distributable included
* build projects. The aggregator proper should be as small as possible, and only contains
* LifeCycle dependencies, aggregated through the various included builds. This creates as
* few bootstrapping problems as possible, since by the time we get to the configuration phase
* of the root build.gradle.kts, we have installed convention plugins, resolved version catalogs
* and similar things.
*/
val installDist by tasks.registering {
group = DISTRIBUTION_TASK_GROUP
description = "Install the XDK distribution in the xdk/build/distributions and xdk/build/install directories."
dependsOn(xdk.task(":$name"))
}
/**
* Register aggregated publication tasks to the top level project, to ensure we can publish both
* the XDK and the XTC plugin (and other future artifacts) with './gradlew publish' or
* './gradlew publishToMavenLocal'. Snapshot builds should only be allowed to be published
* in local repositories.
*
* Publishing tasks can be racy, but it seems that Gradle serializes tasks that have a common
* output directory, which should be the case here. If not, we will have to put back the
* parallel check/task failure condition.
*
* Publish remote - one way to do it is to only allow snapshot publications in GitHub, otherwise
* we need to do it manually. "publishRemoteRelease", in which case we will also feed into
* jreleaser.
*/
val publishRemote by tasks.registering {
group = PUBLISH_TASK_GROUP
description = "Publish (aggregate) all artifacts in the XDK to the remote repositories."
// Call publishRemote in xdk and plugin projects.
includedBuildsWithPublications.forEach {
dependsOn(it.task(":$name"))
}
}
/**
* Publish local publications to the mavenLocal repository. This is useful for testing
* that a dependency to a particular XDK version of an XDK or XTC package works with
* another application before you push it, and cause a "remote" publication to be made.
*/
val publishLocal by tasks.registering {
group = PUBLISH_TASK_GROUP
description = "Publish (aggregated) all artifacts in the XDK to the local Maven repository."
includedBuildsWithPublications.forEach {
dependsOn(it.task(":$name"))
}
}
/**
* Publish both local (mavenLocal) and remote (GitHub, and potentially mavenCentral, gradlePluginPortal)
* packages for the current code.
*/
val publish by tasks.registering {
group = PUBLISH_TASK_GROUP
description = "Task that aggregates publish tasks for builds with publications."
dependsOn(publishLocal, publishRemote)
}
private val xdk = gradle.includedBuild("xdk")
private val plugin = gradle.includedBuild("plugin")
private val includedBuildsWithPublications = listOf(xdk, plugin)
private val distributionTaskNames = XdkDistribution.distributionTasks
private val publishTaskPrefixes = listOf("list", "delete")
private val publishTaskSuffixesRemote = listOf("RemotePublications")
private val publishTaskSuffixesLocal = listOf("LocalPublications")
// list|deleteLocalPublicatiopns/remotePublications.
publishTaskPrefixes.forEach { prefix ->
buildList {
addAll(publishTaskSuffixesLocal)
addAll(publishTaskSuffixesRemote)
}.forEach { suffix ->
val taskName = "$prefix$suffix"
tasks.register(taskName) {
group = PUBLISH_TASK_GROUP
description = "Task that aggregates '$taskName' tasks for builds with publications."
includedBuildsWithPublications.forEach { it ->
dependsOn(it.task(":$taskName"))
}
}
}
}