-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpublish.gradle.kts
46 lines (43 loc) · 1.37 KB
/
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
import java.util.Properties
/**
* includeBuild 和 include 路径不一样
*/
val properties = Properties().apply {
try {
load(rootProject.file("./local.properties").inputStream())
} catch (e: Exception) {
load(rootProject.file("../local.properties").inputStream())
}
}
val testUrl: String by properties
val testName: String by properties
val testPassword: String by properties
val ossrhUsername: String by properties
val ossrhPassword: String by properties
val uploadRepository: Action<RepositoryHandler> = Action<RepositoryHandler> {
maven {
val publicUrl = when {
version.toString()
.endsWith("SNAPSHOT") -> "https://s01.oss.sonatype.org/content/repositories/snapshots/"
version.toString().endsWith(".test") -> testUrl
else -> "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
}
url = uri(publicUrl)
isAllowInsecureProtocol = true
credentials {
if (version.toString().endsWith(".test")) {
username = testName
password = testPassword
} else {
username = ossrhUsername
password = ossrhPassword
}
}
}
mavenLocal()
}
mapOf(
"uploadRepository" to uploadRepository
).forEach { (name, closure) ->
project.extra.set(name, closure)
}