AspectJ - Compile Java source with precompiled asp

2019-06-07 23:59发布

Let's say I have few aspects, which I have already compiled, and now I just want to compile single source file, but without recompiling the aspects, since it takes a lot of time. Is there any way to do so?

For example, I have the following:

  • Trace.aj
  • Log.aj
  • Test.java

All of them were compiled during my "build-all", and now I've changed Test.java and wants to recompile it using the (already compiled) aspects.

标签: java aspectj
2条回答
放荡不羁爱自由
3楼-- · 2019-06-08 00:53

I'm not sure load time weaving is the right approach in this case. You typically use load time weaving when you want to modify the behaviour of classes that have already been compiled. In this case you are compiling the Test type. If the aspects are relatively stable, you can separate them into another project and build that into a jar (say trace.jar), you can then modify the AJDT configuration to add the jar to the aspect libraries (from memory, so apologies if it's not accurate, go to the project properties, select the aspectj compiler option, select the aspect libraries/path tab and add your aspect jar). Doing this means that the aspects in the jar will be applied to Test.java on each build.

查看更多
登录 后发表回答