Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[m2e-users] m2eclipse on existing Maven project

Hello,

I have a Maven-project consisting of several modules, which can be
cleanly compiled from the command line ("mvn compile" in the project
root-directory).

I am importing this project into eclipse, using the import-facility of
m2eclipse.

After importing into Eclipse, I cannot compile the project from
Eclipse due to various errors.

1) On the pom.xml-level, I have specified the compiler version to be
1.6, but in the imported subprojects, in some I see J2SE-1.4 and in
some JavaSE-1.6 (behind "JRE System Library" in the GUI-project
tree). When looking at the effective pom.xml for one subproject, which
is shown as having compiler level J2SE-1.4, I nevertheless see [1]:

	<build>
	[...]
    <plugins>
		[...]
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>2.2</version>
        <configuration>
          <source>1.6</source>
          <target>1.6</target>
          <encoding>UTF-8</encoding>
        </configuration>
      </plugin>
      [...]
    </plugins>
  </build>

When looking at one, which is shown as having JavaSE-1.6, I see [2]:

  <build>
	[...]
    <plugins>
		[...]
     <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>2.2</version>
        <executions>
          <execution>
            <id>default-testCompile</id>
            <phase>test-compile</phase>
            <goals>
              <goal>testCompile</goal>
            </goals>
            <configuration>
              <source>1.6</source>
              <target>1.6</target>
            </configuration>
          </execution>
          <execution>
            <id>default-compile</id>
            <phase>compile</phase>
            <goals>
              <goal>compile</goal>
            </goals>
            <configuration>
              <source>1.6</source>
              <target>1.6</target>
            </configuration>
          </execution>
        </executions>
        <configuration>
          <source>1.6</source>
          <target>1.6</target>
        </configuration>
      </plugin>
      [...]
    </plugins>
  </build>

[1] comes directly from the root-pom.xml, [2]: I do not know, where
the additional <source>, <version> elements within an <execution>
element come from, there is no pom.xml in the project having
this. When enforcing [2] by explicitly putting it into the
root-pom.xml, every subproject is imported as having
"JavaSE-1.6"-dependency.

2) After taking measures to ensure JavaSE-1.6-dependency in all
subprojects, I get compile errors when choosing "Build All", because
some packages cannot be resolved etc. Without going into the details
(mostly, these are packages from our own artifactory), I fail to see
the reason for this. If the command line interface gives a clean
compile, why doesn't m2eclipse do? This is even the case, when in
"Preferences|Maven|Installations" pointing to the same Maven
distribution as the one used from the command line, pointing global
and user settings to the same files as used from the command line.

3) I can build directly via "Run as|Maven build", but still this does
not affect the highlighted errors.

My questions are:

Q1) Why does using Maven from within m2eclipse so drastically alter
Maven's behaviour?

Q2) Or maybe I did not really understand its rationale?

Q3) Are there robust ways to fix this from the user's prespective, so
that the dependencies as seen by eclipse are the same as seen by
Maven?

Thank you for explanations and hints!


Back to the top