-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
89 lines (69 loc) · 2.15 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
79
80
81
82
83
84
85
86
87
88
89
apply plugin: 'java'
apply plugin: 'idea'
import org.apache.tools.ant.filters.ReplaceTokens
sourceCompatibility = 1.7
version = '0.1-rc'
jar {
manifest {
attributes 'JNapios': 'JNapios', 'Implementation-Version': version
manifest.attributes("Main-Class": "org.jnapios.ApplicationBootstrap")
}
/*
*This will create a "fat jar". The jar file generated will include all it's dependencies.
*It will be a "big" file, but it can be run with just "java -jar file.jar"
*without the need to worry about jar dependencies
*/
from {
configurations.compile.collect {
it.isDirectory() ? it : zipTree(it)
}
}
doLast{
copy {
from 'JNapios.sh'
into 'build/libs'
filter(ReplaceTokens, tokens: [jar_file: jar.archiveName])
}
}
}
repositories { mavenCentral() }
buildscript {
repositories { mavenCentral() }
//to enable the use of proguard
dependencies { classpath 'net.sf.proguard:proguard-gradle:4.10' }
}
dependencies {
compile 'org.apache.httpcomponents:httpcore:4.3',
'com.google.code.gson:gson:2.2.4',
'org.tinylog:tinylog:0.8'
testCompile 'junit:junit:4.11'
}
task wrapper(type: Wrapper) {
gradleVersion = '2.1'
}
/*
* Proguard is a tool that performs a bunch of tasks in the generated jar file.
* "...Java class file shrinker, optimizer, obfuscator, and preverifier." from: http://proguard.sourceforge.net/
*/
task minify(type: proguard.gradle.ProGuardTask) {
ext {
outDir = file("${buildDir}/libs/proguard")
obfuscatedJar = "${outDir}/${jar.archiveName}"
}
outDir.mkdirs()
injars jar.archivePath
outjars obfuscatedJar
libraryjars System.getProperty("java.home") + '/lib/rt.jar'
//application entry-point
keep 'public class org.jnapios.ApplicationBootstrap { \
public static void main(java.lang.String[]); \
}'
//we don't need obfuscation. And it breaks the json format that we want.
dontobfuscate
//Optimizations break the code. The parser works in a different way... probably it should be rewrited, but not for now.
dontoptimize
printmapping "${outDir}/mappings.out"
doLast {
logger.lifecycle "[Proguard] Generated obfuscated JAR in ${obfuscatedJar}"
}
}