Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
86 lines (66 sloc) 1.74 KB
apply plugin: 'java'
apply plugin: 'groovy'
apply plugin: 'idea'
repositories {
maven {
url 'http://deux.gemjars.org'
}
mavenCentral()
}
configurations {
antlr
}
idea {
module {
sourceDirs += file('src/generated/java')
sourceDirs += file('src/main/marco')
}
}
ext.antlr = [
grammarpackage: "marco.parser.antlr",
antlrSource: 'src/main/antlr',
destinationDir: "src/generated/java"
]
dependencies {
antlr 'org.antlr:antlr4:4.1'
compile 'org.antlr:antlr4-runtime:4.1'
testCompile "org.spockframework:spock-core:0.7-groovy-2.0"
testCompile group: 'junit', name: 'junit', version: '4.+'
}
task antlrOutputDir << {
mkdir(antlr.destinationDir)
}
task generateGrammarSource(dependsOn: antlrOutputDir, type: JavaExec) {
description = 'Generates Java sources from ANTLR4 grammars.'
inputs.dir file(antlr.antlrSource)
outputs.dir file(antlr.destinationDir)
def grammars = fileTree(antlr.antlrSource).include('**/*.g4')
main = 'org.antlr.v4.Tool'
classpath = configurations.antlr
def pkg = antlr.grammarpackage.replaceAll("\\.", "/")
args = ["-o", "${antlr.destinationDir}/${pkg}"/*, "-atn"*/, "-visitor", "-package", antlr.grammarpackage, grammars.files].flatten()
}
compileJava {
dependsOn generateGrammarSource
source antlr.destinationDir
}
test {
classpath += files("src/main/marco")
}
clean {
delete antlr.destinationDir
}
jar {
from configurations.runtime.asFileTree.files.collect { zipTree(it) }
from files("src/main/marco")
manifest {
attributes 'Main-Class': 'marco.main'
}
}
task testMarco(dependsOn: jar, type: JavaExec) {
description = "Runs marco tests."
classpath += files(jar.archivePath)
main = 'marco.main'
args = ['src/test/marco/core/even.mrc']
}
build.dependsOn 'testMarco'