forked from kotest/kotest
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
108 lines (96 loc) · 3.73 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
plugins {
`java-platform`
`maven-publish`
signing
}
group = "io.kotest"
version = Ci.publishVersion
val bomProject = project
// Explicitly exclude subprojects that will never be published so that when configuring this project
// we don't force their configuration and do unecessary work
val excludeFromBom = listOf("kotest-examples", "kotest-tests")
fun projectsFilter(candidateProject: Project) =
excludeFromBom.all { !candidateProject.name.contains(it) } &&
candidateProject.name != bomProject.name
// Declare that this subproject depends on all subprojects matching the filter
// When this subproject is configured, it will force configuration of all subprojects
// so that we can declare dependencies on them
rootProject.subprojects.filter(::projectsFilter).forEach { bomProject.evaluationDependsOn(it.path) }
dependencies {
constraints {
rootProject.subprojects.filter { project ->
// Only declare dependencies on projects that will have publications
projectsFilter(project) && project.tasks.findByName("publish")?.enabled == true
}.forEach { project ->
project.publishing.publications.forEach { publication: Publication ->
if (publication is MavenPublication) {
if (publication.artifacts.any { it.extension == "klib" }) {
// Skip platform artifacts (like *-linuxx64, *-macosx64)
// It leads to inconsistent bom when publishing from different platforms
// (e.g. on linux it will include only linuxx64 artifacts and no macosx64)
// It shouldn't be a problem as usually consumers need to use generic *-native artifact
// Gradle will choose correct variant by using metadata attributes
} else {
api("${publication.groupId}:${publication.artifactId}:${publication.version}")
}
}
}
}
}
}
val ossrhUsername: String by project
val ossrhPassword: String by project
val signingKey: String? by project
val signingPassword: String? by project
publishing {
repositories {
maven {
val releasesRepoUrl = uri("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/")
val snapshotsRepoUrl = uri("https://s01.oss.sonatype.org/content/repositories/snapshots/")
name = "deploy"
url = if (Ci.isRelease) releasesRepoUrl else snapshotsRepoUrl
credentials {
username = System.getenv("OSSRH_USERNAME") ?: ossrhUsername
password = System.getenv("OSSRH_PASSWORD") ?: ossrhPassword
}
}
}
publications {
create<MavenPublication>("KotestBom") {
from(components["javaPlatform"])
pom {
name.set("Kotest")
description.set("Kotlin Test Framework")
url.set("https://github.com/kotest/kotest")
scm {
connection.set("scm:git:https://github.com/kotest/kotest/")
developerConnection.set("scm:git:https://github.com/sksamuel/")
url.set("https://github.com/kotest/kotest/")
}
licenses {
license {
name.set("Apache-2.0")
url.set("https://opensource.org/licenses/Apache-2.0")
}
}
developers {
developer {
id.set("sksamuel")
name.set("Stephen Samuel")
email.set("sam@sksamuel.com")
}
}
}
}
}
}
signing {
useGpgCmd()
if (signingKey != null && signingPassword != null) {
@Suppress("UnstableApiUsage")
useInMemoryPgpKeys(signingKey, signingPassword)
}
if (Ci.isRelease) {
sign(publishing.publications)
}
}