Search code examples
javaeclipsemavengwtm2eclipse

Does a setting in Eclipse propagate to Maven?


I've imported a Maven project into Eclipse but I'm still unsure how Maven and Eclipse really work together.

For example, Eclipse just changed my .classpath file when I copied and pasted a source folder from one Module to another in an attempt to solve Can Google App Engine Modules share source code just like Maven Modules?:

Eclipse added this to .classpath when I copied/pasted source code I want duplicated across modules/projects:

<classpathentry kind="src" path="/nbsocialmetrics-backend"/>

Eclipse didn't make any changes to my POM.xml files though. Eclipse seems happy with the .classpath change it made for me, I don't have any compilation warnings for any of the related projects/modules. But mvn clean install at the top-level of my project is complaining about a lot of missing dependencies.

Am I correct in assuming a command-line Maven command such as mvn clean install won't look at the Eclipse .classpath file?

Doesn't Maven only rely on the following?

  1. POM.xml files
  2. Repositories such as the Maven Central repository
  3. Command line arguments passed to mvn
  4. Source code/resources/etc. (the stuff you want to build, not meta data such as .classpath)

If I'm correct in understanding this, why would Eclipse allow me to make changes that aren't correct for a Maven project I've imported? What types of Eclipse changes are actually safe to make--in other words what types of changes that I make in Eclipse will actually get reflected at the time I go to execute mvn clean install at the command line?

As another example, I'm trying to use Eclipse's WindowBuilder Editor for some GWT in one of my modules (J2EE/Maven sense of 'module' not GWT sense of 'module'). As I'm looking to ensure I have the right version of WindowsBuilder to resolve Error "No GWT module found" for Maven project imported into Eclipse, should I be looking at Eclipse plugin settings or Maven POM.xml settings? Eclipse, in this case, right?

Thanks for helping me understand.


Solution

  • Am I correct in assuming a command-line Maven command such as mvn clean install won't look at the Eclipse .classpath file?

    Yes, Maven does not use this file. This file is only used by Eclipse to save information about the project, namely the source directories and their corresponding class or output directories, and the classpath entries.

    Maven relies on the resources you mentioned: the POM file, repositories, etc.

    why would Eclipse allow me to make changes that aren't correct for a Maven project I've imported?

    Even if the project is a Maven project, Eclipse still allows the user to change the build settings for the project in a way that may not follow the standard Maven conventions. For example, the default source in a module is under src/main/java, but nothing prevents you from right-clicking on the module, and adding a source folder in the build path settings that does not follow this standard (needless to say this would not be a good thing to do).

    A Maven project in Eclipse is just a project configured to use the Maven plugin which enables dependency management using Maven (it could also be a Groovy project at the same time for example).

    what types of changes that I make in Eclipse will actually get reflected at the time I go to execute mvn clean install at the command line?

    As far as Maven is concerned, all information are present in the POM. Therefore, only changes done to the POM (adding a dependency or a plugin) should affect the behavior of Maven when used from the command line.

    As I'm looking to ensure I have the right version of WindowsBuilder to resolve Error "No GWT module found" for Maven project imported into Eclipse, should I be looking at Eclipse plugin settings or Maven POM.xml settings? Eclipse, in this case, right?

    Yes it should be Eclipse not Maven. The Maven plugin has nothing to do with the WindowBuilder feature. A project can be a Maven project and at the same be configured to be a GWT project.