Skip to main content

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

See my comments inline

--
Regards,
Igor

On 10-12-26 09:30 AM, Kay Ulbrich wrote:
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.


In order to determine project configuration, m2e 0.12.0 and earlier run
partial maven build. If that build fails for whatever reason, m2e falls
back to some defaults, and use of java 1.4 is one of them. Check Maven
console view and .log to see if there is anything interesting there.

m2e 0.14.0 will use different method to determine project configuration
and should be more reliable and predicable.


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.

I need more details to understand what is going on. Dependency
resolution works reliably for vast majority of users in 0.12.0 as far as
I know. Is there anything interesting in .log file? Can you provide
sample project and steps to reproduce the problem?


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?

You understood it correctly. m2e is expected to either import projects
or fail a clear message. There are known problems in 0.12.0 and we are
making major changes in m2e 0.14.0 to make it work more predictable.


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?


I need to understand exact problem(s) to answer this question.

--
Regards,
Igor


Back to the top