-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmaven.publish.gradle.kts
87 lines (78 loc) · 2.61 KB
/
maven.publish.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
// From https://stackoverflow.com/a/63502756/3891161
import org.gradle.api.publish.PublishingExtension
import java.io.FileInputStream
import java.util.*
apply(plugin = "maven-publish")
val localProperties = Properties().apply {
val file = project.rootProject.file("local.properties")
if (file.exists()) {
load(FileInputStream(file))
}
}
val bintrayUser: String = System.getenv("BINTRAY_USER") ?: localProperties.getProperty("bintrayUser") ?: ""
val bintrayApiKey: String = System.getenv("BINTRAY_API_KEY") ?: localProperties.getProperty("bintrayApiKey") ?: ""
val libraryVersion: String by project
val publishedGroupId: String by project
val artifact: String by project
val bintrayRepo: String by project
val libraryName = project.name
val bintrayName: String by project
val libraryDescription: String by project
val siteUrl: String by project
val gitUrl: String by project
val licenseName: String by project
val licenseUrl: String by project
val developerName: String by project
val developerEmail: String by project
val developerId: String by project
project.group = publishedGroupId
project.version = libraryVersion
afterEvaluate {
configure<PublishingExtension> {
publications.all {
val mavenPublication = this as? MavenPublication
mavenPublication?.artifactId =
"${project.name}${"-$name".takeUnless { "kotlinMultiplatform" in name }.orEmpty()}"
}
}
}
configure<PublishingExtension> {
publications {
withType<MavenPublication> {
groupId = publishedGroupId
artifactId = artifact
version = libraryVersion
pom {
name.set(libraryName)
description.set(libraryDescription)
url.set(siteUrl)
licenses {
license {
name.set(licenseName)
url.set(licenseUrl)
}
}
developers {
developer {
id.set(developerId)
name.set(developerName)
email.set(developerEmail)
}
}
scm {
connection.set(gitUrl)
developerConnection.set(gitUrl)
url.set(siteUrl)
}
}
}
}
repositories {
maven("https://api.bintray.com/maven/$bintrayUser/$bintrayRepo/$artifact/;publish=1") {
credentials {
username = bintrayUser
password = bintrayApiKey
}
}
}
}