-
Notifications
You must be signed in to change notification settings - Fork 62
/
Copy pathbuild.gradle
59 lines (48 loc) · 1.14 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
plugins {
id 'application'
}
application {
mainClassName = 'com.yworks.example.HelloWorld'
}
jar {
manifest {
attributes(
'Main-Class': application.mainClassName
)
}
}
repositories {
mavenCentral()
}
configurations {
yguard
}
dependencies {
yguard 'com.yworks:yguard:4.1.1'
}
task obfuscate {
dependsOn jar
group 'yGuard'
description 'Obfuscates the java archive.'
doLast {
def archivePath = jar.archiveFile.get().asFile.path
def unobfJar = archivePath.replace(".jar", "_unobf.jar")
ant.move(file: archivePath, tofile: unobfJar, verbose: true)
ant.taskdef(
name: 'yguard',
classname: 'com.yworks.yguard.YGuardTask',
classpath: configurations.yguard.asPath
)
ant.yguard {
inoutpair(in: unobfJar, out: archivePath)
rename(logfile: "${buildDir}/${rootProject.name}_renamelog.xml") {
keep {
'class'(implements: 'java.io.Serializable', methods: 'private', fields: 'private')
method(name: 'void main(java.lang.String[])', class: application.mainClassName)
}
}
}
}
}
distTar.dependsOn obfuscate
distZip.dependsOn obfuscate