Pages

Thursday, 24 July 2014

What is M2_REPO and what does mvn:eclipse eclipse do ?

First step is to be able to create a pom.xml, then you have to be able to get mvn:compile and mvn:package running. After that comes your eclipse repo the dev environment, in this page you get that running. Next how do you add jars to the classpath to get the jar running. 

  1. M2_REPO is a variable that defines where maven 2 repository is on your disk
  2. This means: add definition of M2_REPO to XML file that defines the eclipse workspace
  3. You can do the same manually if you want. That is what I personally did. Just go to Window/Preferences and then choose Java/Build Path/Classpath Variables. Once you did it you can enjoy maven integration with eclipse. Every time you add new dependency to your pom.xml, run
    mvn eclipse:eclipse
and refresh you workspace you get all new libraries into classpath of your project.
If you have a simple java project which is made up of only one module, using eclipse is very simple. To generate the eclipse project files from your POM you execute the following command:
mvn eclipse:eclipse
If you have created or checked out the project with eclipse, you only have to refresh the project in your workspace. Otherwise you have to import the project into your eclipse workspace (From the menu bar, select File >Import >Existing Projects into Workspace). In the latter case the project (directory) should not be located in your workspace, because eclipse might come into trouble, especially if you want to use eclipse as the scm client.

http://stackoverflow.com/questions/4517507/setting-up-m2-repo-classpath
http://maven.apache.org/guides/mini/guide-ide-eclipse.html

No comments:

Post a Comment