-
Notifications
You must be signed in to change notification settings - Fork 208
/
publish.gradle
149 lines (131 loc) · 4.59 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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
apply plugin: 'maven-publish'
apply plugin: 'com.jfrog.bintray'
project.ext.meta.vcsUrl = "https://github.com/alibaba/GCanvas.git"
version = project.version
buildscript {
repositories {
//本地库,local repository(${user.home}/.m2/repository)
jcenter()
mavenCentral()
maven {
url 'https://maven.google.com/'
name 'Google'
}
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.0'
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.0'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.0'
}
}
def pomConfig = {
url "https://g-platform.github.io"
scm {
url "https://github.com/alibaba/GCanvas"
connection "scm:git:https://github.com/alibaba/GCanvas.git"
developerConnection "scm:git:git@github.com:alibaba/GCanvas.git"
}
licenses {
license {
name 'Apache 2.0'
url 'https://www.apache.org/licenses/LICENSE-2.0'
distribution 'repo'
}
}
developers {
developer {
name "ertong"
email "soandky@gmail.com"
organization "alibaba"
organizationUrl "https://www.alibaba.com/"
}
developer {
name "jwxbond"
email "jwxbond@gmail.com"
organization "alibaba"
organizationUrl "https://www.alibaba.com/"
}
developer {
name "sylonhu"
organization "alibaba"
organizationUrl "https://www.alibaba.com/"
}
developer {
name "xieguanglei"
email "xieguanglei@hotmail.com"
organization "alibaba"
organizationUrl "https://www.alibaba.com/"
}
developer {
name "winter"
organization "alibaba"
organizationUrl "https://www.alibaba.com/"
}
}
}
publishing {
println("$buildDir/outputs/aar/${project.name}-${version}.aar")
publications {
maven(MavenPublication) {
groupId group
artifactId project.ext.id
version version
println("${group}:${project.ext.id}:${version}")
pom.withXml {
def dependenciesNode = asNode().appendNode('dependencies')
configurations.compile.allDependencies.each { dep ->
if (dep.group != null && (dep.name != null && "unspecified" != dep.name) && dep.version != null && dep.version != 'unspecified') {
def dependencyNode = dependenciesNode.appendNode('dependency')
dependencyNode.appendNode('groupId', dep.group)
dependencyNode.appendNode('artifactId', dep.name)
dependencyNode.appendNode('version', dep.version)
}
}
asNode().appendNode("name", "${project.group}:${project.ext.id}")
asNode().appendNode("description", project.ext.meta.description)
asNode().children().last() + pomConfig
}
}
}
}
task sourcesJar(type: Jar) {
from android.sourceSets.main.java.srcDirs
classifier = "sourceJar"
}
task androidJavadocs(type: Javadoc) {
source = android.sourceSets.main.java.srcDirs
}
task androidJavadocsJar(type: Jar, dependsOn: androidJavadocs) {
from androidJavadocs.destinationDir
classifier = "javadoc"
}
artifacts {
archives sourcesJar
archives androidJavadocsJar
}
//上传到jcenter
Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())
bintray {
//读取 local.properties 文件里面的 bintray.user,对应的是https://bintray.com/signup/oss 的用户名
user = properties.getProperty("bintray.user")
//读取 local.properties 文件里面的 bintray.apikey,对应的是https://bintray.com/signup/oss的api-key
key = properties.getProperty("bintray.apikey")
configurations = ['archives']
pkg {
repo = "GCanvas"
name = "${project.group}:${project.ext.id}"
//读取 local.properties 文件里面的 bintray.user,对应的是https://bintray.com/signup/oss 的用户名
userOrg = properties.getProperty("bintray.userOrg")
licenses = ['Apache-2.0']
websiteUrl = "https://g-platform.github.io"
vcsUrl = project.ext.meta.vcsUrl
labels = project.ext.meta.labels
version {
name = project.version
desc = project.ext.meta.description
vcsTag = project.version
}
}
}