Alex Rivera | Logout

Maven project not being treated as Java in Eclipse

Asked 2012-01-17T16:11:23.640
28

I'm working on a project that has lots of different Maven projects. I've been doing a bunch of JUnit testing on these projects, and usually this goes well. I open up Eclipse, right click in package explorer->Import... Existing Maven Projects and I'm able to import the project fine. I can build, drill down to src/test/java... Right click on the file and do a Run As JUnit test. Every now and then though, I can't get this to work. If I right click to do a Run As, all I get is AspectJ/Java application. There's no JUnit tests.

I noticed that the icon next to the project folder only has an M and a folder icon, whereas with projects that do work, there's a folder, M, AND a AJ. I've also noticed that it doesn't seem to sort the files into their packages like normal Java projects. It seems like it's not treating the project as an AspectJ project. How do I get Eclipse to recognize this Maven project as a Java project?

Edit
Report

1 Answer

1

Check the pom.xml file for projects that don't get the AspectJ nature (AJ on the project). Are they missing the AspectJ-Maven plugin? They should have a section like:

<plugin>
  <groupId>org.codehaus.mojo</groupId>
  <artifactId>aspectj-maven-plugin</artifactId>
    <executions>
      <execution>
        <goals>
          <!-- use this goal to weave all your main classes -->
          <goal>compile</goal>
        </goals>
      </execution>
    </executions>
    <configuration>
      <complianceLevel>1.6</complianceLevel>
    </configuration>
</plugin>

Also take a look at his question: Maven/AJDT project in Eclipse

answered 2012-01-17T16:53:07.083

Your Answer