Search code examples
javaeclipsemaven-2

Convert Existing Eclipse Project to Maven Project


For a project at work, we're considering using the Maven plugin for Eclipse to automate our builds. Right now the procedure is far more complicated than it ought to be, and we're hoping that Maven will simplify things to a one-click build.

My question is, is there a wizard or automatic importer for converting an existing Eclipse Java project to a Maven project, using the Maven plugin? Or should I create a new Maven project and manually copy over all source files, libs, etc.


Solution

  • If you just want to create a default POM and enable m2eclipse features: so I'm assuming you do not currently have an alternative automated build setup you're trying to import, and I'm assuming you're talking about the m2eclipse plugin.

    The m2eclipse plugin provides a right-click option on a project to add this default pom.xml:

    Newer M2E versions

    Right click on Project -> submenu Configure -> Convert to Maven Project

    Older M2E versions

    Right click on Project -> submenu Maven -> Enable Dependency Management.

    That'll do the necessary to enable the plugin for that project.


    To answer 'is there an automatic importer or wizard?': not that I know of. Using the option above will allow you to enable the m2eclipse plugin for your existing project avoiding the manual copying. You will still need to actually set up the dependencies and other stuff you need to build yourself.