Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] Problems with test aspects in Eclipse

I posted a question on StackOverflow, but haven't received much traction there, so I thought I would check with people on this list as well.

I'm having trouble with Eclipse weaving aspects from my test folder into my target/classes folder (as opposed to putting the woven classes into target/test-classes)

I've got a maven project in which I have @Aspect classes in my src/test/java folder.  If I build from command line, everything runs properly.  If however, I build from within Eclipse, the compiler weaves my aspects into my target class files and puts them in target/classes.

This obviously causes me troubles as the JVM tries to find the woven Aspect and throws NoClassDefFoundError (since the actual aspect.class is only in target/test-classes).

Has anyone encountered this before?  Is there a way to instruct ajc/Eclipse/maven/m2e to put the woven class file into target/test-classes and not target/classes when it is due to an aspect from the test folder?


My pom defn shows the following for the ajc plugin:
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>aspectj-maven-plugin</artifactId>
        <version>1.2</version>
        <executions>
          <execution>
            <goals>
              <goal>compile</goal>
              <goal>test-compile</goal>
            </goals>
            <configuration>
              <outxml>true</outxml>
              <aspectLibraries>
                <aspectLibrary>
                  <groupId>org.springframework</groupId>
                  <artifactId>spring-aspects</artifactId>
                </aspectLibrary>
              </aspectLibraries>
              <source>7</source>
              <target>7</target>
            </configuration>
          </execution>
        </executions>
        <dependencies>
          <dependency>
            <groupId>org.aspectj</groupId>
            <artifactId>aspectjrt</artifactId>
            <version>1.7.0</version>
            <scope>compile</scope>
          </dependency>
          <dependency>
            <groupId>org.aspectj</groupId>
            <artifactId>aspectjtools</artifactId>
            <version>1.7.0</version>
            <scope>compile</scope>
          </dependency>
        </dependencies>
        <configuration>
          <outxml>true</outxml>
          <aspectLibraries>
            <aspectLibrary>
              <groupId>org.springframework</groupId>
              <artifactId>spring-aspects</artifactId>
            </aspectLibrary>
          </aspectLibraries>
          <source>7</source>
          <target>7</target>
        </configuration>
      </plugin>


I've tried running maven 3.0.4 and 3.2.5, but no difference.

Thanks,

Eric





Back to the top