Last active
August 29, 2015 14:13
-
-
Save rgoulter/b04abfeb8c52b9e31377 to your computer and use it in GitHub Desktop.
Gradle for an Antlr4, Scala project. Can generate Eclipse files, too.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apply plugin: 'java' | |
apply plugin: 'scala' | |
apply plugin: 'eclipse' | |
apply plugin: 'application' | |
apply plugin: 'me.champeau.gradle.antlr4' | |
buildscript { | |
repositories { | |
maven { | |
name 'JFrog OSS snapshot repo' | |
url 'https://oss.jfrog.org/oss-snapshot-local/' | |
} | |
jcenter() | |
} | |
dependencies { | |
classpath 'me.champeau.gradle:antlr4-gradle-plugin:0.1' | |
} | |
} | |
repositories { | |
jcenter() | |
} | |
dependencies { | |
compile 'org.scala-lang:scala-library:2.11.1' | |
// Runtime only needs antlr4-runtime, not the whole antlr4. | |
compile 'org.antlr:antlr4-runtime:4.5' | |
// Customise antlr4 version, for buildscript | |
antlr4 'org.antlr:antlr4:4.5' | |
} | |
// Have Gradle/Antlr4 use the same output folder as Maven | |
// so that it plays nicely with Eclipse. | |
antlr4.output = new File("target/generated-sources/antlr4") | |
// make the Java compile task depend on the antlr4 task | |
compileJava.dependsOn antlr4 | |
// add the generated source files to the list of java sources | |
sourceSets.main.java.srcDirs += antlr4.output |
Antlr4 generated src went to build/generated-src
.
Generated classes to bin
.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
While I'm sure this isn't idiomatic Gradle, I don't know what would be. I know that this works well enough for my purposes.
It can generate Eclipse project files. A
gradle antlr4
is needed, though, after agradle clean
.