Antlr4 maven插件在不同目录下找不到语法文件 [英] Antlr4 maven plugin cannot find grammar files in different directories

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

问题描述

我正在使用 antlr4 maven 插件来构建我使用 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>

我从一个语法文件开始,然后设置了 pom.xml,一切都构建得很好.

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

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

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.

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

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

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

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

[ERROR] Message{errorType=CANNOT_FIND_IMPORTED_GRAMMAR

为什么 antlr 找不到我正在导入的其他文件?

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

谢谢,瑞安.

推荐答案

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

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

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

看这里:如何在 Antlr4 中导入语法以使用 maven 构建

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

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