Eclipse自动构建输出与Maven命令行构建输出交互

时间:2012-04-18 11:22:53

标签: eclipse maven maven-3 m2eclipse

由于两者都使用目标目录,因此Eclipse的构建输出有时会干扰在命令行运行的mvn构建的输出。

将两个输出分开的最佳方法是什么?

3 个答案:

答案 0 :(得分:10)

将以下内容插入pom.xml。 Eclipse的“m2e.version”属性将激活以下配置文件,该配置文件会改变Eclipse构建的位置

<profiles>
  <profile>
    <id>IDE</id>
    <activation>
      <property>
        <name>m2e.version</name>
      </property>
    </activation>
    <build>
      <!-- Put the IDE's build output in a folder other than target, so that IDE builds don't interact with Maven builds -->
      <directory>target-ide</directory>
    </build>
  </profile>
</profiles>

答案 1 :(得分:1)

这里介绍官方方式:
http://wiki.eclipse.org/M2E_FAQ#How_to_configure_Maven_project_to_use_separate_output_folders_in_Eclipse

我个人不会这样做。通常我基本上禁用Eclipse中的自动构建,因为无论如何我从控制台做的大多数构建。但如果你真的想要它,那么你就是。

答案 2 :(得分:0)

如果您使用maven-eclipse-plugin而不是M2Eclipse,这里是您想要更改Eclipse输出目录的定义:

<plugin>
  <artifactId>maven-eclipse-plugin</artifactId>
  <version>2.9</version>
  <configuration>
    <buildOutputDirectory>target-eclipse/classes</buildOutputDirectory>
    <downloadSources>true</downloadSources>
    <downloadJavadocs>true</downloadJavadocs>
  </configuration>
</plugin>
相关问题