Updated readme

This commit is contained in:
Geert Bevin 2023-04-04 09:41:14 -04:00
parent c971ebe77e
commit 2ed79de4de

View file

@ -15,16 +15,17 @@ command then uses an adapted `CompileOperation` to include the generated
sources into the main source directories. sources into the main source directories.
```java ```java
private final Antlr4Operation antlr4Operation_ = new Antlr4Operation(); private final Antlr4Operation antlr4Operation = new Antlr4Operation();
private final CompileOperation compileOperation = new CompileOperation();
@BuildCommand(summary = "Generates the grammar Java sources") @BuildCommand(summary = "Generates the grammar Java sources")
public void generateGrammar() public void generateGrammar()
throws Exception { throws Exception {
antlr4Operation_.executeOnce(o -> o antlr4Operation.executeOnce(o -> o
.sourceDirectories(List.of(new File(srcMainDirectory(), "antlr"))) .sourceDirectories(List.of(new File(srcMainDirectory(), "antlr")))
.outputDirectory(new File(buildDirectory(), "generated")) .outputDirectory(new File(buildDirectory(), "generated"))
// these options are specific to ANTLR4, please refer to the extension // these options are specific to ANTLR4, please refer to the extension
// documentation to learn more about these and other option // documentation to learn more about these and others
.visitor() .visitor()
.longMessages()); .longMessages());
} }
@ -35,10 +36,9 @@ throws Exception {
// always generate the latest grammar before compiling the sources // always generate the latest grammar before compiling the sources
generateGrammar(); generateGrammar();
// compileOperation_ is part of the main project, include the generated // include the generated grammar with the main sources
// grammar with the main sources compileOperation.executeOnce(o -> o
compileOperation_.executeOnce(o -> o
.fromProject(this) .fromProject(this)
.mainSourceDirectories(List.of(antlr4Operation_.outputDirectory()))); .mainSourceDirectories(List.of(antlr4Operation.outputDirectory())));
} }
``` ```