summaryrefslogtreecommitdiff
path: root/enigma/build.gradle
blob: ffea473dac2d1d91e3f29f73eedcdeeaaa39b031 (plain) (blame)
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
configurations {
	proGuard
}

dependencies {
	implementation 'org.ow2.asm:asm:9.6'
	implementation 'org.ow2.asm:asm-commons:9.6'
	implementation 'org.ow2.asm:asm-tree:9.6'
	implementation 'org.ow2.asm:asm-util:9.6'

	implementation 'org.bitbucket.mstrobel:procyon-compilertools:0.6.0'
	implementation 'net.fabricmc:cfr:0.2.2'

	proGuard 'com.guardsquare:proguard-base:7.4.0-beta02'

	testImplementation 'com.google.jimfs:jimfs:1.2'
}

// Generate "version.txt" file

ext.genOutputDir = file("$buildDir/generated-resources")

task generateVersionFile {
	ext.outputFile = file("$genOutputDir/version.txt")
	outputs.file(outputFile)
	doLast {
		outputFile.text = "${project.version}"
	}
}

sourceSets.main.output.dir genOutputDir, builtBy: generateVersionFile

// 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) {
		task("${theFile.name}TestJar", type: 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')
		}

		task("${theFile.name}TestObf", type: 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'