views:

1518

answers:

1

MY aspect works great from Eclipse with AspectJ plugin, however if I try to use it with Maven I get .... nothing.

I tried this http://mojo.codehaus.org/aspectj-maven-plugin/includeExclude.html

I add loggin in my aspect and I try to test it with junit test, but when I run

mvn clean
mvn test

I get...

[INFO] [aspectj:compile {execution: default}]

But i dont see logging in test

If I do compiling in Eclipse it works find, but Id like it to be IDE Independent(so I could use it with Hudson)

P.S. I use .aj file for Aspect

I tried to Google it, but I cant find any working example.

+3  A: 

Without seeing your POM it's hard to say, one thing to check is that Maven expects your aspects to be under src/main/aspect rather than src/main/java by default.

You also need to ensure the aspectj runtime library is on your classpath (in Eclipse it is included by the AJDT classpath container.

For example (from the plugin documentation):

<project>
    ...
    <dependencies>
        ...
        <dependency>
            <groupId>org.aspectj</groupId>
            <artifactId>aspectjrt</artifactId>
            <version>1.6.2</version>
        </dependency>
        ...
    </dependencies>
    ...
    <build>
        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>aspectj-maven-plugin</artifactId>
                <version>1.2</version>
                <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>
   <build>
...
</project>

If neither of these work, can you post your pom contents? It might help to identify the problem.

Rich Seller
I didnt know about src/main/aspect, it works great, thx.
martin
You're welcome.
Rich Seller