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.
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 : http://docs.jboss.org/tools/whatsnew/maven/maven-news-4.0.0.beta1.html.
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 http://download.jboss.org/jbosstools/updates/stable/juno/ 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:
<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
groupidare 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
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.
- Convert Existing Eclipse Project to Maven Project
- Maven root pom.xml marked as red when importing existing project into eclipse
- Add Maven nature to existing Eclipse project that has pom but no Maven submenu
- Importing an existing maven Project into Eclipse
- eclipse existing maven project add jpa support?
- Eclipse m2e multi-module project checkout and convert to maven
- m2eclipse: add group id to project name when importing existing maven project into Eclipse
- Automating the Import of Existing Maven Project Into Eclipse
- Eclipse - Importing an existing Maven project gives Unsupported IClasspathEntry kind=4 Error
- Eclipse - Convert to Maven project
- How to convert an existing eclipse GWT project into a Dynamic Web Project?
- how do I add a Maven dependency on another existing project in Eclipse
- How to convert a maven dependeny from the local repo to a maven project in eclipse ?
- Eclipse convert to Maven project not creating a POM file
- Importing a Maven project as a sub project in an existing project in eclipse
- Uploading an Existing Maven Eclipse Project into GitHub
- How can I convert a maven project to a Dynamic Web Project in Eclipse that builds with Ant?
- How to convert properly Eclipse project to Maven project?
- convert eclipse plugin project into maven project programatically
- Can not Convert to Maven Project in Eclipse
- maven project convert to Eclipse classpath
- Adding existing maven project to Maven multi module project in eclipse
- I integrated maven in eclipse . then i imported a existing maven project using import wizard. i got the following error please help me out
- The maven project generated by gwt-maven-plugin can't be imported into eclipse via import existing maven project
- How would you add maven to an existing GWT project in Eclipse with m2e installed?
- How to convert an existing Android project with Google API 4.2 to Maven
- Convert an Eclipse "Makefile project from existing code" to an AVR project
- why I cannot convert an existing Eclipse project to the dynamic web project?
- Converting existing project to maven and run it in dev. mode in eclipse
More Query from same tag
- How to quickly add namespace declarations in a spring bean config file via STS
- how to add python perspective in rcp
- Why does maven pom.xml file show error once i add apache poi dependency to it?
- Where do you find the JDBCProvider Interface?
- Too many files open in system when outputting to a txt file in Java
- Connecting to my own router via android
- Graphical layout broken
- view native code from Eclipse
- eclipse dynamic web project default start page
- Java Socket Programming in Eclipse
- Type mismatch: cannot convert from Set<Object> to Set<Long>
- Getting NoClassDefFoundError -> com/sun/jna/platform/win32/Psapi with Eclipse
- Is there documentation to implement Zooz in a Codenameone Project (Eclipse)?
- How do I install PDT 2.0 in Eclipse Ganymede?
- Why is ADT calling code that the doc specifies throws an UnsupportedOperationException?
- Maven trouble during project creation in Eclipse Mare
- Eclipse : Programmatically importing projects without copying
- How to declare multiple activities in Manifest.xml on Android Eclipse
- Where does tomcat store txt files used by web applications
- How can I add an editor without IEditorInput into a RCP application?
- Java compiler version and java version is different
- How to Find Elements In Selenium Without Run Web Driver
- Can you copy resources from an eclipse project to a UNC path programmatically?
- Setting up Apache Tomee with jdk1.8 for ejb application
- Using CUTE for C++ tests in Eclipse
- How to delete project nature in eclipse rcp
- Eclipse-project to makefile for ant/maven/gradle/
- Making in-memory workspace or folder in Eclipse
- LG G2 vs980 not recognized by ADB devices command (Win7 on virtualbox)
- Set a default parameter to the first day of the month Birt report