Thursday, February 25, 2010

m2eclipse plugin makes M2_REPO variable non modifiable in Eclipse

Yesterday for first time I installed m2eclipse plugin and all of a sudden projects failed to compile. I was using Maven for quite long time hence adding all library dependencies for a project using a variable named M2_REPO, which was pointing towards a location where Maven downloaded jars were stored. After installation of m2eclipse plugin Eclipse was not able to resolve the absolute path of the jars in classpath.

The value of the M2_REPO variable was changed itself to some path other than what I configured. When I tried to fix that, to my surprise I can't edit it any longer. It was marked with this text "M2_REPO (non modifiable)". After poking here and there for a while I come to know that m2eclipse picks the value of M2_REPO variable from $MAVEN_HOME/conf/settings.xml (MAVEN_HOME is the currently selected Maven installation) file using <localRepository> element-

If nothing is specifed in settings.xml then ${user.home}/.m2 directory becomes the value of M2_REPO variable.