-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbintray.gradle
106 lines (88 loc) · 3.37 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
103
104
105
106
/**
* Upload artifacts to Bintray and synchronization with Maven
*
* @param bintrayUser (required) bintray user
* @param bintrayKey (required) bintray API key
* @param bintrayOrg (required) bintray organization
* @param bintrayRepo (required) bintray organization
* @param bintrayGPGPass (optional) gpg passphrase to enable autosigning
* @param bintrayPublish (optional) publishing to bintray
* @param mavenUser (optional) Sonatype user
* @param mavenPassword (optional) Sonatype password
*
* To specify parameters from command line use '-P' prefix
* e.g. -PbintrayUser='user'
*/
apply plugin: 'com.jfrog.bintray'
def requiredParams = ["bintrayUser", "bintrayKey", "bintrayOrg", "bintrayRepo"]
for (param in requiredParams) {
if (!project.hasProperty(param)) {
throw new GradleException("Missing '-P${param}' required argument")
}
}
def BINTRAY_DRYRUN = false
def BINTRAY_PUBLISH = project.has('bintrayPublish') ? project.ext.bintrayPublish : false
def MAVEN_SYNC = false
def MAVEN_CLOSE = '0'
def BINTRAY_PROJECT_NAME = "${project.group}.${project.ext.archivesBaseName}"
publishing.publications.pluginMaven(MavenPublication) {
pom.withXml {
asNode().appendNode('description', project.ext.pomDesc)
asNode().appendNode('url', 'http://tools.android.com/')
asNode().appendNode('name', BINTRAY_PROJECT_NAME)
Node license = asNode().appendNode('licenses').appendNode('license')
license.appendNode('name', 'The Apache Software License, Version 2.0')
license.appendNode('url', 'http://www.apache.org/licenses/LICENSE-2.0.txt')
license.appendNode('distribution', 'repo')
asNode().appendNode('developers')
.appendNode('developer')
.appendNode('name', 'The Android Open Source Project')
Node scm = asNode().appendNode('scm')
scm.appendNode('connection', 'git://android.googlesource.com/platform/tools/base.git')
scm.appendNode('url', 'https://android.googlesource.com/platform/tools/base')
}
}
bintray {
user = project.ext.bintrayUser
key = project.ext.bintrayKey
dryRun = BINTRAY_DRYRUN
publish = BINTRAY_PUBLISH
publications = ['pluginMaven']
pkg {
repo = project.ext.bintrayRepo
userOrg = project.ext.bintrayOrg
name = BINTRAY_PROJECT_NAME
desc = project.ext.pomDesc
licenses = ['Apache-2.0']
publicDownloadNumbers = true
vcsUrl = 'git://android.googlesource.com/platform/tools/base.git'
version {
name = project.version
desc = project.ext.pomDesc + ' version ' + project.version
released = new java.util.Date()
}
}
}
if (project.hasProperty('bintrayGPGPass')) {
bintray.pkg.version.gpg {
sign = true
passphrase = project.ext.bintrayGPGPass
}
}
if (project.hasProperty('mavenUser') && project.hasProperty('mavenPassword')) {
bintray.pkg.version.mavenCentralSync {
sync = MAVEN_SYNC
user = project.ext.mavenUser
password = project.ext.mavenPassword
close = MAVEN_CLOSE
}
bintrayUpload.doFirst {
project.logger.quiet('MavenCentral credentials detected')
if (MAVEN_SYNC) {
project.logger.quiet('Uploading to MavenCentral')
} else {
project.logger.quiet('MavenSync is disabled. '
+ 'Upload to MavenCentral is cancelled')
}
}
}