Friday, June 07, 2013

Eclipse and maven-properties problem

Today, I'm going to share a problem which I think it's quite common:
- importing Java Maven projects into Eclipse and expecting Eclipse to just work with it.

You do:
1) sync from source control
2) import existing maven projects to eclipse
3) see many red errors in Eclipse.
4) yeah , I forgot to set the Maven settings file
5) still some projects are failing
6) try to fix each problem 1 by 1

Why does it happen like that?

Most common is that it will set a Java Compiler version which is from the POM.xml but then the JRE environment specified could be... just not right. So your POM.xml says "compiler version 1.7", but the Maven projects you import are automatically assigned Java1.5...
So errors like
- You cannot use @Override here
or for java1.7
- new ArrayList<> constructor not found (or not valid expression).

So you have to go to each project, reconfigure build path parameters to point to JRE1.7 manually, even though you have specified JDK1.7 as installed JDK.
Imagine fixing this manually for 20-50 projects (you've just been moved to moderately progressed project)

Even if you explicitly set the Maven settings in the Preferences menu, you would not solve your problem.

The single solution is to:
1) delete all projects ( only from Eclipse )
2) reimport them, because NOW you have set the Maven settings BEFORE the importing...

Just crazy... not being able to automatically adapt the projects to the new maven settings file... not even "clean" and "maven update" help...

Best wishes,
Leni Kirilov

No comments:

Post a Comment