sfinnie
sfinnie

Reputation: 9952

Set Antlr4 custom generation path relative to project root?

Using the Antlr4 intellij plugin. I want to customise the directory into which Antlr puts generated code. Right-Clicking the grammar file and selecting Configure Antlr... enables this: Output directory where all output is generated. However: it's an absolute path.

That breaks project portability, e.g. can't work on the project across linux & windows machines.

So: is there a way to enter the generation path relative to the module root?

Thanks.

Upvotes: 3

Views: 899

Answers (1)

Rakib Ahmed
Rakib Ahmed

Reputation: 31

Yes, I programmatically put the files into one of my packages using the org.antlr.v4.Tool as below:

Tool.main(new String[]{"MyGrammar.g4", "-o", "src/com/package/files/"});

Running this generates the Lexer, Parser, and the Listeners in the specified folder. My grammar file is located in the root of my project like /home/workspae/MyProject/MyGrammar.g4 and my Main() is with the above command is in a different package folder.

Upvotes: 1

Related Questions