Generating a Maven POM from an existing project?

后端 未结 4 1066
眼角桃花
眼角桃花 2020-12-30 03:04

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 Ma

相关标签:
4条回答
  • 2020-12-30 03:38

    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.

    0 讨论(0)
  • 2020-12-30 03:42

    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.

    0 讨论(0)
  • 2020-12-30 03:50

    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)

    0 讨论(0)
  • 2020-12-30 03:55

    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"
    
    0 讨论(0)
提交回复
热议问题