| 11 | import org.gradle.api.tasks.TaskAction; |
| 12 | |
| 13 | public abstract class GenerateParserTask extends DefaultTask { |
| 14 | @InputFile |
| 15 | public abstract RegularFileProperty getGrammarFile(); |
| 16 | |
| 17 | @OutputDirectory |
| 18 | public abstract DirectoryProperty getOutputDir(); |
| 19 | |
| 20 | @TaskAction |
| 21 | public void run() { |
| 22 | getProject().delete(getOutputDir()); |
| 23 | |
| 24 | int returnValue; |
| 25 | try { |
| 26 | returnValue = Main.mainProgram( |
| 27 | getGrammarFile().get().getAsFile().toPath(), |
| 28 | getOutputDir().get().getAsFile().toPath(), |
| 29 | "java", |
| 30 | 8, |
| 31 | true, |
| 32 | Collections.emptyMap() |
| 33 | ); |
| 34 | } catch (Exception e) { |
| 35 | throw new RuntimeException(e); |
| 36 | } |
| 37 | |
| 38 | if (returnValue != 0) { |
| 39 | throw new RuntimeException("JavaCC returned a non-zero exit code."); |
| 40 | } |
| 41 | } |
| 42 | } |
nothing calls this directly
no outgoing calls
no test coverage detected