Intellij and maven harmonization

179 views
Skip to first unread message

Kristoffer Sjögren

unread,
Apr 21, 2014, 5:57:44 AM4/21/14
to antlr-di...@googlegroups.com
Hi

I have a ANTLR4 project where I try to align output directory for generated sources from antlr4-maven-plugin and antlr4 intellij plugin.

By default the antlr4 plugin generate sources to the "gen" directory of the Maven project root. This is not optimald since intellij will complain about duplicate source files after the Maven build have generated sources to target/generated-sources/antlr4.

Another issue is that antlr4 plugin does not recognize directory structure, output sources to the root, unless @header package statement is put in the grammar? This conflicts with antlr4-maven-plugin since it DOES recognize directory structure.

My idea is to configure the intellij plugin to output sources to same directory as Maven, target/generated-sources/antlr4. But I havent found a way to configure the plugin, i.e. the -o option?

Cheers,
-Kristoffer

Sam Harwell

unread,
Apr 21, 2014, 8:00:19 AM4/21/14
to antlr-di...@googlegroups.com
Hi Kristoffer,

If you are using the antlr4-maven-plugin (or one of the Ant build tasks that generates parser code during the build), you should not need to use the "generate code" feature of any of the IDE plugins. The build plugins are much more consistent and reliable than any IDE plugin.

By disabling the code generation in the IntelliJ plugin and removing the package clause from your @header block in the grammar, everything should work perfectly.

Sam

Kristoffer Sjögren

unread,
Apr 21, 2014, 1:01:44 PM4/21/14
to antlr-di...@googlegroups.com
Sure, I can live with that. After all, the Maven build is what generates the final application.

But Maven builds are slow so the turnaround loop will be longer. The IDE plugin generate sources almost instantly after saving the grammar file. This is important for me to be productive during development.

Is there no way to force the output directory of the IDE plugin?

Terence Parr

unread,
Apr 21, 2014, 1:03:53 PM4/21/14
to antlr-di...@googlegroups.com
On Apr 21, 2014, at 10:01 AM, Kristoffer Sjögren <sto...@gmail.com> wrote:

Sure, I can live with that. After all, the Maven build is what generates the final application.

But Maven builds are slow so the turnaround loop will be longer. The IDE plugin generate sources almost instantly after saving the grammar file. This is important for me to be productive during development.

Is there no way to force the output directory of the IDE plugin?’

Sure. Configuration dialog. right-click within a grammar file and it will give you an option to do that. Then just set the output directory. 1.1 plug-in looks for the package in an action but 1.2, which will come out today I hope ignores that in favor of the package specification in the dialog box. Unfortunately 1.1 did not pay attention to that package field; a bug. 1.2 fixes that.

Ter


On Monday, April 21, 2014 2:00:19 PM UTC+2, Sam Harwell wrote:
Hi Kristoffer,

If you are using the antlr4-maven-plugin (or one of the Ant build tasks that generates parser code during the build), you should not need to use the "generate code" feature of any of the IDE plugins. The build plugins are much more consistent and reliable than any IDE plugin.

By disabling the code generation in the IntelliJ plugin and removing the package clause from your @header block in the grammar, everything should work perfectly.

Sam

On Monday, April 21, 2014 4:57:44 AM UTC-5, Kristoffer Sjögren wrote:
Hi

I have a ANTLR4 project where I try to align output directory for generated sources from antlr4-maven-plugin and antlr4 intellij plugin.

By default the antlr4 plugin generate sources to the "gen" directory of the Maven project root. This is not optimald since intellij will complain about duplicate source files after the Maven build have generated sources to target/generated-sources/antlr4.

Another issue is that antlr4 plugin does not recognize directory structure, output sources to the root, unless @header package statement is put in the grammar? This conflicts with antlr4-maven-plugin since it DOES recognize directory structure.

My idea is to configure the intellij plugin to output sources to same directory as Maven, target/generated-sources/antlr4. But I havent found a way to configure the plugin, i.e. the -o option?

Cheers,
-Kristoffer

--
You received this message because you are subscribed to the Google Groups "antlr-discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to antlr-discussi...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Kristoffer Sjögren

unread,
Apr 22, 2014, 8:39:47 AM4/22/14
to antlr-di...@googlegroups.com
Found it! Though changing configuration doesn't have any effect? Bug?

Terence Parr

unread,
Apr 22, 2014, 10:19:28 AM4/22/14
to antlr-di...@googlegroups.com
as i say it has a bug at moment. hoping to get 1.2 out today.
T
Reply all
Reply to author
Forward
0 new messages