forked from queueit/android-webui-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpublish.gradle
110 lines (98 loc) · 3.37 KB
/
publish.gradle
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
apply plugin: 'maven-publish'
apply plugin: 'signing'
apply plugin: "de.marcphilipp.nexus-publish"
group = groupId
version = libraryVersion
def pomConfig = {
description libraryDescription
licenses {
license {
name licenseName
url licenseUrl
}
}
scm {
connection gitUrl
developerConnection gitUrl
url siteUrl
}
developers {
developer {
name "Developers"
email "[email protected]"
organization organization
organizationUrl organizationUrl
}
}
}
afterEvaluate {
configurations.all {
if (it.name =~ /DebugAll(Api|Runtime)Publication$/) {
components.all.withVariantsFromConfiguration(it) {
skip()
}
}
}
publishing.publications {
android.libraryVariants.all { variant ->
if (variant.buildType.name == "debug") return // Prevents publishing debug library
def flavored = !variant.flavorName.isEmpty()
/**
* Translates "_" in flavor names to "-" for artifactIds, because "-" in flavor name is an
* illegal character, but is well used in artifactId names.
*/
def variantArtifactId = flavored ? variant.flavorName.replace('_', '-') : project.name
def publicationName = "android-webui-sdk-${variant.name.capitalize()}"
def sourceDirs = variant.sourceSets.collect {
it.javaDirectories // Also includes kotlin sources if any.
}
def sourcesJar = task("${variant.name}SourcesJar", type: Jar) {
description "Puts sources for ${variant.name} in a jar."
from sourceDirs
classifier = 'sources'
}
"$publicationName"(MavenPublication) {
from components."release"
artifactId variantArtifactId
group groupId
version libraryVersion
artifact sourcesJar
pom {
withXml {
def root = asNode()
root.appendNode("name", "${libraryName}:${variantArtifactId}")
root.appendNode("url", siteUrl)
root.appendNode("description", libraryDescription)
root.children().last() + pomConfig
root.dependencies.removeAll { dep ->
dep.scope == "test"
}
// Create a signed pom if we need it
def pomFile = file("${project.buildDir}/generated-${variant.flavorName}-pom.xml")
writeTo(pomFile)
// signing.sign(pomFile)
}
}
}
}
}
}
Properties localProps = new Properties()
if (rootProject.file("local.properties").exists()) {
localProps.load(rootProject.file("local.properties").newDataInputStream())
}
//Sign all of our publications with our PGP private key
//signing {
// useInMemoryPgpKeys(PGP_KEY, PGP_PASSWORD)
// publishing.publications.all { publication ->
// sign(publication)
// }
//}
nexusPublishing {
repositories {
sonatype {
username.set(OSSRH_USERNAME)
password.set(OSSRH_PASSWORD)
}
}
}