Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Generating a Maven POM from an existing project?

Tags:

java

maven-2

ide

Do any of the IDEs (or any other tool for that matter) have the ability to generate a POM based on an existing project?


I ended up generating the POM with a Maven archetype as Peter and Sal suggested and then moving the existing source in. Thanks for the help guys.

like image 503
dshaw Avatar asked Jan 23 '09 21:01

dshaw


People also ask

How do I add Maven dependencies to an existing project in Eclipse?

Via the Maven index, you can search for dependencies, select them and add them to your pom file. To download the index, select Windows > Preferences > Maven and enable the Download repository index updates on startup option. After changing this setting, restart Eclipse. This triggers the download of the Maven index.


2 Answers

One way to do this it to create a template project via maven archetype then move your existing code to the template. I would recommend this only for really simple projects. It would work something like this.

mvn archetype:generate 
mv src/* src/main/java
mv test/* src/test/java
mvn package

You'll get errors. To add the missing dependencies, go here: http://www.mvnrepository.com/ and start looking them up. If you pick an archetype close to what you need, you'll be half way there.

Once it all works.

svn commit -m "hacky maven port"
like image 51
sal Avatar answered Sep 25 '22 20:09

sal


You can do this in IntelliJ, but the POM it generates may be more complex than if you write by hand. If your project is currently in JBuilder or Eclipse you can import this first.

Instead I would suggest you describe your project in a POM and use it to generate your project information. You can do this for eclipse and idea (and I assume other IDEs)

like image 21
Peter Lawrey Avatar answered Sep 23 '22 20:09

Peter Lawrey