-
Notifications
You must be signed in to change notification settings - Fork 3
/
publish-mpp.gradle.kts
112 lines (97 loc) · 3.4 KB
/
publish-mpp.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
apply(plugin = "java")
apply(plugin = "java-library")
apply(plugin = "maven-publish")
apply(plugin = "signing")
apply(plugin = "org.jetbrains.dokka")
apply(plugin = "com.bmuschko.nexus")
repositories {
mavenCentral()
}
val ossrhUsername: String by project
val ossrhPassword: String by project
val signingKey: String? by project
val signingPassword: String? by project
fun Project.publishing(action: PublishingExtension.() -> Unit) =
configure(action)
fun Project.signing(configure: SigningExtension.() -> Unit): Unit =
configure(configure)
val dokka = tasks.named("dokka")
val javadoc = tasks.named("javadoc")
//val sources = tasks.named("kotlinSourcesJar")
val publications: PublicationContainer = (extensions.getByName("publishing") as PublishingExtension).publications
signing {
setRequired({
(Ci.isRelease) && gradle.taskGraph.hasTask("publish")
})
if (signingKey != null && signingPassword != null) {
@Suppress("UnstableApiUsage")
useInMemoryPgpKeys(signingKey, signingPassword)
}
if (Ci.isRelease) {
useGpgCmd()
sign(publications)
}
}
val javadocJar2 by tasks.creating(Jar::class) {
group = JavaBasePlugin.DOCUMENTATION_GROUP
description = "Assembles java doc to jar"
archiveClassifier.set("javadoc")
from(javadoc)
}
val dokkaJar by tasks.creating(Jar::class) {
group = JavaBasePlugin.DOCUMENTATION_GROUP
description = "Assembles Kotlin docs with Dokka"
archiveClassifier.set("javadoc")
from(dokka)
}
//val sourcesJar by tasks.creating(Jar::class) {
// group = JavaBasePlugin.DOCUMENTATION_GROUP
// description = "Assembles sources"
// archiveClassifier.set("sources")
// from(the<SourceSetContainer>()["main"].allSource)
//}
publishing {
repositories {
maven {
val releasesRepoUrl = uri("https://oss.sonatype.org/service/local/staging/deploy/maven2/")
val snapshotsRepoUrl = uri("https://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.withType<MavenPublication>().forEach {
it.apply {
if (Ci.isRelease) {
artifact(tasks["dokkaJar"])
}
artifact(tasks["kotlinSourcesJar"])
pom {
name.set("Neefect")
description.set("Nee")
url.set("http://www.github.com/neeffect/nee/")
scm {
connection.set("scm:git:http://www.github.com/neeffect/nee/")
developerConnection.set("scm:git:http://github.com/jarekratajski/")
url.set("http://www.github.com/neeffect/nee/")
}
licenses {
license {
name.set("Apache-2.0")
url.set("https://opensource.org/licenses/Apache-2.0")
}
}
developers {
developer {
id.set("jarekratajski")
name.set("Jarek Ratajski")
email.set("[email protected]")
}
}
}
}
}
}