-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpublish.gradle
86 lines (80 loc) · 3.02 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
apply plugin: "maven-publish"
def pomConfig = {
licenses {
license {
name "The Apache Software License, Version 2.0"
url "http://www.apache.org/licenses/LICENSE-2.0.txt"
distribution "repo"
}
}
developers {
developer {
id project.findProperty("dev.id")
name project.findProperty("dev.name")
email project.findProperty("dev.email")
}
}
scm {
url project.findProperty("pom.scm")
}
}
publishing {
project.afterEvaluate {
if (!plugins.hasPlugin("android")) {
publications {
mavenJava(MavenPublication) {
artifact bundleReleaseAar
groupId project.findProperty("pom.group")
artifactId project.findProperty("pom.artifact")
version project.findProperty("pom.version")
pom.withXml {
def root = asNode()
root.appendNode('description', project.findProperty("pom.description"))
root.appendNode('name', project.findProperty("pom.name"))
root.appendNode('url', project.findProperty("pom.scm"))
root.children().last() + pomConfig
def dependenciesNode = asNode().appendNode('dependencies')
//Iterate over the compile dependencies (we don't want the test ones), adding a <dependency> node for each
dependenciesToBePackaged()*.each {
def dependencyNode = dependenciesNode.appendNode('dependency')
dependencyNode.appendNode('groupId', it.group)
dependencyNode.appendNode('artifactId', it.name)
dependencyNode.appendNode('version', it.version)
}
}
}
}
}
}
}
gradle.afterProject { graph ->
publishing {
repositories {
if (project.gradle.startParameter.taskNames =~ "publishLocal") {
mavenLocal()
} else {
maven {
name = project.findProperty("pom.artifact")
url = uri("https://maven.pkg.github.com/${project.findProperty("dev.id")}/${project.findProperty("git.bucket")}")
credentials {
username = "${github.user}"
password = "${github.token}"
}
}
}
}
}
}
def dependenciesToBePackaged() {
return configurations.all
.findAll {
!it.name.matches(/.*[tT]est.*/) && it.hierarchy.any {
it.name.matches(/.*(compile|ReleaseCompile)/) && !it.name.matches(/.*[tT]est.*/)
}
}
.collectMany { it.allDependencies }
.findAll { it.version }
.unique(false)
}
task publishLocal
publishLocal.dependsOn 'publish'