后期处理 Antlr Maven 目标
我正在使用 Maven 运行 Antlr。 Antlr 从 .g 文件生成 .java 文件,我需要后期处理生成的 java 文件(对其进行一些更改)。我该怎么做呢?
<plugin>
<groupId>org.antlr</groupId>
<artifactId>antlr3-maven-plugin</artifactId>
<version>3.5.2</version>
<configuration>
<outputDirectory>src/main/java</outputDirectory>
</configuration>
<executions>
<execution>
<goals>
<goal>antlr</goal>
</goals>
</execution>
</executions>
</plugin>
I'm running antlr with maven. Antlr generates .java file from .g file and I need to post process generated java file (do some changes in it). How can I do it?
<plugin>
<groupId>org.antlr</groupId>
<artifactId>antlr3-maven-plugin</artifactId>
<version>3.5.2</version>
<configuration>
<outputDirectory>src/main/java</outputDirectory>
</configuration>
<executions>
<execution>
<goals>
<goal>antlr</goal>
</goals>
</execution>
</executions>
</plugin>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
最后,我找到了解决方案。您必须使用Maven-Antrun-Plugin,它可以执行Java代码。
另一个问题是,在流程源阶段还没有编译类(您需要在编译之前运行)。因此,在执行Java类之前,您需要像我一样对其进行编译或做 - 存储已经编译的类并将其复制到目标类。
Finally I've found a solution. You have to use maven-antrun-plugin, it can execute java code.
Another problem was that there were no compiled classes yet in the process-sources phase (you need to run it before compile). So before executing the java class, you need to compile it or do as I did - store the already compiled class and copy it to target classes.