tags:

views:

2263

answers:

5

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

+4  A: 

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)

Peter Lawrey
I was afraid that might be the case, that the IDE generated POM was even more complex than figuring out what you need to build it by hand.
dshaw
A: 

Your existing project probably does not use Maven, so creating a POM based on it isn't trivial.

The simplest way I can think of is to get the Maven plugin for Eclipse, generate a new maven project and then add your code.

You'll also need to manage external jars using Maven's method. In this case, they would probably be system jars.

Pyrolistical
+3  A: 

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"
sal
A: 

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.

dshaw
A: 

In eclipse Galileo if you have the maven2 plugin you can select the project and then right click and go down to Maven2 in the context menu and there should be an option to convert the project to a maven project.

ozone