summaryrefslogtreecommitdiff
path: root/build.gradle
diff options
context:
space:
mode:
authorGravatar Michael Smith2015-05-21 23:30:00 +0100
committerGravatar Michael Smith2015-05-21 23:30:00 +0100
commite3f452250e51b7271f3989c7dfd12e4422934942 (patch)
tree5aa482f9a6e21eb318a3e23e7d8274d77c73faf6 /build.gradle
downloadenigma-e3f452250e51b7271f3989c7dfd12e4422934942.tar.gz
enigma-e3f452250e51b7271f3989c7dfd12e4422934942.tar.xz
enigma-e3f452250e51b7271f3989c7dfd12e4422934942.zip
Support Gradle alongside SSJB
This makes builds faster, simpler and better automated but still keeps Cuchaz happy. :)
Diffstat (limited to 'build.gradle')
-rw-r--r--build.gradle176
1 files changed, 176 insertions, 0 deletions
diff --git a/build.gradle b/build.gradle
new file mode 100644
index 00000000..48ad4272
--- /dev/null
+++ b/build.gradle
@@ -0,0 +1,176 @@
1// Do it this way so people with older Gradle can hopefully still build.
2buildscript {
3 repositories { jcenter() }
4
5 dependencies {
6 classpath 'com.github.jengelman.gradle.plugins:shadow:1.2.1'
7 }
8}
9
10apply plugin: 'java'
11apply plugin: 'eclipse'
12apply plugin: 'com.github.johnrengelman.shadow'
13apply plugin: 'maven'
14
15group = 'cuchaz'
16version = '0.10.4b'
17
18sourceCompatibility = 1.7
19targetCompatibility = 1.7
20
21// Custom source layout
22sourceSets {
23 main {
24 java { srcDir 'src' }
25 resources { srcDir 'conf' }
26 }
27 test {
28 java { srcDir 'test' }
29 resources { srcDir 'test' }
30 }
31}
32
33repositories {
34 mavenLocal()
35 mavenCentral()
36
37 maven {
38 name "Cuchaz Custom Repository"
39 url 'http://maven.cuchazinteractive.com'
40 }
41}
42
43configurations {
44 proGuard // used to download ProGuard
45 application // used for JSyntaxPane so it's not in the library POM
46
47 compile.extendsFrom application
48}
49
50dependencies {
51 compile 'com.google.guava:guava:17.+'
52 compile 'org.javassist:javassist:3.+'
53 compile 'org.bitbucket.mstrobel:procyon-decompiler:0.5.28-enigma'
54 application 'de.sciss:syntaxpane:1.1.+'
55
56 testCompile 'junit:junit:4.+'
57 testCompile 'org.hamcrest:hamcrest-all:1.+'
58
59 proGuard 'net.sf.proguard:proguard-base:5.+'
60}
61
62// For each set of test inputs, create an output jar and obfuscate it.
63file('test/cuchaz/enigma/inputs').listFiles().each {theFile ->
64 if (theFile.directory) {
65 task("${theFile.name}TestJar", type: Jar, dependsOn: testClasses) {
66 from ('build/classes/test') {
67 include 'cuchaz/enigma/inputs/$theFile.name/**/*.class'
68 include 'cuchaz/enigma/inputs/Keep.class'
69 }
70
71 archiveName = theFile.name + '.jar'
72 destinationDir = file('build/test-inputs')
73 }
74
75 task ("${theFile.name}TestObf", type: JavaExec,
76 dependsOn: "${theFile.name}TestJar") {
77 main 'proguard.ProGuard'
78 classpath configurations.proGuard
79
80 args '@proguard-test.conf', '-injars', file('build/test-inputs/' +
81 "${theFile.name}.jar"), '-outjars', file('build/test-obf/' +
82 "${theFile.name}.jar")
83 }
84
85 test.dependsOn "${theFile.name}TestObf"
86 }
87}
88
89// We also semi-deobfuscate translation.jar to then test it... yeah... oh well.
90task ('deobfTranslationInput', type: JavaExec, dependsOn: 'translationTestObf')
91{
92 classpath sourceSets.main.runtimeClasspath
93 main 'cuchaz.enigma.CommandMain'
94 args 'deobfuscate', file('build/test-obf/translation.jar'),
95 file('build/test-deobf/translation.jar')
96}
97test.dependsOn 'deobfTranslationInput'
98
99test {
100 // Since the Minecraft test is really long (like 10 minutes D:) we turn it
101 // off by default.
102 if (!System.getProperty('enableExtremelySlowMinecraftTest', '')
103 .equalsIgnoreCase('true')) {
104 exclude 'cuchaz/enigma/TestSourceIndex.class'
105 }
106
107 // Allow people to specify a custom path to their Minecraft directory.
108 // (Example: `gradle build -Denigma.test.minecraftdir=./`)
109 systemProperties = [
110 'enigma.test.minecraftdir': System.getProperty('test.minecraftdir')
111 ]
112}
113
114// Set the main class.
115jar.manifest.attributes 'Main-Class': 'cuchaz.enigma.Main'
116
117// Make the "fat" application jar. This is useful to just throw in a classpath
118// for tests, though it includes some slightly useless stuff.
119shadowJar {
120 append 'license.LGPL3.txt'
121 append 'license.APL2.txt'
122 append 'readme.txt'
123
124 exclude 'META-INF/maven/**'
125}
126
127// Now make the deployable application jar with extra classes stripped out using
128// ProGuard (don't use JavaExec because we want to redirect output to a file).
129task('thinJar', dependsOn: shadowJar) << {
130 javaexec {
131 main 'proguard.ProGuard'
132 classpath configurations.proGuard
133
134 args '@proguard-build.conf', '-injars', shadowJar.archivePath,
135 // well this works...
136 '-outjars', file("build/libs/$project.name-${version}-thin.jar")
137
138 // Cut down on console spam
139 standardOutput new File(buildDir, 'proguard.log').newOutputStream();
140 }
141 println 'Saved ProGuard output to build/proguard.log'
142}
143
144// Create a library jar, containing only the deobfuscation code, for use at
145// runtime. This will be deployed to Maven Local with a POM, and can be uploaded
146// to a remote server manually (for now anyway).
147task('libJar', type: Jar, dependsOn: classes) {
148 baseName = 'enigma-lib'
149
150 from("$buildDir/classes/main") {
151 exclude 'cuchaz/enigma/gui/**'
152 exclude 'cuchaz/enigma/convert/**'
153
154 // Main classes + inner classes (keep CommandMain)
155 exclude 'cuchaz/enigma/Main.class'
156 exclude 'cuchaz/enigma/Main.class'
157 exclude 'cuchaz/enigma/ConvertMain*.class'
158 }
159}
160artifacts.archives libJar { name 'enigma-lib' }
161
162// Here we need a bit of hackery to remove the default Maven deployment and just
163// deploy enigma-lib. Works, but not ideal :(
164configurations.archives {
165 artifacts.iterator().with {
166 while(it.hasNext()) {
167 if (it.next().name == 'enigma') {
168 it.remove()
169 }
170 }
171 }
172}
173
174// And finally, make the build generate / install the jars.
175assemble.dependsOn thinJar
176build.dependsOn install \ No newline at end of file