-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
77 lines (65 loc) · 1.87 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
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'application'
repositories {
mavenCentral()
jcenter()
}
version = '1.0'
def getVersionCode = { ->
try {
def stdout = new ByteArrayOutputStream()
exec {
commandLine 'git', 'rev-list', '--count', 'head'
standardOutput = stdout
}
return Integer.parseInt(stdout.toString().trim())
}
catch (ignored) {
return -1
}
}
static def getGitBranch() {
def branch = ""
def proc = "git rev-parse --abbrev-ref HEAD".execute()
proc.in.eachLine { line -> branch = line }
proc.err.eachLine { line -> println line }
proc.waitFor()
branch
}
println "####### Build Data #######"
println "======> Version: " + getVersionCode()
println "======> Branch: " + getGitBranch()
dependencies {
compile 'com.google.guava:guava:20.0'
compile 'commons-cli:commons-cli:1.4'
testCompile 'junit:junit:4.12'
}
mainClassName = 'App'
task fatJar(type: Jar) {
description = "Packages a complete JAR file"
manifest {
attributes 'Implementation-Title': 'Encrypt files into images and back again',
'Implementation-Version': version,
'Main-Class': 'App'
}
baseName = project.name + ''
from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
with jar
}
task copyJar(type: Copy) {
description = "Copy the created JAR file from /build/libs/ to /example/"
from file("${buildDir}/libs/${project.name}-${version}.jar")
into file("${projectDir}/example")
}
task superBuild(dependsOn: ['clean', 'build', 'fatJar', 'copyJar']){
description = "Cleans, Builds and creates a complete release JAR file"
build.mustRunAfter clean
fatJar.mustRunAfter build
copyJar.mustRunAfter fatJar
}
run {
if (project.hasProperty("appArgs")) {
args Eval.me(appArgs)
}
}