Skip to content

Commit 1899712

Browse files
committed
build: configure releasing in afterEvaluate
1 parent bc68feb commit 1899712

File tree

1 file changed

+91
-90
lines changed

1 file changed

+91
-90
lines changed

build.gradle.kts

Lines changed: 91 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -43,120 +43,121 @@ nexusStaging {
4343
numberOfRetries = 42
4444
}
4545

46-
evaluationDependsOnChildren()
4746
val closeAndReleaseRepository by project.tasks
4847

4948
subprojects {
50-
apply {
51-
plugin("org.jetbrains.dokka")
52-
plugin("de.marcphilipp.nexus-publish")
53-
plugin("org.gradle.maven-publish")
54-
plugin("org.gradle.signing")
55-
}
49+
afterEvaluate {
50+
apply {
51+
plugin("org.jetbrains.dokka")
52+
plugin("de.marcphilipp.nexus-publish")
53+
plugin("org.gradle.maven-publish")
54+
plugin("org.gradle.signing")
55+
}
5656

57-
val sourcesJar by tasks.registering(Jar::class) {
58-
group = "build"
59-
description = "Assembles the source code into a jar"
60-
archiveClassifier.set("sources")
61-
from(sourceSets.main.map { it.allSource })
62-
}
57+
val sourcesJar by tasks.registering(Jar::class) {
58+
group = "build"
59+
description = "Assembles the source code into a jar"
60+
archiveClassifier.set("sources")
61+
from(sourceSets.main.map { it.allSource })
62+
}
6363

64-
tasks.withType<DokkaTask> {
65-
dokkaSourceSets.named("main") {
66-
this.DokkaSourceSetID(if (extra.has("artifactId")) extra["artifactId"] as String else project.name)
67-
sourceLink {
68-
val projectPath = projectDir.absoluteFile.relativeTo(rootProject.projectDir.absoluteFile)
69-
localDirectory.set(file("src/main/kotlin"))
70-
remoteUrl.set(uri("https://github.com/$githubRepository/blob/$gitRef/$projectPath/src/main/kotlin").toURL())
71-
remoteLineSuffix.set("#L")
64+
tasks.withType<DokkaTask> {
65+
dokkaSourceSets.named("main") {
66+
this.DokkaSourceSetID(if (extra.has("artifactId")) extra["artifactId"] as String else project.name)
67+
sourceLink {
68+
val projectPath = projectDir.absoluteFile.relativeTo(rootProject.projectDir.absoluteFile)
69+
localDirectory.set(file("src/main/kotlin"))
70+
remoteUrl.set(uri("https://github.com/$githubRepository/blob/$gitRef/$projectPath/src/main/kotlin").toURL())
71+
remoteLineSuffix.set("#L")
72+
}
7273
}
7374
}
74-
}
7575

76-
val dokkaJar by tasks.registering(Jar::class) {
77-
group = "build"
78-
description = "Assembles the Kotlin docs with Dokka"
79-
archiveClassifier.set("javadoc")
80-
from(tasks.named("dokkaJavadoc"))
81-
}
76+
val dokkaJar by tasks.registering(Jar::class) {
77+
group = "build"
78+
description = "Assembles the Kotlin docs with Dokka"
79+
archiveClassifier.set("javadoc")
80+
from(tasks.named("dokkaJavadoc"))
81+
}
8282

83-
artifacts {
84-
archives(sourcesJar)
85-
archives(dokkaJar)
86-
}
83+
artifacts {
84+
archives(sourcesJar)
85+
archives(dokkaJar)
86+
}
8787

88-
signing {
89-
val signingKey: String? by project
90-
val signingKeyPassword: String? by project
91-
useInMemoryPgpKeys(signingKey, signingKeyPassword)
92-
}
88+
signing {
89+
val signingKey: String? by project
90+
val signingKeyPassword: String? by project
91+
useInMemoryPgpKeys(signingKey, signingKeyPassword)
92+
}
9393

94-
publishing.publications.register<MavenPublication>("maven") {
95-
artifactId = if (extra.has("artifactId")) extra["artifactId"] as String else project.name
94+
publishing.publications.create<MavenPublication>("maven") {
95+
artifactId = if (extra.has("artifactId")) extra["artifactId"] as String else project.name
9696

97-
from(components["java"])
98-
artifact(sourcesJar)
99-
artifact(dokkaJar)
97+
from(components["java"])
98+
artifact(sourcesJar)
99+
artifact(dokkaJar)
100100

101-
signing.sign(this)
101+
signing.sign(this)
102102

103-
pom {
104-
name.set("$groupId:$artifactId")
105-
description.set("Easily manage test files and directories when testing with Spek!")
106-
inceptionYear.set("2020")
107-
url.set("https://github.com/$githubRepository")
108-
ciManagement {
109-
system.set("GitHub Actions")
110-
url.set("https://github.com/$githubRepository/actions")
111-
}
112-
issueManagement {
113-
system.set("GitHub Issues")
114-
url.set("https://github.com/$githubRepository/issues")
115-
}
116-
developers {
117-
developer {
118-
name.set("Joshua Gleitze")
119-
email.set("[email protected]")
120-
}
121-
}
122-
scm {
123-
connection.set("scm:git:https://github.com/$githubRepository.git")
124-
developerConnection.set("scm:git:git://[email protected]:$githubRepository.git")
103+
pom {
104+
name.set("$groupId:$artifactId")
105+
description.set("Easily manage test files and directories when testing with Spek!")
106+
inceptionYear.set("2020")
125107
url.set("https://github.com/$githubRepository")
126-
}
127-
licenses {
128-
license {
129-
name.set("MIT")
130-
url.set("https://opensource.org/licenses/MIT")
131-
distribution.set("repo")
108+
ciManagement {
109+
system.set("GitHub Actions")
110+
url.set("https://github.com/$githubRepository/actions")
111+
}
112+
issueManagement {
113+
system.set("GitHub Issues")
114+
url.set("https://github.com/$githubRepository/issues")
115+
}
116+
developers {
117+
developer {
118+
name.set("Joshua Gleitze")
119+
email.set("[email protected]")
120+
}
121+
}
122+
scm {
123+
connection.set("scm:git:https://github.com/$githubRepository.git")
124+
developerConnection.set("scm:git:git://[email protected]:$githubRepository.git")
125+
url.set("https://github.com/$githubRepository")
126+
}
127+
licenses {
128+
license {
129+
name.set("MIT")
130+
url.set("https://opensource.org/licenses/MIT")
131+
distribution.set("repo")
132+
}
132133
}
133134
}
134135
}
135-
}
136136

137-
val githubPackages = publishing.repositories.maven("https://maven.pkg.github.com/$githubRepository") {
138-
name = "GitHubPackages"
139-
credentials {
140-
username = githubOwner
141-
password = githubToken
137+
val githubPackages = publishing.repositories.maven("https://maven.pkg.github.com/$githubRepository") {
138+
name = "GitHubPackages"
139+
credentials {
140+
username = githubOwner
141+
password = githubToken
142+
}
142143
}
143-
}
144144

145-
val mavenCentral = nexusPublishing.repositories.sonatype {
146-
username.set(ossrhUsername)
147-
password.set(ossrhPassword)
148-
}
145+
val mavenCentral = nexusPublishing.repositories.sonatype {
146+
username.set(ossrhUsername)
147+
password.set(ossrhPassword)
148+
}
149149

150-
val publishToGithub = tasks.named("publishAllPublicationsTo${githubPackages.name.capitalize()}Repository")
151-
val publishToMavenCentral = tasks.named("publishTo${mavenCentral.name.capitalize()}")
150+
val publishToGithub = tasks.named("publishAllPublicationsTo${githubPackages.name.capitalize()}Repository")
151+
val publishToMavenCentral = tasks.named("publishTo${mavenCentral.name.capitalize()}")
152152

153-
tasks.register("release") {
154-
group = "release"
155-
description = "Releases the project to all remote repositories"
156-
dependsOn(publishToGithub, publishToMavenCentral, rootProject.tasks.closeAndReleaseRepository)
157-
}
153+
tasks.register("release") {
154+
group = "release"
155+
description = "Releases the project to all remote repositories"
156+
dependsOn(publishToGithub, publishToMavenCentral, rootProject.tasks.closeAndReleaseRepository)
157+
}
158158

159-
rootProject.tasks.closeAndReleaseRepository { mustRunAfter(publishToMavenCentral) }
159+
rootProject.tasks.closeAndReleaseRepository { mustRunAfter(publishToMavenCentral) }
160+
}
160161
}
161162

162163
val Project.isSnapshot get() = versionDetails.commitDistance != 0

0 commit comments

Comments
 (0)