title: AspectJ: How to get pointcuts to advise classes located in other projects
body: <p>This should be simple.</p>
  
  <p><strong>Question</strong><bR>
  How do you get a pointcut in one project to advise the code/classes within another project?
  <hr>
  <strong>Context</strong><br>
  I'm working in eclipse with two projects.  For ease of explanation, let's call one <strong><em>science project</em></strong> and the other <strong><em>math project</em></strong> and say the science project relies on the math project and I'm developing in both projects, concurrently.  The math project is a core product, in production, and life will be easier if I don't modify the code much.</p>
  
  <p>Currently, I'm debugging the interaction between these two projects. To assist with that, I'm writing an Aspect (within the science project) to log key information as the math code (and science code) executes.</p>
  
  <p><hr>
  <strong>Example</strong><br>
  I running a simple example aspect along the lines of:</p>
  
  <pre><code>package org.science.example;
  
  public aspect ScientificLog {
      public pointcut testCut() : execution (public * *.*(..));
      before() : testCut() {
          //do stuff
      }
  }
  </code></pre>
  
  <p><hr>
  <strong>Problem</strong><br>
  The problem is, no matter what pointcut I create, it only advises code from the <em>science project</em>.  No classes from <code>org.math.example</code> are crosscut, AT ALL!<br><br>I tried adding the <em>math project</em> to the <em>inpath</em> of the <em>science project</em> by going to <code>proect properties &gt; AspectJ Build &gt; Inpath</code> and clicking <em>add project</em> and choosing the <em>math project</em>.  That didn't work but it seems like I need to do something along those lines.</p>
  
  <p>Thanks, in advance, for any suggestions...</p>
  
  <p>-gMale
  <hr>
  EDIT 1:<br>
  Since writing this, I've noticed the project is giving the following error:</p>
  
  <pre>Caused by: org.aspectj.weaver.BCException: Unable to continue, this version of AspectJ
  supports classes built with weaver version 6.0 but the class
  com.our.project.adapter.GenericMessagingAdapter is version 7.0
  when batch building BuildConfig[null] #Files=52 AopXmls=#0</pre>
  
  <p>So maybe this is setup properly and the error is more subtle.  BTW, the class mentioned is from the "science project," so to speak.  This happens even after I clean the project.  I'm currently googling this error...<hr>
  EDIT 2: <br>
  I found the solution to the error above in
  <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=321280#c5" rel="noreferrer">comment #5 here</a></p>
  
  <p>The problem is the maven-aspectj-plugin's pom file declares a dependency on aspectjtools version 1.6.7. So, when configuring the plugin, that transient dependency has to be modified. Here's the related code snippet for the pom file that fixes the problem by specifying version 1.6.9 instead of 1.6.7:</p>
  
  <pre><code>                    &lt;plugin&gt;
                              &lt;groupId&gt;org.codehaus.mojo&lt;/groupId&gt;
                              &lt;artifactId&gt;aspectj-maven-plugin&lt;/artifactId&gt;
                              &lt;version&gt;1.3&lt;/version&gt;
                              &lt;dependencies&gt;
                                  &lt;dependency&gt;
                                      &lt;groupId&gt;org.aspectj&lt;/groupId&gt;
                                      &lt;artifactId&gt;aspectjtools&lt;/artifactId&gt;
                                      &lt;version&gt;1.6.9&lt;/version&gt;
                                  &lt;/dependency&gt;
                              &lt;/dependencies&gt;
                              &lt;configuration&gt;
                                      &lt;source&gt;1.6&lt;/source&gt;
                                      &lt;target&gt;1.6&lt;/target&gt;
                              &lt;/configuration&gt;
                              &lt;executions&gt;
                                      &lt;execution&gt;
                                              &lt;goals&gt;
                                                      &lt;goal&gt;compile&lt;/goal&gt;
                                                      &lt;goal&gt;test-compile&lt;/goal&gt;
                                              &lt;/goals&gt;
                                      &lt;/execution&gt;
                              &lt;/executions&gt;
                      &lt;/plugin&gt;
  </code></pre>