title: Using aspects written with AspectJ in projects which use Spring AOP
body: <p>I'm new in Gradle/AspectJ and I have a few questions regarding this.
  I develop some library which will be used in other projects. I use AspectJ to implement some cross-cutting logic and I created my aspects using @Aspect without apectj specific language.
  This lib is small framework which provides some annotations to use it.
  I created unit tests for my classes. I know that to apply aspects I need to compile classes using AspectJ compiler ("ajc"). In my ide I run tests with option: -javaagent:[path to aspectjweaver jar] and all my tests are working well as excpected. But when I run tests from gradle then some tests are failed because my aspects aren't applied. I heard about aspectj plugin in maven and tried to find something similar for gradle. I found this <a href="https://github.com/eveoh/gradle-aspectj" rel="nofollow">plugin</a> which weaves AspectJ aspects into classes and it works good, all tests are passed, but I faced with some problems. How I said I develop third-party lib which used in other projects, if some projects use Spring AOP then my aspect doesn't work. For example aspect isn't apply with next configuration:</p>
  
  <pre><code>&lt;aop:aspectj-autoproxy/&gt;
  &lt;bean id="myAspect" class="com.ext.aop.MyAspect"/&gt;
  </code></pre>
  
  <p>To make it clear my aspect wraps all methods which annotated with my specific annotation in some logic, that's all.</p>
  
  <p>In the case of Load-time weaving my aspects are working:</p>
  
  <pre><code>&lt;context:load-time-weaver aspectj-weaving="autodetect"/&gt;
  -javaagent:lib/spring-instrument.jar
  </code></pre>
  
  <p>Maybe somebody know what's the problem ? How I understand in the case of LTW the project's developers need to compile project with using some plugin again in order to wave acpects. Whether the use of LTW affect other aspects which already exist in a project? Maybe there is a way to say gradle to wave aspects only for tests and leave project's developers to be responsible for compiling aspects in an appropriate way? Or better create separate version of lib for spring framework? Maybe someone encountered such situation and have any ideas, so please give me advice. Thanks for advance.</p>