forked from decaf-lang/decaf
-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.gradle
83 lines (66 loc) · 2.32 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
plugins {
id 'java'
id 'org.xbib.gradle.plugin.jflex' version '1.2.0'
id 'org.xbib.gradle.plugin.jacc' version '1.1.3'
id 'de.undercouch.download' version "4.0.0"
}
group 'decaf'
sourceCompatibility = JavaVersion.VERSION_12
sourceSets.main.java.srcDirs += files("$project.buildDir/generated-src/ll1pg")
tasks.withType(JavaCompile).each {
it.options.compilerArgs.add('--enable-preview')
}
repositories {
mavenCentral()
}
dependencies {
// https://mvnrepository.com/artifact/commons-cli/commons-cli
compile group: 'commons-cli', name: 'commons-cli', version: '1.4'
// https://mvnrepository.com/artifact/commons-io/commons-io
compile group: 'commons-io', name: 'commons-io', version: '2.6'
// https://mvnrepository.com/artifact/org.apache.commons/commons-lang3
compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.9'
}
task ll1pg(type: Task) {
download {
src 'https://github.com/paulzfm/ll1pg/releases/download/decaf-course-19-fall/ll1pg-decaf-course-19-fall.jar'
dest "$rootDir/ll1pg.jar"
overwrite false
}
ConfigurableFileTree fs = fileTree(dir: file('src/main/ll1pg'), include: '**/*.spec')
File dstDir = file("$project.buildDir/generated-src/ll1pg")
delete(dstDir)
mkdir(dstDir)
if (fs.empty) System.err.println("No *.spec file found in 'src/main/ll1pg/', skip")
fs.visit { FileVisitDetails f ->
if (f.isDirectory) return
javaexec {
classpath = files("$rootDir/ll1pg.jar")
main = 'decaf.tools.ll1pg.Main'
args = [f.file.path, dstDir.path]
}
}
}
tasks.compileJava.dependsOn tasks.ll1pg
jar {
manifest {
attributes 'Main-Class': 'decaf.Main'
}
from {
configurations.compile.collect {
it.isDirectory() ? it : zipTree(it)
}
}
}
javadoc {
// Ignore the auto-generated file, because their javadoc comments may be out-dated (e.g. jflex <tt>).
source = sourceSets.main.allJava.filter { !it.toString().contains('generated-src') }
options.source('12')
// NOTE: the first '-' is added by Gradle and thus ignored.
// See https://github.com/gradle/gradle/issues/2354
options.addBooleanOption('-enable-preview', true)
options.showFromPrivate()
}
tasks.withType(JavaCompile) {
options.encoding = "UTF-8"
}