vendredi 4 octobre 2013

Opening a Maven project in Eclipse

  1. Select 'Import...MavenExisting Maven Projects'.
  2. Enter the path to the root folder of the project you're interested in containing the 'pom.xml' or browse to it.
  3. If after entering a path directly you don't see any 'pom.xml' under the 'Projects' field then click on [Refresh].
    Note: If it's the very first time you install Maven then the lookup of the pom.xml files may take few minutes instead of few seconds because some artifacts used as plugins by m2e need to be downloaded.
  4. Make sure the 'pom.xml' file(s) is/are selected and click on [Next >] or directly on [Finish].
  5. You may then select the projects you've opened and use the 'Team' menu to specify the SCM to use (e.g. Git, Mercurial, Subversion, Perforce, CVS...)
  • Each 'pom.xml' defines a Maven project. If a project is a parent one then you may find other 'pom.xml' files in that project sub-folders. Simply make sure that you select them all when doing the importation into Eclipse.
  • You don't have to open all the projects if you need to work only on a sub-project nor have to compile all the projects your project depends on.
    Actually if your project depends on another project and if that other project built artifact is not in your '~/.m2/repository' then Maven will query the default central Maven repositories or the shared one you may have defined in your '~/.m2/settings.xml' (e.g. Artifactory, Nexus...) to get the corresponding artifact that has been built by the continuous integration (CI - e.g. Jenkins).
    In case of SNAPSHOT versions, Maven may get the artifact from the latest successful build by the continuous integration that is available on one of the default central or shared repositories.
  • The result of the build is located under 'target' folder and in case you use the command 'mvn install' inside your local repository '~/.m2/repository/'.
  • You mustn't check into the SCM your Eclipse projects folders and files (i.e. '.classpath', '.project', etc.). The 'm2e' plug-in will figure out the project properties from the 'pom.xml' that replaces all those folders and files. In principle an ignore file for the SCM should help preventing that (e.g. .gitignore, .hgignore, .p4ignore...).

Aucun commentaire :

Enregistrer un commentaire