Skip to main content



      Home
Home » Language IDEs » AspectJ » AJ Builder for existing class files? (to weave non-Java sources)
AJ Builder for existing class files? (to weave non-Java sources) [message #778687] Fri, 13 January 2012 11:32 Go to next message
Eclipse UserFriend
Hi,

I've been using AJDT for a long time for Java projects, and the way I understand its Eclipse project builder is that it handles the compilation of the Java sources as well as the weaving. More recently I've got into using Scala, and on the command line I can quite easily compile Scala in .class files and then run ajc on the compiled classes to weave annotation based @Aspect and @Pointcut classes in the Scala project. There doesn't seem to be any equivalent ability in AJDT however. The AJDT project builder on its own obviously won't compile Scala, and trying to have it in a project alongside the Scala builder doesn't work as the two builders fight over who is doing the compiling.

Does anybody know if it would be feasible to have an alternate builder able to run after another builder, weaving class files? Then any project that generated .class files, Java or not, would be able to benefit from AspectJ weaving.

As it works from the command line I'm quietly hopeful that it's theoretically possible to add to ADJT.
Re: AJ Builder for existing class files? (to weave non-Java sources) [message #778791 is a reply to message #778687] Fri, 13 January 2012 15:57 Go to previous messageGo to next message
Eclipse UserFriend
The best that you can do is separate your Scala code from your Aspect code. The AspectJ builder in Eclipse expects that it controls all source files in the project (and I assume the same goes for the scala builder, but I am not really familiar with it). This means that if you have some Aspect code that references scala code, compilation will fail.
Re: AJ Builder for existing class files? (to weave non-Java sources) [message #779013 is a reply to message #778791] Sat, 14 January 2012 06:55 Go to previous messageGo to next message
Eclipse UserFriend
Hi Andrew. Yes, the Scala builder also expects to control all the source files. So if I put my aspects and pointcuts in a separate AspectJ project in .java or .aj files then I can compile these. But as I understand it I still won't be able to weave any advice into the Scala code using the plugin? The same applies where I am using a jar of 3rd party aspects, such as those that come with the Spring framework.

I would be interested in looking into the AJDT plugin and trying to implement something myself, if you think such a thing might be possible with the project builder API? I would imagine that incremental compilation might be an issue.
Re: AJ Builder for existing class files? (to weave non-Java sources) [message #779164 is a reply to message #779013] Sat, 14 January 2012 17:50 Go to previous messageGo to next message
Eclipse UserFriend
When you have your Scala and AJ files in separaete projects, it is possible to weave your scala project.

Add your scala project to the inpath of the aspect project. This will add the class files of your scala project to the weaver of the aspect project. Your scala files will be woven and the class files will be added to the default out directory of your aspect project. You can specify an inpath out folder if you want to choose a different location.

As for implementing a joint builder...this might be possible, but it would require some deep knowledge of how the scala compiler works, how the aspectj compiler works, AND deep knowledge of Eclipse APIs. It would be a very large undertaking. I would recommend keeping things simple for now and splitting projects as I say above.
Re: AJ Builder for existing class files? (to weave non-Java sources) [message #779677 is a reply to message #779164] Mon, 16 January 2012 05:04 Go to previous message
Eclipse UserFriend
Thanks Andrew. I'll try splitting up the project. Making a new builder was definitely a bit ambitious! It seemed appealing because of the possibility of making one that would work against any other language builder that generated JVM classfiles, not just Scala.
Previous Topic:headless AJDT: one aspect, many projects
Next Topic:AJDT compiler results in errors
Goto Forum:
  


Current Time: Tue May 20 19:14:31 EDT 2025

Powered by FUDForum. Page generated in 0.03686 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top