0

I have a library created by myself with simple logging annotations and logger aspect. I have several AspectJ projects where I want to reuse this library compiled into the jar. Library is very similar to http://www.jcabi.com/ library with it's @Loggable annotation, but has some differences, main difference is that my library aspect tries to retrieve a Username if class of method marked as @Loggable implements HasUser interface (my own interface). Other differences are not so important.

I want an example of Ant script to compile both from library and project aspects. AspectJ Ant Documentation is too complex for me because I have little experience with Ant.

Partially similar questions are hear:

aspectj: How to weave aspects from a library into user code?

iajc fails to weave aspects from a jar but succeedes from class files

Community
  • 1
  • 1
Roman Lebedev
  • 903
  • 1
  • 6
  • 16

1 Answers1

0

I would recommend to use jcabi-maven-plugin, which weaves your .class files using AspectJ aspects from your current Maven module (in src/main/aspect) and from all its dependencies:

<plugin>
  <groupId>com.jcabi</groupId>
  <artifactId>jcabi-maven-plugin</artifactId>
  <version>0.7.19</version>
  <executions>
    <execution>
      <goals>
        <goal>ajc</goal>
      </goals>
    </execution>
  </executions>
</plugin>
yegor256
  • 102,010
  • 123
  • 446
  • 597