在IntelliJ IDEA的注解处理器编译 [英] Annotation Processor compilation in IntelliJ IDEA

查看:4840
本文介绍了在IntelliJ IDEA的注解处理器编译的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是最新版本的IntelliJ IDEA(13.1.4)的,我发展我自己的自定义注释。

I'm using the latest version of IntelliJ IDEA (13.1.4) and I'm developing my own custom annotation.

目前,我有我的项目的两个模块

I currently have two modules on my project


  • MyOwnCustomAnnotationProcessor(这里我有实际的处理器)

  • MyOwnCustomAnnotationProcessorTest(这我基本上有一对夫妇类注释,看它是否是所有产生罚款)

我在Eclipse的工作,但我试图迁移OT的IntelliJ,因为我无法忍受的Eclipse。我设法还挺的Eclipse工作由具有Ant构建生成主项目的.jar文件和测试类将利用这一的.jar做出来。

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.

但我不能让它上的IntelliJ工作。

But I can't make it work on IntelliJ.

设置 - >编译器 - >注释处理器我有一个新的配置文件,测试项目是此配置文件里面,轮廓就像是:

In Settings -> Compiler -> Annotation Processor I have a new profile, the test project is inside this profile, the profile is like:

我也试图改变处理器路径来输出文件夹(如果这儿有类ñMETA-INF),但没有运气。在生成正由IDE创建的文件夹,但它没有找到任何处理器。

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.

这是怎么这里着手任何提示?

Any tip on how to proceed here?

推荐答案

我最终找到如​​何做到这一点,如果有人有兴趣:

I ended up finding how to do it, if anyone is interested:


  • 项目结构菜单中添加一个神器来的主要项目(注解处理器的项目)。这神器出口与注释处理器的.jar 文件,确保启用构建上制作这样一个新的.jar将生成你要求的一切重建项目

  • 设置 - >编译器 - >注释处理器启用标注处理,检查处理器路径,并把导出的的.jar 文件。请务必将处理器。

  • In Project Structure menu add an artifact to the main project (the annotation processor project). This artifact exports a .jar file with the annotation processor, make sure enable Build on Make that way a new .jar will be generated everything you ask to Rebuild Project
  • In Settings - > Compiler -> Annotation Processor Enable annotation processing, check Processor Path and put the path of the exported .jar file. Make sure to put the processor.

这应该是所有的。
现在,每次被点击重建项目生成一个新的jar和第二个项目将与新的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.

这篇关于在IntelliJ IDEA的注解处理器编译的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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