Migrating an Eclipse AspectJ project

Hi *,

at my company, we are currently working with Eclipse for our Java projects.
As me and some other coworkers would rather use IntelliJ, we took a crack at migrating our projects and failed at getting AspectJ to work.

Here are the steps we took:

  1. import the project and dependencies into IntelliJ
  2. download and install AspectJ
  3. Under Settings -> Java Compiler: Use ajc compiler, delegate to javac (path to aspectjtools.jar is correct as the test button indicates)
  4. Add AspectJ libs to Global Libraries (aspectjrt.jar, aspectjtools.jar, aspectjweaver.jar, and org.aspectj.matcher.jar)
  5. Create AspectJ facet for the one module that is using AspectJ, leave all settings as is (no aspect path defined)
  6. Add aspectjrt to project libraries
  7. rebuild, make etc.


On make I get the following errors:
Error:(38, 0) ajc: The type LoggingDirectory must implement the inherited abstract method LogContext.isDebugEnabled()

LogContext is just an empty interface. Classes that want a logger appended implement this interface.

This method is injected with AspectJ. Unfortunately I am not an expert with this and guy who implemented it already left, so I am stuck.

In order to check general functionality, we implemented a tiny project from scratch with just three classes with the same settings as above:

public interface LogContext {
}

 
public aspect LogContextAspect {
    public void LogContext.log() {
        System.out.println("Log!");
    
}

}

 
public class Aspect implements LogContext {

    public static void main(String[] args) {
        Aspect aspect = new Aspect();
        
aspect.log();
    
}

}


The code actually executes fine and prints out the "Log!" message, but on make I get the following error:
Error:(4, 0) ajc: The type Aspect must implement the inherited abstract method LogContext.log()

What are we missing here? In order to migrate our projects, we need AspectJ to work.
The whole system is built with Java 6 compatibility but runs on Java 7.

Thanks for your help!

- Sascha

5 comments
Comment actions Permalink

Has noone else tried this before?

We are using Java 7, IDEA 14.03, and AspectJ 1.7.3

0
Comment actions Permalink

There is no automatic migration, sorry. Feel free to file a feature request.

But the setup is simple. Besides the compiler, you also need to create AspectJ facet for both kinds of modules (modules with aspects, and modules to be weaved by these aspects), and for the latter, you need to add the former in an aspect path.

0
Comment actions Permalink

Hi Roman,

thanks for your reply. I don't think such a feature is really necessary, I just didn't know that the last step was necessary.

I just added aspectjrt.jar to the aspect part of that tiny sample project that I described above and this worked.
I will try your steps with our big projects within the next days and give an update on how successful I was.

I am really grateful for your help as I already moved to IDEA for the non-AspectJ projects to get away from Eclipse :)

Thanks!

- Sascha

0
Comment actions Permalink

Oh also is there anything I need to consider seeing that the project with the aspects and the woven project are the same?

0
Comment actions Permalink

You still need to set up a facet for it, but an aspect path may be empty (a module is always in its own aspect path).

0

Please sign in to leave a comment.