Search code examples
eclipsemavenmaven-3m2eclipse

Eclipse auto-build output interacts with Maven command-line build output


Since both use the target directory, Eclipse's build output sometimes interferes with the output of mvn builds run at the command line.

What's the best way to separate the two outputs?


Solution

  • Insert the following into your pom.xml. Eclipse's "m2e.version" property will activate the following profile which alters the location of the Eclipse build

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