Mix AspectJ and Scala in an Eclipse Project

Has anyone been able to get Scala and AspectJ (AJDT) to play beautifully together in Eclipse 3.6?

Scala seems to conflict with the AspectJ crawler. I hope that I just missed something.

Edit: play well in one project

+5
source share
4 answers

Based on your comment above, it looks like you want one project to use both the AspectJ linker and the Scala constructor. It's impossible. Each of them passes its own compiler, and the two compilers are not compatible (yet). The Scala compiler can compose Java and Scala code, and the AspectJ compiler can co-create AspectJ and Java code, but that is.

If you want aspects to apply to your Scala code, you must separate your AspectJ and Scala code into different projects, and then add the Scala project to the inpath of your AspectJ project.

This is the same thing you will need to do if you are compiling from ant or on the command line.

+3
source

The currently recommended version is still Eclipse3.5.2 .

Tickets such as 1000075 or 3251 saying:

If you are desperate, try the nightly build update experimental site at http://download.scala-ide.org/nightly-update-wip-helios-2.8.0.final .

Today, at night you can try with Helios 3.6:

http://download.scala-ide.org/nightly-update-master-2.8.1.final

+2
source

I struggled with this for some time. Here is my solution:

First separate your Scala and your AspectJ code into different projects.

Then add the Ant constructor to your Scala project. It starts whenever the Scala builder executes and weaves. It uses ant4eclipse to extract the classpath, but you need to specify the location of the Scala library.

build.xml

<project name="simple-example" default="compile" xmlns:ant4eclipse="antlib:org.ant4eclipse" xmlns:antcontrib="antlib:net.sf.antcontrib"> <ant4eclipse:jdtClassPathLibrary name="org.scala-ide.sdt.launching.SCALA_CONTAINER"> <fileset file="../lib/scala-library.jar"/> </ant4eclipse:jdtClassPathLibrary > <ant4eclipse:getJdtClassPath workspacedirectory=".." projectName="lpfExample" property="classpath"/> <target name="compile"> <iajc sourceroots="src" destdir="bin"> <inpath> <pathelement location="bin" /> </inpath> <aspectpath> <pathelement location="../aspects/bin"/> </aspectpath> <classpath path="${classpath}"/> </iajc> </target> </project> 
0
source

Do you mean the presence of both Scala and AJDT plug-in? This is certainly doable - for example, to develop the Scala module itself.

I do the following:

  • Install AspectJ dev developer tools + eclipse eclipse function
  • Install the Scala IDE, but omit the JDT Weaving for Scala
-one
source

All Articles