Chris Beach
Chris Beach

Reputation: 4392

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?

Upvotes: 10

Views: 2996

Answers (3)

Chris Beach
Chris Beach

Reputation: 4392

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>

Upvotes: 12

colin
colin

Reputation: 149

If you use maven-eclipse-plugin instead of M2Eclipse, here's the definition you want in order to change the Eclipse output directory:

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

Upvotes: 0

Michał Kalinowski
Michał Kalinowski

Reputation: 17933

Official way is presented here:
http://wiki.eclipse.org/M2E_FAQ#How_to_configure_Maven_project_to_use_separate_output_folders_in_Eclipse

I personally don't do something like this. Usually I basically disable auto-build in Eclipse since most builds I do from the console anyway. But if you really want it, here you are.

Upvotes: 1

Related Questions