Problems using an aspectLibrary in a multi-module project

View: New views
2 Messages — Rating Filter:   Alert me  

Problems using an aspectLibrary in a multi-module project

by lvdpal :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I have a Maven multi-module project that I would like to use aspects in. This project consists of a parent module and several submodules. Including a module that contains an aspect to weave the code for my logging into my code. This is in fact all that this module contains. In the parent POM I have put the maven-aspectj-plugin in the pluginManagement tag, specifying the logging module as an aspectLibrary. Then in the submodule POMS that I want to use logging in, I have specified the use of this plugin.

However when I run the code, I only see the logging for the first project that is built after the logging module, and not the second module where I also specified the use of the logging module.

Any ideas what I might be doing wrong?

Regards,
Linda

Here's the pluginManagment code from the parent POM:
<pluginManagement>
      <plugins>
        <plugin>
          <groupId>org.codehaus.mojo</groupId>
          <artifactId>aspectj-maven-plugin</artifactId>
          <version>1.1</version>
          <configuration>
            <complianceLevel>1.6</complianceLevel>
            <aspectLibraries>
              <aspectLibrary>
                <groupId>nl.lunaris.bookdb</groupId>
                <artifactId>logging</artifactId>
              </aspectLibrary>
            </aspectLibraries>

          </configuration>
          <executions>
            <execution>
              <goals>
                <goal>compile</goal>       <!-- use this goal to weave all your main classes -->
                <goal>test-compile</goal>  <!-- use this goal to weave all your test classes -->
              </goals>
            </execution>
          </executions>
        </plugin>
      </plugins>
    </pluginManagement>

And here's how I use it in a child POM:
...
<build>
...
    <plugins>
      <plugin>
        <artifactId>aspectj-maven-plugin</artifactId>
      </plugin>
      <plugin>
        <groupId>org.mortbay.jetty</groupId>
        <artifactId>maven-jetty-plugin</artifactId>
      </plugin>
      ...
    </plugins>
</build>
<dependencies>
...
    <dependency>
      <groupId>nl.lunaris.bookdb</groupId>
      <artifactId>logging</artifactId>
      <version>${project.version}</version>
    </dependency>
</dependencies>
...

Re: Problems using an aspectLibrary in a multi-module project

by lvdpal :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I guess it was something with the maven-aspectj-plugin. When I removed the pluginManagement item and duplicated the code in the children, there was no longer any problem.

lvdpal wrote:
I have a Maven multi-module project that I would like to use aspects in. This project consists of a parent module and several submodules. Including a module that contains an aspect to weave the code for my logging into my code. This is in fact all that this module contains. In the parent POM I have put the maven-aspectj-plugin in the pluginManagement tag, specifying the logging module as an aspectLibrary. Then in the submodule POMS that I want to use logging in, I have specified the use of this plugin.

However when I run the code, I only see the logging for the first project that is built after the logging module, and not the second module where I also specified the use of the logging module.

Any ideas what I might be doing wrong?

Regards,
Linda

Here's the pluginManagment code from the parent POM:
<pluginManagement>
      <plugins>
        <plugin>
          <groupId>org.codehaus.mojo</groupId>
          <artifactId>aspectj-maven-plugin</artifactId>
          <version>1.1</version>
          <configuration>
            <complianceLevel>1.6</complianceLevel>
            <aspectLibraries>
              <aspectLibrary>
                <groupId>nl.lunaris.bookdb</groupId>
                <artifactId>logging</artifactId>
              </aspectLibrary>
            </aspectLibraries>

          </configuration>
          <executions>
            <execution>
              <goals>
                <goal>compile</goal>       <!-- use this goal to weave all your main classes -->
                <goal>test-compile</goal>  <!-- use this goal to weave all your test classes -->
              </goals>
            </execution>
          </executions>
        </plugin>
      </plugins>
    </pluginManagement>

And here's how I use it in a child POM:
...
<build>
...
    <plugins>
      <plugin>
        <artifactId>aspectj-maven-plugin</artifactId>
      </plugin>
      <plugin>
        <groupId>org.mortbay.jetty</groupId>
        <artifactId>maven-jetty-plugin</artifactId>
      </plugin>
      ...
    </plugins>
</build>
<dependencies>
...
    <dependency>
      <groupId>nl.lunaris.bookdb</groupId>
      <artifactId>logging</artifactId>
      <version>${project.version}</version>
    </dependency>
</dependencies>
...