-
Notifications
You must be signed in to change notification settings - Fork 4
/
froid.gradle
65 lines (57 loc) · 2.79 KB
/
froid.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
project.afterEvaluate {
extensions.compileFrege = {
description = 'Compile Frege to Java'
javaexec {
android.dexOptions.setJavaMaxHeapSize("4g")
android.defaultConfig.setMultiDexEnabled(true)
def libs = project.rootDir.path + "/app/libs".replace('/' as char, File.separatorChar)
def froid = new File(libs + "/froid.jar".replace('/' as char, File.separatorChar))
if (!froid.exists()) {
new URL("https://github.com/mchav/froid/releases/download/v0.0.2/froid_0.0.2.jar")
.withInputStream{ i ->
froid.withOutputStream{ it << i }
}
}
def froid_support = new File(libs + "/froid-support.jar".replace('/' as char, File.separatorChar))
if (!froid_support.exists()) {
new URL("https://github.com/mchav/froid-support/releases/download/v0.0.1/froid-support_0.0.1.jar")
.withInputStream{ i ->
froid_support.withOutputStream{ it << i }
}
}
def frege = new File(libs + "/frege-3.24.100.1-jdk7.jar".replace('/' as char, File.separatorChar))
if (!frege.exists()) {
new URL("https://github.com/mchav/GeoQuiz-Frege/blob/master/app/libs/frege-3.24.100.1-jdk7.jar?raw=true")
.withInputStream{ i ->
frege.withOutputStream{ it << i }
}
}
def frege_src = new File(project.rootDir.path + "/app/src/main/frege".replace('/' as char, File.separatorChar))
frege_src.mkdirs()
android.sourceSets.getByName("main").java.setSrcDirs([frege_src] + android.sourceSets.getByName("main").java.getSrcDirs())
main = 'frege.compiler.Main'
def androidJarPath = android.bootClasspath[0].path
def list = [androidJarPath]
classpath += files(androidJarPath)
android.applicationVariants.each { variant ->
variant.getCompileClasspath(null).each { path ->
list << path
classpath += files(path)
}
}
def appPath = "src/main/frege/".replace('/' as char, File.separatorChar)
def a = ['-j', '-target', '1.7', '-v', '-inline', '-O', '-d', 'src/main/java', '-make',
'-fp', list.join(File.pathSeparator),
'-sp', appPath, appPath ]
project.logger.debug('Frege compiler args: "' + a.join(' ') + '"')
args (*a)
}
}
try {
compileFrege()
} catch (Exception e) {
// all error handling is shown on the gradle console.
System.err << "Frege compile failed.\n"
System.err << e.toString() + "\n"
}
}