-
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathdeploy-bintray.gradle.kts
132 lines (120 loc) · 4.63 KB
/
deploy-bintray.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
import com.jfrog.bintray.gradle.BintrayExtension
import com.jfrog.bintray.gradle.BintrayPlugin
import java.io.FileInputStream
import java.util.*
buildscript {
repositories {
jcenter()
}
dependencies {
classpath(Libs.com_jfrog_bintray_gradle_bintray_plugin)
}
}
apply(plugin = Libs.maven_publish)
plugins.apply(BintrayPlugin::class.java) //https://github.com/bintray/gradle-bintray-plugin/issues/301
val bintrayRepo = properties["bintrayRepo"].toString()
val libraryVersion = properties["libraryVersion"].toString()
val libraryDescription = properties["libraryDescription"].toString()
val siteUrl = properties["siteUrl"].toString()
val gitUrl = properties["gitUrl"].toString()
configure<BintrayExtension> {
val bintrayName = properties["bintrayName"].toString()
val mavenUser: String
val mavenToken: String
if (project.rootProject.file("local.properties").exists()) {
val fis = FileInputStream(project.rootProject.file("local.properties"))
val prop = Properties()
prop.load(fis)
user = prop.getProperty("bintray.user", "")
key = prop.getProperty("bintray.apiKey", "")
mavenUser = prop.getProperty("maven.user", "")
mavenToken = prop.getProperty("maven.token", "")
} else {
user = System.getenv("bintrayUser")
key = System.getenv("bintrayApiKey")
mavenUser = System.getenv("mavenUser") ?: ""
mavenToken = System.getenv("mavenToken") ?: ""
}
setPublications(bintrayRepo)
override = true
pkg.apply {
repo = bintrayRepo
name = bintrayName
description = libraryDescription
websiteUrl = siteUrl
issueTrackerUrl = "$siteUrl/issues"
vcsUrl = gitUrl
setLicenses("Apache-2.0")
publish = true
publicDownloadNumbers = true
version.apply {
name = libraryVersion
vcsTag = libraryVersion
desc = libraryDescription
released = Date().toString()
if (mavenToken.isNotEmpty())
mavenCentralSync.apply {
sync = true
user = mavenUser
password = mavenToken
}
}
}
}
configure<PublishingExtension> {
val artifact = properties["artifact"].toString()
val publishedGroupId = properties["publishedGroupId"].toString()
val libraryName = properties["libraryName"].toString()
val developerId = properties["developerId"].toString()
val developerName = properties["developerName"].toString()
val developerEmail = properties["developerEmail"].toString()
publications {
create<MavenPublication>(bintrayRepo) {
groupId = publishedGroupId
artifactId = artifact
version = libraryVersion
artifact(tasks.getByName("sourcesJar"))
artifact(tasks.getByName("dokkaJar"))
artifact("$buildDir/outputs/aar/${artifactId}-release.aar") {
builtBy(tasks.getByName("assemble"))
}
pom {
packaging = "aar"
name.set(libraryName)
description.set(libraryDescription)
url.set(siteUrl)
scm {
connection.set(gitUrl)
developerConnection.set(connection.get())
url.set(siteUrl)
}
issueManagement { url.set("$siteUrl/issues") }
licenses {
license {
name.set("The Apache Software License, Version 2.0")
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
}
}
developers {
developer {
id.set(developerId)
name.set(developerName)
email.set(developerEmail)
}
}
withXml {
val dependenciesNode = asNode().appendNode("dependencies")
// note: replace with the desired configuration (ex: api, testImplementation, etc...)
configurations.getByName("implementation") {
dependencies.forEach {
val dependencyNode = dependenciesNode.appendNode("dependency")
dependencyNode.appendNode("groupId", it.group)
dependencyNode.appendNode("artifactId", it.name)
dependencyNode.appendNode("version", it.version)
}
}
}
}
}
}
}