在同一编译过程中注释预处理和类生成的 Maven 示例?
有谁有一个 Maven 项目在编译时预处理类注释的干净示例,并在同一编译过程中编译后续生成的类?
有谁有实施此类项目的分步程序吗?
Does anyone have a clean example of a maven project preprocessing class annotations at compile time with subsequent generation of classes to be compiled in the same compilation process?
Does anyone have a step-by-step procedure to implement such a project?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在浏览了网上大量现有文档后,我得出以下结论:
需要澄清的内容:
tools.jar
添加本地依赖项才能访问这些教程中描述的 API。不干净。一些调用 apt 的第三方插件可用,但没有详细记录。使用 Maven 在 Java 6 中进行注释处理
...和代码生成
After navigating a lot in existing documentation on the net, I came up with the following:
What needs to be clarified:
tools.jar
to access the API described in these tutorials. Not clean. Some third-party plugins calling the apt are available, but not well documented.Annotation Processing in Java 6 with Maven
...and code generation
maven-processor-plugin 可以做到这一点...
https://code.google.com /p/maven-annotation-plugin/
文档中的示例:
maven-processor-plugin can do that...
https://code.google.com/p/maven-annotation-plugin/
Example from documentation:
Maven-Antlr-Plugin 正是这样做的。它根据语法生成 Java 类,然后编译插件编译生成的类。 maven-annotation-plugin 可能有用
The Maven-Antlr-Plugin exactly does this. It generates Java classes from a grammar and the compile plugin compiles the generated classes. May it might be usefull the maven-annotation-plugin