I would like to be able to configure the pom.xml so that when I import it into eclipse it specifies src/main/aspect
as an eclipse source folder.
At the moment, importing creates the default source folders but that is all.
What should be done?
Thanks
edit 1
I have configured the aspectj plugin thus:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.4</version>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>test-compile</goal>
</goals>
<configuration>
<source>${project.build.source}</source>
<target>${project.build.target}</target>
<aspectDirectory>src/main/aspect</aspectDirectory>
<testAspectDirectory>src/test/aspect</testAspectDirectory>
</configuration>
</execution>
</executions>
</plugin>
edit 2
I have configured the m2e plugin thus:
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>
org.codehaus.mojo
</groupId>
<artifactId>
aspectj-maven-plugin
</artifactId>
<versionRange>
[1.4,)
</versionRange>
<goals>
<goal>test-compile</goal>
<goal>compile</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore></ignore>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
You shouldn't configure the defaults of the plugin , cause it defines already the src/test/aspect and src/main/aspect and it shouldn't be necessary to configuration something supplemental to compile etc.
Furthermore the problem with eclipse could be based on a missing mapping for your m2e plugin this means to add the following to your build:
<pluginManagement>
<plugins>
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<versionRange>[1.4,)</versionRange>
<goals>
<goal>compile</goal>
<goal>test-compile</goal>
</goals>
</pluginExecutionFilter>
<action>
<execute />
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
This might cause you problem in Eclipse not to see the source folder correctly imported.
I believe source
is supposed to be a java version, not a directory. Same for target
. sources
allows you to specify the source directories, and the docs say that if not specified, the java sources of the current project will be used - just one for your project as configured currently.
I would try listing the directories in the sources
parameter, and if that didn't work, I'd remove sources
and try build-helper:add-source . I'm not sure there's an m2e connector for build-helper-maven-plugin
yet so you might have to add a similar mapping to the one khmarbaise mentioned.
I think it would not be added as source folder by Eclipse. you could add it on your own in Java Build Path > Source
.
This is not necessary: Then you need to have AJDT plugin installed in and convert the project to AspectJ Project, otherwise the .aj
files will be full of errors complained by Eclipse. The errors does not affect maven compiling.
In my experience, recognized or not as source would not affect maven compiling the .aj
files under src/main/aspect
Both aspectDirectory and aspectTestDirectory
have default values as you given. they are not needed if the same as default.
Here below is my pom configuration (didn't try test-compile
) and it works:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.4</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<!--<Xlint>ignore</Xlint>--><!--bypass xlint warnings -->
</configuration>
<dependencies>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjtools</artifactId>
<version>1.7.2</version>
</dependency>
</dependencies>
<executions>
<execution>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.