forked from DSAppTeam/Robust
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgradle_mvn_push.gradle
71 lines (65 loc) · 2.3 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
66
67
68
69
70
71
apply plugin: 'com.github.dcendents.android-maven'
apply plugin: 'com.jfrog.bintray'
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: uri('../repo')) //仓库的路径,此处是项目根目录下的 repo 的文件夹
pom.groupId = 'com.app.plugin' //groupId ,自行定义,一般是包名
pom.artifactId = 'autopatchplugin' //artifactId ,自行定义
pom.version = '1.0.0' //version 版本号
}
}
//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
// }
//}