Antlr4 Maven插件无法在其他目录中找到语法文件 [英] Antlr4 maven plugin cannot find grammar files in different directories

查看:335
本文介绍了Antlr4 Maven插件无法在其他目录中找到语法文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用antlr4 maven插件来构建使用antlr4的maven项目:

     <groupId>org.antlr</groupId>
     <artifactId>antlr4-maven-plugin</artifactId>
     <version>4.0</version>

我从一个语法文件开始,并设置了pom.xml,一切都很好.

然后,我决定将语法拆分为逻辑部分,因此使用了几个语法文件,但它们位于不同的目录中(因此生成的代码将放入单独的包中),但仍全部位于同一根src/main/antlr4目录下. /p>

我在顶级"语法文件中使用import语句来导入其他所需文件.

但是现在maven在尝试构建时给了我以下错误:

[ERROR] Message{errorType=CANNOT_FIND_IMPORTED_GRAMMAR

为什么无法找到我要导入的其他文件?

谢谢, 瑞安.

解决方案

我遇到了同样的问题,并通过以下配置解决了该问题:

<libDirectory>${basedir}/src/main/antlr4/yourGrammarDirectory</libDirectory>

查看此处:如何在Antlr4中导入语法以使用Maven进行构建

I'm using the antlr4 maven plug-in to build my maven project which uses antlr4:

     <groupId>org.antlr</groupId>
     <artifactId>antlr4-maven-plugin</artifactId>
     <version>4.0</version>

I started with one grammar file and got my pom.xml set-up and everything was building nicely.

Then I decided to split my grammar into logical parts and therefore used several grammar files but in different directories (so the generated code would be put into separate packages) but still all under the same root src/main/antlr4 directory.

I use the import statement in my "top" level grammar file to import the other required files.

But now maven gives me the following error when trying to build:

[ERROR] Message{errorType=CANNOT_FIND_IMPORTED_GRAMMAR

Why can't antlr find the other files that I am importing?

thanks, Ryan.

解决方案

I had the same problem and solved with the following configuration:

<libDirectory>${basedir}/src/main/antlr4/yourGrammarDirectory</libDirectory>

Look here: How to import grammar in Antlr4 to build with maven

这篇关于Antlr4 Maven插件无法在其他目录中找到语法文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆