java IntelliJ IDEA 中的注解处理器编译
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/25501926/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Annotation Processor compilation in IntelliJ IDEA
提问by Budius
I'm using the latest version of IntelliJ IDEA (13.1.4) and I'm developing my own custom annotation.
我正在使用最新版本的 IntelliJ IDEA (13.1.4) 并且我正在开发我自己的自定义注释。
I currently have two modules on my project
我的项目目前有两个模块
- MyOwnCustomAnnotationProcessor (here I have the actual processor)
- MyOwnCustomAnnotationProcessorTest (this I basically have a couple classes annotated to see if it's all generating fine)
- MyOwnCustomAnnotationProcessor(这里我有实际的处理器)
- MyOwnCustomAnnotationProcessorTest(这个我基本上有几个类注释,看看它是否都生成正常)
I was working in Eclipse but I'm trying to migrate ot IntelliJ because I can't stand Eclipse. I managed to make it kinda-of work in Eclipse by having an Ant build generating the .jar file of the main project and the Test classes would use this .jar.
我在 Eclipse 中工作,但我正在尝试迁移 ot IntelliJ,因为我无法忍受 Eclipse。通过让 Ant 构建生成主项目的 .jar 文件和测试类将使用此 .jar,我设法在 Eclipse 中完成了一些工作。
But I can't make it work on IntelliJ.
但我不能让它在 IntelliJ 上工作。
In Settings -> Compiler -> Annotation Processor
I have a new profile, the test project is inside this profile, the profile is like:
在Settings -> Compiler -> Annotation Processor
我有一个新的配置文件中,测试项目在此配置文件中,配置文件如下:
I've also tried changing the Processor Path
to the output folder (where there're classes n META-INF) but no luck. The generated
folder is being created by the IDE, but it's not finding any processors.
我也尝试将 更改Processor Path
为输出文件夹(其中有类 n META-INF)但没有运气。该generated
文件夹正在由 IDE 创建,但未找到任何处理器。
Any tip on how to proceed here?
关于如何在此处进行的任何提示?
回答by Budius
I ended up finding how to do it, if anyone is interested:
如果有人感兴趣,我最终找到了如何去做:
- In
Project Structure
menu add anartifact
to the main project (the annotation processor project). This artifact exports a.jar
file with the annotation processor. Make sure to enableBuild on Make
, that way a new .jar will be generated every time you ask toRebuild Project
- In
Settings - > Compiler -> Annotation Processor
Enable annotation processing, checkProcessor Path
and put the path of the exported.jar
file. Make sure to put the processor.
- 在
Project Structure
菜单中添加一个artifact
到主项目(注释处理器项目)。此工件导出.jar
带有注释处理器的文件。确保启用Build on Make
,这样每次请求时都会生成一个新的 .jarRebuild Project
- 在
Settings - > Compiler -> Annotation Processor
Enable annotation processing 中,勾选Processor Path
并放置导出.jar
文件的路径。确保放置处理器。
and that should be all.
Now everytime rebuilt project
is clicked a new jar is generated and the second project will be re-generated with that new jar.
这应该是全部。现在每次rebuilt project
点击都会生成一个新 jar,第二个项目将使用该新 jar 重新生成。