3

I have a module in a project that has a need for post-time weaving.

I have configured my compiler to be Ajc and I have added AspectJ Facet to my module, but I am unable to enable the "Post-compile weave mode" as the checkbox is greyed out.

enter image description here

Anyone knows what am I missing there?

Ihor M.
  • 2,728
  • 3
  • 44
  • 70

1 Answers1

2

Normally I do my AspectJ stuff by setting up Maven projects which just work in Eclipse and IntelliJ IDEA. In order to help you I just tried setting up a simple Java + AspectJ project from scratch in IDEA. This is what I did (I also had to play around a bit):

  • Switch to Ajc as project compiler, set path to aspectjtools library and activate toggle for delegating to Javac for post-compile weaving and non-AspectJ projects
  • Add aspectjrt library to project, either as a path to a JAR or using Maven coordinates
  • Add aspectjrt library as dependency in all AspectJ-related modules and add AspectJ facet
  • Edit AspectJ facet, activate post-compile weaving

enter image description here

enter image description here

enter image description here

enter image description here

If you have your aspects in a separate module, please also make sure to add that module as a dependency to the Java module and also add it to the aspect path.

Please also note that if optionally you wish to use Javac for compiling the aspect module, all aspects have to be in @AspectJ syntax, not in native syntax, otherwise you cannot delegate to Javac but have to use Ajc for the aspect module too. Either way, both modules need to have an AspectJ facet.


Update after the answer was already accepted:

Some IntelliJ IDEA sources for reference:

kriegaex
  • 63,017
  • 15
  • 111
  • 202
  • Thx, it worked, even though I have figured out on my own, but your answer confirms the steps! – Ihor M. Dec 03 '20 at 19:02
  • On SO it is perfectly fine to write an answer to your own question and even accept it. You could have spared me the effort to confirm your steps after the fact. Next time you might want to do that. – kriegaex Dec 04 '20 at 01:35
  • I normally do, I came to add my answer, but you have posted it already. Thanks for your help again! – Ihor M. Dec 04 '20 at 05:24