-
Notifications
You must be signed in to change notification settings - Fork 391
/
dokkabuild.publish-base.gradle.kts
114 lines (104 loc) · 4.15 KB
/
dokkabuild.publish-base.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
import java.net.URI
/*
* Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/
plugins {
`maven-publish`
signing
}
publishing {
repositories {
maven {
name = "mavenCentral"
url = mavenCentralRepositoryUri()
credentials {
username = System.getenv("DOKKA_SONATYPE_USER")
password = System.getenv("DOKKA_SONATYPE_PASSWORD")
}
}
maven {
name = "spaceDev"
url = uri("https://maven.pkg.jetbrains.space/kotlin/p/dokka/dev")
credentials {
username = System.getenv("DOKKA_SPACE_PACKAGES_USER")
password = System.getenv("DOKKA_SPACE_PACKAGES_SECRET")
}
}
maven {
name = "spaceTest"
url = uri("https://maven.pkg.jetbrains.space/kotlin/p/dokka/test")
credentials {
username = System.getenv("DOKKA_SPACE_PACKAGES_USER")
password = System.getenv("DOKKA_SPACE_PACKAGES_SECRET")
}
}
// Publish to a project-local Maven directory, for verification. To test, run:
// ./gradlew publishAllPublicationsToProjectLocalRepository
// and check $rootDir/build/maven-project-local
maven {
name = "projectLocal"
url = uri(rootProject.layout.buildDirectory.dir("maven-project-local"))
}
}
publications.withType<MavenPublication>().configureEach {
pom {
name.convention("Dokka ${project.name}")
description.convention("Dokka is an API documentation engine for Kotlin")
url.convention("https://github.com/Kotlin/dokka")
licenses {
license {
name.convention("The Apache Software License, Version 2.0")
url.convention("https://www.apache.org/licenses/LICENSE-2.0.txt")
distribution.convention("repo")
}
}
developers {
developer {
id.convention("JetBrains")
name.convention("JetBrains Team")
organization.convention("JetBrains")
organizationUrl.convention("https://www.jetbrains.com")
}
}
scm {
connection.convention("scm:git:git://github.com/Kotlin/dokka.git")
url.convention("https://github.com/Kotlin/dokka")
}
}
}
}
/**
* Due to Gradle running publishing tasks in parallel, multiple staging repositories
* can be created within a couple of seconds with artifact files scattered throughout.
* The safest and most stable option is to publish to a pre-defined staging repository.
*/
fun mavenCentralRepositoryUri(): URI {
val repositoryId: String? = System.getenv("DOKKA_MVN_CENTRAL_REPOSITORY_ID")
return if (repositoryId == null) {
URI("https://oss.sonatype.org/service/local/staging/deploy/maven2/")
} else {
URI("https://oss.sonatype.org/service/local/staging/deployByRepositoryId/$repositoryId")
}
}
signing {
useInMemoryPgpKeys(
System.getenv("DOKKA_SIGN_KEY_ID")?.takeIf(String::isNotBlank),
System.getenv("DOKKA_SIGN_KEY")?.takeIf(String::isNotBlank),
System.getenv("DOKKA_SIGN_KEY_PASSPHRASE")?.takeIf(String::isNotBlank),
)
sign(publishing.publications)
setRequired(provider {
val isPublishedToMavenLocal = gradle.taskGraph.allTasks.any { it.name == "publishToMavenLocal" }
!project.version.toString().endsWith("-SNAPSHOT") && !isPublishedToMavenLocal
})
}
// This is a hack for a Gradle 8 problem, see https://github.com/gradle/gradle/issues/26091
//
// Fails with the following error otherwise:
// > Task ':runner-gradle-plugin-classic:publishDokkaPluginMarkerMavenPublicationToSpaceTestRepository' uses
// > this output of task ':runner-gradle-plugin-classic:signPluginMavenPublication' without declaring an
// > explicit or implicit dependency.
tasks.withType<AbstractPublishToMaven>().configureEach {
val signingTasks = tasks.withType<Sign>()
mustRunAfter(signingTasks)
}