-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
72 lines (59 loc) · 1.99 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
repositories {
mavenCentral()
}
apply plugin: 'java'
apply plugin: 'antlr'
dependencies {
compile 'org.apache.commons:commons-lang3:3.4'
compile 'com.google.guava:guava:18.0'
testCompile 'junit:junit:4.12'
antlr "org.antlr:antlr4:4.5" // use ANTLR version 4
}
generateGrammarSource {
arguments += ["-visitor", "-long-messages"]
}
// By default, Antlr generates the source files in a directory that does not
// match the package. This task will move the generated source files to a
// directory matching the package.
generateGrammarSource.doLast {
File generatedDir = file('build/generated-src/antlr/main')
File packageDir = new File(generatedDir, 'scriptism/grammar')
packageDir.mkdirs()
generatedDir.listFiles().each { File file ->
file.renameTo(new File(packageDir, file.getName()))
}
}
task(run, dependsOn: 'classes', type: JavaExec) {
main = 'scriptism.Main'
classpath = sourceSets.main.runtimeClasspath
args 'scripts/some-variables.ts'
}
//create a single Jar with all dependencies
task consolidatedJar(type: Jar) {
manifest {
attributes 'Implementation-Title': 'Scriptism',
'Implementation-Version': '1.0',
'Main-Class': 'scriptism.Main'
}
baseName = project.name
from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
with jar
}
def concat(File src1, File src2, File dest) {
def input1 = src1.newDataInputStream()
def input2 = src2.newDataInputStream()
def output = dest.newDataOutputStream()
output << input1
output << input2
input1.close()
input2.close()
output.close()
}
task executableJar(dependsOn: 'consolidatedJar') {
doLast {
def executableFile = new File("build/scriptism")
concat(new File("src/main/sh/header.sh"), new File("build/libs/scriptism.jar"), executableFile)
Runtime.getRuntime().exec("chmod +x " + executableFile.getAbsolutePath()).waitFor()
}
}
defaultTasks 'executableJar'