-
Notifications
You must be signed in to change notification settings - Fork 809
/
gradle_mvn_push.gradle
65 lines (59 loc) · 1.93 KB
/
gradle_mvn_push.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
apply plugin: 'com.github.dcendents.android-maven'
apply plugin: 'com.jfrog.bintray'
group = GROUP
version = VERSION_NAME
def getPropertyFromLocalProperties(key) {
File file = project.rootProject.file('local.properties');
if (file.exists()) {
Properties properties = new Properties()
properties.load(file.newDataInputStream());
return properties.getProperty(key)
}
}
def getRepositoryUrl() {
return isSnapshot() ? getPropertyFromLocalProperties("SNAPSHOT_REPOSITORY_URL") : getPropertyFromLocalProperties("RELEASE_REPOSITORY_URL")
// return isSnapshot() ? SNAPSHOT_REPOSITORY_URL : RELEASE_REPOSITORY_URL
}
def isSnapshot() {
return version.endsWith("SNAPSHOT");
}
def hasAndroidPlugin() {
return getPlugins().inject(false) { a, b->
def classStr = b.getClass().name
def isAndroid = ("com.android.build.gradle.LibraryPlugin" == classStr) || ("com.android.build.gradle.AppPlugin" == classStr)
a || isAndroid
}
}
task sourcesJar(type: Jar) {
if (hasAndroidPlugin()) {
from android.sourceSets.main.java.srcDirs
classifier = 'sources'
} else {
from sourceSets.main.allSource
classifier = 'sources'
}
}
artifacts {
archives sourcesJar
}
uploadArchives {
repositories.mavenDeployer {
repository(url: repositoryUrl) {
authentication(userName: getPropertyFromLocalProperties("USER"), password: getPropertyFromLocalProperties("PASSWORD"))
}
}
}
bintray {
user = getPropertyFromLocalProperties("bintray.user")
key = getPropertyFromLocalProperties("bintray.apikey")
configurations = ['archives']
pkg {
repo = 'maven'
name = "${project.group}:${project.name}"
userOrg = 'meituan'
licenses = ['Apache-2.0']
websiteUrl = 'http://tech.meituan.com/android_autopatch.html'
vcsUrl = 'https://github.com/Meituan-Dianping/Robust'
publish = true
}
}