-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathpublish-lib.gradle.kts
86 lines (70 loc) · 2.76 KB
/
publish-lib.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
import co.early.fore.Shared
import org.gradle.kotlin.dsl.`maven-publish`
import org.gradle.kotlin.dsl.signing
import java.net.URI
apply(plugin = "maven-publish")
apply(plugin = "java-library")
apply(plugin = "signing")
val LIB_ARTIFACT_ID: String? by project
val LIB_DESCRIPTION: String? by project
println("[$LIB_ARTIFACT_ID lib publish file]")
group = "${Shared.Publish.LIB_GROUP}"
version = "${Shared.Publish.LIB_VERSION_NAME}"
configure<JavaPluginExtension> {
withSourcesJar()
withJavadocJar()
}
configure<PublishingExtension> {
publications {
create<MavenPublication>("release") {
groupId = "${Shared.Publish.LIB_GROUP}"
artifactId = LIB_ARTIFACT_ID
version = "${Shared.Publish.LIB_VERSION_NAME}"
from(components["java"])
pom {
name.set("${Shared.Publish.PROJ_NAME}")
description.set(LIB_DESCRIPTION)
url.set("${Shared.Publish.POM_URL}")
licenses {
license {
name.set("${Shared.Publish.LICENCE_NAME}")
url.set("${Shared.Publish.LICENCE_URL}")
}
}
developers {
developer {
id.set("${Shared.Publish.LIB_DEVELOPER_ID}")
name.set("${Shared.Publish.LIB_DEVELOPER_NAME}")
email.set("${Shared.Publish.LIB_DEVELOPER_EMAIL}")
}
}
scm {
connection.set("${Shared.Publish.POM_SCM_CONNECTION}")
developerConnection.set("${Shared.Publish.POM_SCM_CONNECTION}")
url.set("${Shared.Publish.POM_SCM_URL}")
}
}
}
}
repositories {
maven {
name = "mavenCentral"
val releasesRepoUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
val snapshotsRepoUrl = "https://oss.sonatype.org/content/repositories/snapshots/"
val repoUrl = if (Shared.Publish.LIB_VERSION_NAME.endsWith("SNAPSHOT")) snapshotsRepoUrl else releasesRepoUrl
url = URI(repoUrl)
credentials {
username = "${Shared.Secrets.MAVEN_USER}"
password = "${Shared.Secrets.MAVEN_PASSWORD}"
}
}
}
}
configure<SigningExtension> {
extra["signing.keyId"] = "${Shared.Secrets.SIGNING_KEY_ID}"
extra["signing.password"] = "${Shared.Secrets.SIGNING_PASSWORD}"
extra["signing.secretKeyRingFile"] = "${Shared.Secrets.SIGNING_KEY_RING_FILE}"
val pubExt = checkNotNull(extensions.findByType(PublishingExtension::class.java))
val publication = pubExt.publications["release"]
sign(publication)
}