1

I am trying to add AspectJ to my existing Tycho based application, and it appears that the build doesn't see my jar libraries now — am getting a lot of "The import ... cannot be resolved" and similar compilation errors.

Each module in the project has some jar libraries that are attached to them in their build.properties files as is usual for RCP/Tycho-based apps, and it looks as these libraries are not resolved after I add AspectJ to the build for some reason.

What I did is added AspectJ to my parent project's pom.xml file as described in this question. I'm getting such build errors now:

[INFO] Showing AJC message detail for messages of types: [error, warning, fail]
[ERROR] The import org.mozilla cannot be resolved
        C:\Projects\TychoProject\com.myapp.common\src\com\myapp\common\scripting\Exec.java:7
import org.mozilla.javascript.Context;
       ^^^^^^^^^^

[ERROR] The import org.mozilla cannot be resolved
        C:\Projects\TychoProject\com.myapp.common\src\com\myapp\common\scripting\Exec.java:8
import org.mozilla.javascript.EcmaError;
       ^^^^^^^^^^
...

The rhino.jar library that contains these org.mozilla.* classes is located in a folder that is referred to in the respective module's build.properties file (lib-external/ below):

source.com.myapp.common.jar = src/
output.com.myapp.common.jar = bin/
bin.includes = META-INF/,\
               com.myap.common.jar,\
               lib/,\
               lib-external/,\
               plugin.properties
javacSource=1.7
javacTarget=1.7

This compiles well without AspectJ. How can this be fixed to work with AspectJ as well, what I might be missing?

Dmitry Pikhulya
  • 446
  • 2
  • 6
  • I don't know anything about RCP or Tycho, only a little something about AspectJ + Maven builds. But I am afraid that without an [MCVE](https://stackoverflow.com/help/mcve) - ideally on GitHub - I cannot even begin to analyse your problem with the information provided here. – kriegaex Feb 28 '20 at 02:05
  • 1
    I never tried to build an AspectJ-aware project with Tycho but following the exact same process as in a classic Maven project looks unreliable to me. First of all, is AspectJ working in your dev environment? I would first [try to make it work](https://stackoverflow.com/questions/9755001/eclipse-rcp-aspectj-configure). Since AspectJ must be configured at the platform level I think that the easiest would then be to [configure a product](https://www.vogella.com/tutorials/EclipseProductDeployment/article.html) and try to build it with Tycho. – Emmanuel Chebbi Mar 02 '20 at 09:19
  • I also found [a relevant demo](https://eclipsesource.com/blogs/2011/07/13/building-osgi-applications-that-use-aspectj-with-tycho-maven-3/) (albeit very old); did you gave it a try? – Emmanuel Chebbi Mar 02 '20 at 09:21
  • Thanks for the suggestions! I did try that demo, and got some compilation error, but didn't invest much time in investigating it, and didn't try setting up AspectJ in my IDE (I'm using IntelliJ idea). Overall I was trying to integrate AspectJ to help with performance profiling of my application and have switched to other profiling means for now. – Dmitry Pikhulya Mar 03 '20 at 20:31
  • Glad you found a workaroud. If you ever happen to build an AspectJ-aware application with Tychon, will you mind posting the answer here? I would be really interested. – Emmanuel Chebbi Mar 04 '20 at 08:33
  • Yes, I'll try to share if I return to this and find a good solution. – Dmitry Pikhulya Mar 05 '20 at 15:29
  • Apart from the Tycho setup, AspectJ also requires quite different setup in OSGi environments. You also need to configure your Manifests to make it work. If you have the Manifests right, then it's just a matter of having the AspectJ bundles in your target platform and starting everything with the right start-level and auto-start settings for certain AspectJ bundles. This page describes everything: https://www.eclipse.org/equinox/incubator/aspects/equinox-aspects-quick-start.php – kapex Mar 07 '20 at 21:00

0 Answers0