[英]adding src/main/aspect as a source folder to an eclipse maven project
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. 我希望能够配置pom.xml,以便在将其导入eclipse时将src/main/aspect
指定为eclipse源文件夹。
At the moment, importing creates the default source folders but that is all. 目前,导入会创建默认的源文件夹,仅此而已。
What should be done? 应该做什么?
Thanks 谢谢
edit 1 编辑1
I have configured the aspectj plugin thus: 我因此配置了aspectj插件:
<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 编辑2
I have configured the m2e plugin thus: 我因此配置了m2e插件:
<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. 您不应该配置插件的默认值 ,因为它已经定义了src / test / aspect和src / main / aspect,并且没有必要配置一些补充编译等内容。
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: 此外,eclipse的问题可能是由于您的m2e插件缺少映射而引起的,这意味着要在构建中添加以下内容:
<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. 这可能会导致您在Eclipse中看不到正确导入源文件夹的问题。
I believe source
is supposed to be a java version, not a directory. 我相信source
应该是Java版本,而不是目录。 Same for target
. 与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. sources
允许您指定源目录,文档说如果未指定,则将使用当前项目的java源-仅用于当前配置的项目。
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 . 我会尝试在sources
参数中列出目录,如果那行不通,我将删除sources
并尝试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. 我不确定是否有用于build-helper-maven-plugin
的m2e连接器,因此您可能必须为上述khmarbaise添加类似的映射。
I think it would not be added as source folder by Eclipse. 我认为它不会被Eclipse添加为源文件夹。 you could add it on your own in Java Build Path > Source
. 您可以在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. 这不是必需的:然后,您需要安装AJDT插件并将项目转换为AspectJ Project,否则.aj
文件将充满Eclipse抱怨的错误。 The errors does not affect maven compiling. 该错误不影响Maven编译。
In my experience, recognized or not as source would not affect maven compiling the .aj
files under src/main/aspect
以我的经验,识别或不识别为源不会影响Maven在src/main/aspect
下编译.aj
文件
Both aspectDirectory and aspectTestDirectory
have default values as you given. AspectDirectory和aspectTestDirectory
都具有您指定的默认值。 they are not needed if the same as default. 如果与默认值相同,则不需要它们。
Here below is my pom configuration (didn't try test-compile
) and it works: 下面是我的pom配置(没有尝试test-compile
),它可以工作:
<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>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.