-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathbintray.gradle
103 lines (83 loc) · 2.91 KB
/
bintray.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
// ./gradlew clean build generateRelease
apply plugin: 'maven'
apply plugin: 'com.github.dcendents.android-maven'
apply plugin: 'com.jfrog.bintray'
def groupId = project.PUBLISH_GROUP_ID
def artifactId = project.PUBLISH_ARTIFACT_ID
def lib_version = project.PUBLISH_VERSION
configurations {
optional
compile.extendsFrom optional
}
def localReleaseDest = "${buildDir}/release/${lib_version}"
task androidJavadocs(type: Javadoc) {
source = android.sourceSets.main.java.srcDirs
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
}
task androidJavadocsJar(type: Jar, dependsOn: androidJavadocs) {
classifier = 'javadoc'
from androidJavadocs.destinationDir
}
task androidSourcesJar(type: Jar) {
classifier = 'sources'
from android.sourceSets.main.java.srcDirs
}
uploadArchives {
repositories.mavenDeployer {
pom.groupId = groupId
pom.artifactId = artifactId
pom.version = lib_version
pom.withXml {
asNode().dependencies.dependency.findAll { xmlDep ->
// mark optional dependencies
if (project.configurations.optional.allDependencies.findAll { dep ->
xmlDep.groupId.text() == dep.group && xmlDep.artifactId.text() == dep.name
}) {
def xmlOptional = xmlDep.optional[0];
if (!xmlOptional) {
xmlOptional = xmlDep.appendNode('optional')
}
xmlOptional.value = 'true';
}
}
}
// Add other pom properties here if you want (developer details / licenses)
repository(url: "file://${localReleaseDest}")
}
}
task zipRelease(type: Zip) {
from localReleaseDest
destinationDir buildDir
archiveName "release-${lib_version}.zip"
}
task generateRelease << {
println "Release ${lib_version} can be found at ${localReleaseDest}/"
println "Release ${lib_version} zipped can be found ${buildDir}/release-${lib_version}.zip"
}
generateRelease.dependsOn(uploadArchives)
generateRelease.dependsOn(zipRelease)
artifacts {
archives androidSourcesJar
archives androidJavadocsJar
}
// --------------------
def siteUrl = project.WEBSITE_URL
def gitUrl = project.VSC_URL
def libName = project.LIB_NAME
group = project.PUBLISH_GROUP_ID
version = lib_version
Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())
bintray {
user = properties.getProperty("bintray.user")
key = properties.getProperty("bintray.apikey")
configurations = ['archives']
pkg {
repo = "maven" //发布到Bintray的那个仓库里,默认账户有四个库,我们这里上传到maven库
name = libName //发布到Bintray上的项目名字
websiteUrl = siteUrl
vcsUrl = gitUrl
licenses = ["Apache-2.0"]
publish = true
}
}