-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
78 lines (67 loc) · 1.73 KB
/
build.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
// slimer-core package deliver
apply plugin: 'java'
apply plugin: 'groovy'
buildscript {
repositories {
google()
jcenter()
mavenCentral()
}
dependencies {
}
}
repositories {
google()
jcenter()
mavenCentral()
}
dependencies {
}
ext {
tagVersion = getVersion()
}
task pack(type: Zip){
print "-------start package"
archiveName = "$rootProject.name-${tagVersion}.zip"
destinationDir = file("$projectDir/dist")
from fileTree("$projectDir"){
exclude "gradle*"
exclude "dist"
exclude "build"
exclude ".*"
include "**/*"
}
doLast {
push()
}
}
def push(){
//----check zip file exists
if (!file("$projectDir/dist/$rootProject.name-${tagVersion}.zip").exists()) {
throw new GradleException('There is no zip file generated.')
}
//----upload the zip
def stdout = new ByteArrayOutputStream()
exec {
commandLine 'curl', '-u', "${pushName}:${pushPassword}" ,'-k', "${pushUrl}/$rootProject.name-${tagVersion}.zip", '-T', "$projectDir/dist/$rootProject.name-${tagVersion}.zip"
standardOutput = stdout
}
print stdout.toString().trim()
}
def getVersion(){
Properties version = new Properties()
File pf = new File(rootProject.getRootDir().getAbsolutePath()+'/version.ini')
pf.withInputStream {
version.load(it)
}
return String.format("%s.%s.%s",version.get('VERSION_MAJOR'),version.get('VERSION_MINOR'),version.get('VERSION_BUILD'))
}
def commitID() {
def stdout = new ByteArrayOutputStream()
exec {
//commandLine 'git', 'show', '-s', '--pretty=oneline'
commandLine 'git', 'rev-parse', '--short', 'HEAD'
standardOutput = stdout
}
return stdout.toString().trim()
}