English 中文(简体)
将 src/ main/ aspect 添加为日食maven 工程的源文件夹
原标题:adding src/main/aspect as a source folder to an eclipse maven project

我希望能够配置 pom. xml, 这样当我将它导入日蚀时, 它会指定 < code> src/ main/ aspect 作为日蚀源文件夹 。

目前, 导入创建默认源文件夹, 但仅此而已 。

应采取什么行动?

谢谢 谢谢

<强度 > 编辑 1

因此,我配置了侧面j 插件 :

<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>

<强 > 编辑 2

因此我配置了 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>
问题回答

您不应该配置 < a href= > 。 http:// mojo.codehaus. org/ aspectj- maven- plugin/compile- mojo. html" rel= “ no follow” > 插件 < / a> 的默认值, 因为它已经定义了 src/ test/ aspect 和 src/ main/ aspect, 并且没有必要配置一些补充内容来编译等等 。

此外,日食问题可能基于一个缺失的're rel=“nofollow”>映射您的 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>

这可能导致您在 Eclipse 中找不到源文件夹正确导入的问题 。

我认为它不会被 Eclipse 添加为源文件夹。 您可以在 Java 构建路径 & gt; 源代码 中自行添加 。

这没有必要: 那么您需要在工程中安装 < a href=" http://www. eclipse. org/ajdt/% E2%80% 8E" rel=“ nofollow” > AJDT 插件 并将其转换为 AspectJ 项目, 否则 < code>.aj 文件将会充满由 Eclipse 抱怨的错误。 这些错误不会影响 Maven 编译 。

在我的经验中,无论是否被确认为源代码都不会影响在 .aj 下汇编 文件的 Maven, /main/aspect

http://mojo.codehaus.org/aspectj-maven-plugin/compile-mojo.html#aspect contituty" rel=“no follow” >aspect contituty 和aspect Testitry 都有默认值。如果默认值相同,则不需要默认值。

以下是我的组合配置( 尝试 < code> 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>




相关问题
In Eclipse, why doesn t "Show In" appear for non-Java files?

If I have a *java file open, I can right click on the source, scroll down to "Show In (Alt-Shift-W)", and select Navigator. If I have an *xml, *jsp, or pretty much anything besides a Java source ...

Eclipse: Hover broken in debug perspective

Since upgrading Eclipse (Galileo build 20090920-1017), hover in debug no longer displays a variable s value. Instead, hover behaves as if I were in normal Java perspective: alt text http://...

Eclipse smart quotes - like in Textmate

Happy Friday — Does anyone know if eclipse has the notion of smart quotes like Textmate. The way it works is to select some words and quote them by simply hitting the " key? I m a newbie here so be ...

Indentation guide for the eclipse editor

Is there a setting or plugin for eclipse that can show indentation guides in the editor? Something like the Codekana plugin for visual studio (not so fancy is also OK). Important that it works with ...

Adding jar from Eclipse plugin runtime tab

I want to add .jar files for plugin from the Runtime tab of manifest file. When I use the Add... button, I can see only sub-directories of the plugin project. So if I want to add same .jar file to ...

How to copy multiple projects into single folder in eclipse

I have two projects, Project1 and Project2. Now i want to copy this projects into eclipse workspace but i want these projects to be in a single folder like below. Eclipse Workspace -> Project -> ...

Java: Finding out what is using all the memory

I have a java application that runs out of memory, but I have no idea which code is allocating the memory. Is there an application with which I can check this? I use Eclipse.