-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathuploadToBintray.sh
executable file
·140 lines (117 loc) · 3.73 KB
/
uploadToBintray.sh
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
#!/bin/bash
bintrayRepoName=""
bintrayUser=""
## Config bintray info
echo "## Bintray config" > ../bintray.properties
if [ $# == 2 ]
then
echo "bintray.user = $1" >> ../bintray.properties
echo "bintray.apikey = $2" >> ../bintray.properties
else
echo "请输入你的bintray用户名, 例如:yat3s"
read line
echo "bintray.user = $line" >> ../bintray.properties
bintrayUser=$line
echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>"
echo "请输入你的bintray apikey, 例如:8c1f37bdb49e4b64e8b1c4954e19bbf7a42045e3"
read line
echo "bintray.apikey = $line" >> ../bintray.properties
fi
## Config repo info
echo "## Deploy config" > ../deploy.settings
echo ">>>>>>>>>>>(1/4)>>>>>>>>>>>>>>>>>"
echo "接下来我们配置一下你的项目信息吧"
echo "告诉我你的项目的地址,例如:https://github.com/Yat3s/BaseRecyclerViewAdapter"
read line
echo "siteUrl = $line" >> ../deploy.settings
echo "gitUrl = $line.git" >> ../deploy.settings
echo ">>>>>>>>>>>(2/4)>>>>>>>>>>>>>>>>>"
echo "告诉我你的groupId,例如:com.yat3s.library"
read line
echo "groupId = $line" >> ../deploy.settings
echo ">>>>>>>>>>>(3/4)>>>>>>>>>>>>>>>>>"
echo "接着告诉我你的项目名称吧,例如:NineOldAndroid"
read line
echo "name = $line" >> ../deploy.settings
bintrayRepoName=$line
echo ">>>>>>>>>>>(4/4)>>>>>>>>>>>>>>>>>"
echo "最后告诉我你的版本吧,例如:1.0.0"
read line
echo "version = $line" >> ../deploy.settings
## Add deploy.gradle
cat>deploy.gradle<<EOF
apply plugin: 'com.github.dcendents.android-maven'
apply plugin: 'com.jfrog.bintray'
def artifact = new Properties()
artifact.load(new FileInputStream("deploy.settings"))
group = artifact.groupId
version = artifact.version
install {
repositories.mavenInstaller {
pom.project {
packaging 'aar'
groupId artifact.groupId
name artifact.name
url artifact.siteUrl
licenses {
license { // HARDCODED
name 'The Apache Software License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
distribution 'repo'
}
}
scm {
connection artifact.gitUrl
developerConnection artifact.gitUrl
url artifact.siteUrl
}
}
}
}
Properties properties = new Properties()
properties.load(project.rootProject.file('bintray.properties').newDataInputStream())
bintray {
user = properties.getProperty("bintray.user")
key = properties.getProperty("bintray.apikey")
configurations = ['archives']
pkg {
repo = "maven"
name = artifact.name
websiteUrl = artifact.siteUrl
vcsUrl = artifact.gitUrl
licenses = ['Apache-2.0']
publish = true
}
}
task sourcesJar(type: Jar) {
from android.sourceSets.main.java.srcDirs
classifier = 'sources'
}
task javadoc(type: Javadoc) {
source = android.sourceSets.main.java.srcDirs
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
artifacts {
archives javadocJar
archives sourcesJar
}
EOF
echo "apply from: 'deploy.gradle'" >> build.gradle
## Add dependencise to project bulid.gradle
cd ../
sed -i -e '/dependencies {/a\
classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:1.2"; classpath "com.github.dcendents:android-maven-gradle-plugin:1.3"
' build.gradle &&
rm build.gradle-e
./gradlew install &&
./gradlew bintrayUpload &&
echo "上传成功,是否立即打开你的bintray项目主页(y/n)"
read line
if [ $line = "y" ];
then
open https://bintray.com/${bintrayUser}/maven/${bintrayRepoName}
fi