-
Notifications
You must be signed in to change notification settings - Fork 5
/
build.gradle.kts
153 lines (134 loc) · 6.03 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
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.api.tasks.testing.logging.TestLogEvent
plugins {
`maven-publish`
signing
kotlin("multiplatform") version "1.9.22" apply false
id("io.kotest.multiplatform") version "5.8.0" apply false
id("io.github.gradle-nexus.publish-plugin") version "1.1.0"
id("org.jetbrains.dokka") version "1.8.10"
}
allprojects {
repositories {
// mavenLocal() including this first causes all sorts of horror
// with gradle not seeing classes/dependencies that should be there
mavenCentral()
}
}
allprojects {
group = "io.exoquery"
version = "2.0.2"
}
subprojects {
//val varintName = project.name
apply {
plugin("org.jetbrains.dokka")
plugin("maven-publish")
plugin("signing")
}
val dokkaHtml by tasks.getting(org.jetbrains.dokka.gradle.DokkaTask::class)
val javadocJar: TaskProvider<Jar> by tasks.registering(Jar::class) {
dependsOn(dokkaHtml)
archiveClassifier.set("javadoc")
from(dokkaHtml.outputDirectory)
}
publishing {
val user = System.getenv("SONATYPE_USERNAME")
val pass = System.getenv("SONATYPE_PASSWORD")
repositories {
maven {
name = "Oss"
setUrl {
val repositoryId = System.getenv("SONATYPE_REPOSITORY_ID") ?: error("Missing env variable: SONATYPE_REPOSITORY_ID")
"https://s01.oss.sonatype.org/service/local/staging/deployByRepositoryId/$repositoryId/"
}
credentials {
username = user
password = pass
}
}
maven {
name = "Snapshot"
setUrl { "https://s01.oss.sonatype.org/content/repositories/snapshots/" }
credentials {
username = user
password = pass
}
}
}
publications.withType<MavenPublication> {
artifact(javadocJar)
pom {
name.set("pprint-kotlin")
description.set("Pretty Printing for Kotlin")
url.set("https://github.com/deusaquilus/pprint-kotlin")
licenses {
license {
name.set("The Apache Software License, Version 2.0")
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
distribution.set("repo")
}
}
developers {
developer {
name.set("Alexander Ioffe")
email.set("[email protected]")
organization.set("github")
organizationUrl.set("http://www.github.com")
}
}
scm {
url.set("https://github.com/exoquery/pprint-kotlin/tree/main")
connection.set("scm:git:git://github.com/ExoQuery/pprint-kotlin.git")
developerConnection.set("scm:git:ssh://github.com:ExoQuery/pprint-kotlin.git")
}
}
}
}
val isCI = project.hasProperty("isCI")
val isLocal = !isCI
val noSign = project.hasProperty("nosign")
val doNotSign = isLocal || noSign
signing {
// Sign if we're not doing a local build and we haven't specifically disabled it
if (!doNotSign) {
val signingKeyRaw = System.getenv("NEW_SIGNING_KEY_ID_BASE64")
if (signingKeyRaw == null) error("ERROR: No Signing Key Found")
// Seems like the right way was to have newlines after all the exported (ascii armored) lines
// and you can put them into the github-var with newlines but if you
// include the "-----BEGIN PGP PRIVATE KEY BLOCK-----" and "-----END PGP PRIVATE KEY BLOCK-----"
// parts with that then errors happen. Have a look at https://github.com/gradle/gradle/issues/15718 for more detail
// Ultimately however `iurysza` is only partially correct and they key-itself does not need to be escaped
// and can be put into a github-var with newlines.
val signingKey =
"-----BEGIN PGP PRIVATE KEY BLOCK-----\n\n${signingKeyRaw}\n-----END PGP PRIVATE KEY BLOCK-----"
useInMemoryPgpKeys(
System.getenv("NEW_SIGNING_KEY_ID_BASE64_ID"),
signingKey,
System.getenv("NEW_SIGNING_KEY_ID_BASE64_PASS")
)
sign(publishing.publications)
}
}
// Fix for Kotlin issue: https://youtrack.jetbrains.com/issue/KT-61313
tasks.withType<Sign>().configureEach {
val pubName = name.removePrefix("sign").removeSuffix("Publication")
// These tasks only exist for native targets, hence findByName() to avoid trying to find them for other targets
// Task ':linkDebugTest<platform>' uses this output of task ':sign<platform>Publication' without declaring an explicit or implicit dependency
tasks.findByName("linkDebugTest$pubName")?.let {
mustRunAfter(it)
}
// Task ':compileTestKotlin<platform>' uses this output of task ':sign<platform>Publication' without declaring an explicit or implicit dependency
tasks.findByName("compileTestKotlin$pubName")?.let {
mustRunAfter(it)
}
}
// Was having odd issues happening in CI releases like this:
// e.g. Task ':pprint-kotlin-core:publish<AndroidNativeArm32>PublicationToOssRepository' uses this output of task ':pprint-kotlin-core:sign<AndroidNativeArm64>Publication' without declaring an explicit or implicit dependency.
// I tried a few things that caused other issues. Ultimately the working solution I got from here:
// https://github.com/gradle/gradle/issues/26091#issuecomment-1722947958
tasks.withType<AbstractPublishToMaven>().configureEach {
val signingTasks = tasks.withType<Sign>()
mustRunAfter(signingTasks)
}
}