-
Notifications
You must be signed in to change notification settings - Fork 0
/
ossrh.gradle
83 lines (73 loc) · 2.94 KB
/
ossrh.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
File ossrhProp = project.rootProject.file('ossrh.properties')
if (ossrhProp.exists()) {
apply plugin: 'maven-publish'
apply plugin: 'signing'
Properties p = new Properties()
p.load(new FileInputStream(ossrhProp))
p.each { name, value ->
ext[name] = value
}
task androidSourcesJar(type: Jar) {
classifier = 'sources'
from android.sourceSets.main.java.source
}
artifacts {
archives androidSourcesJar
}
publishing {
publications {
release(MavenPublication) {
// The coordinates of the library, being set from variables that
// we'll set up in a moment
groupId publishGroupId
artifactId publishArtifactId
version libraryVersion
// Two artifacts, the `aar` and the sources
artifact("$buildDir/outputs/aar/${project.getName()}-release.aar")
artifact androidSourcesJar
// Self-explanatory metadata for the most part
pom {
name = publishArtifactId
description = libraryDescription
// If your project has a dedicated site, use its URL here
url = siteUrl
licenses {
license {
name = licenseName
url = licenseUrl
}
}
developers {
developer {
id = developerId
name = developerName
email = developerEmail
}
}
// Version control info, if you're using GitHub, follow the format as seen here
scm {
connection = scmConnection
developerConnection = scmDeveloperConnection
url = scmUrl
}
// A slightly hacky fix so that your POM will include any transitive dependencies
// that your library builds upon
withXml {
def dependenciesNode = asNode().appendNode('dependencies')
project.configurations.implementation.allDependencies.each {
if (it.group != null && it.name != null) {
def dependencyNode = dependenciesNode.appendNode('dependency')
dependencyNode.appendNode('groupId', it.group)
dependencyNode.appendNode('artifactId', it.name)
dependencyNode.appendNode('version', it.version)
}
}
}
}
}
}
}
signing {
sign publishing.publications
}
}