Accepted answer

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.


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?

as far as i know, there is nothing that will automagically convert an eclipse project into a maven project (i.e. modify the layout, create a pom, "generate" and feed it with metadata, detect libraries and their versions to add them to the pom, etc). eclipse just doesn't have enough metadata to make this possible (this is precisely the point of the pom) and/or to produce a decent result.

or should i create a new maven project and manually copy over all source files, libs, etc

that would be the best option in my opinion. create a maven project, copy/move sources, resources, tests, test resources into their respective directories, declare dependencies, etc.


for converting to gradle is analogue to maven:

right click on project -> submenu configure -> convert to gradle (sts) project


there is a command line program to convert any java project into a sbt/maven project.

it resolves all jars and tries to figure out the correct version based on sha checksum, classpath or filename. then it tries to compile the sources until it finds a working configuration. custom tasks to execute per dependency configuration can be given too.

universalresolver 1.0
usage: universalresolver [options]

  -s <srcpath1>,<srcpath2>... | --srcpaths <srcpath1>,<srcpath2>...
        required src paths to include
  -j <jar1>,<jar2>... | --jars <jar1>,<jar2>...
        required jars/jar paths to include
  -t /path/to/dir | --testdirectory /path/to/dir
        required directory where test configurations will be stored
  -a <task1>,<task2>... | --sbt-tasks <task1>,<task2>...
        sbt tasks to be executed. i.e. compile
  -d /path/to/dependencyfile.json | --dependencyfile /path/to/dependencyfile.json
        optional file where the dependency buffer will be stored
  -l | --search
        load and search dependencies from remote repositories
  -g | --generateconfigurations
        generate dependency configurations
  -c <value> | --findbynamecount <value>
        number of dependencies to resolve by class name per jar


it's necessary because, more or less, when we import a project from git, it's not a maven project, so the maven dependencies are not in the build path.

here's what i have done to turn a general project to a maven project.

general project-->java project right click the project, properties->project facets, click "java". this step will turn a general project into java project.

java project --> maven project right click project, configure-->convert to maven project at this moment, maven dependencies lib are still not in the build path. project properties, build path´╝î add library, add maven dependencies lib

and wait a few seconds, when the dependencies are loaded, the project is ready!


chengdong's answer is correct, you should use configure>convert to maven project. however, i must add the conversion process has been greatly improved since m2e 0.13.0 : m2e 1.1+ and m2e-wtp 0.16.0+ can now convert the existing eclipse settings into maven plugin configuration .

as for the dependency conversion matter, you can try the jboss tools (jbt) 4.0 maven integration feature, which contains an experimental conversion wizard, plugged into m2e's conversion process :

it does not pretend to be the ultimate solution (nothing can), be it should greatly help bootstrap your maven conversion process.

also, fyi, here are some ideas to enhance m2e's conversion process, refactoring to use a maven layout will most probably be implemented in the future.

jbt 4.0 (requires eclipse javaee juno) can be installed from or from the eclipse marketplace


right click on the project name > configure > convert to maven project > click finish. here you will add some dependencies to download and add your expected jar file.

this will create an auto-generated pom.xml file. open that file in xml format in your eclipse editor. after build tag (</build>) add your dependencies which you can copy from maven website and add them there. now you are good to go. these dependencies will automatically add your required jar files.


i was having the same issue and wanted to mavenise entire eclipse workspace containing around 60 eclipse projects. doing so manually required a lot of time and alternate options were not that viable. to solve the issue i finally created a project called eclipse-to-maven on github. as eclipse doesn't have all necessary information about the dependencies, it does the following:

  • based on <classpathentry/> xml elements in .classpath file, it creates the dependencies on another project, identifies the library jar file and based on its name (for instance jakarta-oro-2.0.8.jar) identifies its version. currently artifactid and groupid are same as i couldn't find something which could return me the maven groupid of the dependency based on artifactid. though this is not a perfect solution it provides a good ground to speed up mavenisation.

  • it moves all source folders according to maven convention (like src/main/java)

  • as eclipse projects having names with spaces are difficult to deal on linux/unix environment, it renames them as well with names without spaces.

  • resultant pom.xml files contain the dependencies and basic pom structure. you have to add required maven plugins manually.


start from m2e 0.13.0 (if not earlier than), you can convert a java project to maven project from the context menu. here is how:

  • right click the java project to pop up the context menu
  • select configure > convert to maven project

here is the detailed steps with screen shots.

Related Query

More Query from same tag