Wednesday, March 24, 2010

Eclipse is building my maven release!

Who will find this article useful?
If you want to develop with eclipse and use the maven-release-plugin, and not have to have a special working copy for doing release:prepare

Hold on I can't clean
You will find that if you use eclipse and maven and share output directories, doing a clean from the command line will trigger eclipse to rebuild the project.

Whos is really compiling those classes
It looks innocent initially but consider that eclipse is using a different compiler and classpath. Eclipse does not understand scopes for classpaths so you end up with compiler errors not being seen - i.e. class leaks from test scope for example - until someone else tries you build the project later.

How to configure it the right way using the maven-eclipse-plugin and m2elipse
You should alway configure eclipse and maven to use different output directories. See an example pom that shows how to configure the maven-eclipse-plugin to allow you to generate eclipse project files.

With that configuration you should run mvn eclipse:clean eclipse:m2eclipse



How to configure it the right way using eclipse without the m2eclipse plugin
Configure the output path to be target-eclipse/classes

How to configure when using IAM
I imagine the process would be similar to the m2eclipse plugin but I've never tried, sorry.

The release plugin is your friend
When using the maven release plugin - which you should do if you are thinking of using maven at all - makes this all the more important as the standard release process involves, clean, build, tag. If that build is done by eclipse you don't have the two factor validation i.e. command line and IDE to show you build is coherent.

Get rid of the extra working copy
A common solution is to release from a separate working directory than the one you use to develop. Its just an extra overhead you just don't need.

Hope this is useful for people out there, anything to encourage people to use the release plugin.