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
|
configurations {
proGuard
}
dependencies {
implementation 'org.ow2.asm:asm:9.7.1'
implementation 'org.ow2.asm:asm-commons:9.7.1'
implementation 'org.ow2.asm:asm-tree:9.7.1'
implementation 'org.ow2.asm:asm-util:9.7.1'
implementation 'org.bitbucket.mstrobel:procyon-compilertools:0.6.0'
implementation 'net.fabricmc:cfr:0.2.2'
implementation 'org.vineflower:vineflower:1.10.1'
proGuard 'com.guardsquare:proguard-base:7.4.0-beta02'
testImplementation 'com.google.jimfs:jimfs:1.2'
}
// Generate "version.txt" file
def genOutputDir = layout.buildDirectory.dir('generated-resources').get().asFile
tasks.register('generateResources') {
def langDir = file('src/main/resources/lang')
inputs.dir(langDir)
inputs.property 'version', project.version
def versionFile = file("$genOutputDir/version.txt")
def langsFile = file("$genOutputDir/lang/index.txt")
outputs.files(versionFile, langsFile)
doLast {
versionFile.text = inputs.properties.version
langsFile.text = langDir
.listFiles()
.collect { it.name }
.findAll { it.endsWith(".json") }
.collect { it.substring(0, it.length() - 5) }
.join("\n")
}
}
sourceSets.main.output.dir genOutputDir, builtBy: generateResources
// Generate obfuscated JARs for tests
def libraryJarsArg = "<java.home>/jmods"
// If your test fails for class file version problem with proguard, run gradle with -Dorg.gradle.java.home="<older jdk>" flag
file('src/test/java/cuchaz/enigma/inputs').listFiles().each { theFile ->
if (theFile.directory) {
tasks.register("${theFile.name}TestJar", Jar) {
from(sourceSets.test.output) {
include "cuchaz/enigma/inputs/$theFile.name/**/*.class"
include 'cuchaz/enigma/inputs/Keep.class'
}
archiveFileName = theFile.name + '.jar'
destinationDirectory = file('build/test-inputs')
}
tasks.register("${theFile.name}TestObf", JavaExec) {
dependsOn "${theFile.name}TestJar"
mainClass = 'proguard.ProGuard'
classpath configurations.proGuard
args '@src/test/resources/proguard-test.conf', '-injars', file('build/test-inputs/' +
"${theFile.name}.jar"), '-libraryjars', libraryJarsArg,
'-outjars', file('build/test-obf/' + "${theFile.name}.jar")
}
test.dependsOn "${theFile.name}TestObf"
}
}
test.dependsOn 'translationTestObf'
|