Monday, July 11, 2011

Eclipse and Maven

Tips for those getting started with Maven and Eclipse. If you're like me, you want to try using Maven for dependency management, but you prefer to leave the building of your project to Eclipse. To start with, install the m2eclipse plugin from this location.

To convert an existing Java project to Maven:
  • Right-click project > Configure > Convert to Maven Project
After doing this, you may notice two issues:
  • Project source folders have been converted to regular folders. Right-click the folder and select Build Path > Add to Build Path to fix this.
  • The JRE system library version has changed. Go to Project Properties > Java Build Path > Libraries to make sure your JRE system library is correct.
Adding new dependencies using the plugin's cool lookup tool is straight-forward. Right-click the generated pom.xml and select Maven > Add Dependency.

No comments: