从现有项目生成Maven POM?

时间:2021-09-19 23:56:45

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

是否有任何IDE(或任何其他工具)能够基于现有项目生成POM?


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.

我最终生成了一个Maven原型的POM,如Peter和Sal建议的那样,然后移动现有的源代码。感谢帮助人员。

4 个解决方案

#1


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.

您可以在IntelliJ中执行此操作,但它生成的POM可能比您手动编写时更复杂。如果您的项目当前在JBuilder或Eclipse中,则可以先导入它。

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)

相反,我建议您在POM中描述您的项目并使用它来生成项目信息。你可以为eclipse和idea做这个(我假设其他的IDE)

#2


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.

一种方法是通过maven原型创建模板项目,然后将现有代码移动到模板。我建议这只适用于非常简单的项目。它会像这样工作。

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.

你会得到错误。要添加缺少的依赖项,请访问:http://www.mvnrepository.com/并开始查找它们。如果你选择一个接近你需要的原型,你就会在那里。

Once it all works.

一切都行之有效。

svn commit -m "hacky maven port"

#3


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

您现有的项目可能不使用Maven,因此基于它创建POM并非易事。

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.

我能想到的最简单的方法是获取Eclipse的Maven插件,生成一个新的maven项目,然后添加你的代码。

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

您还需要使用Maven的方法管理外部jar。在这种情况下,它们可能是系统罐。

#4


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.

在eclipse Galileo中,如果你有maven2插件,你可以选择项目,然后右键单击并在上下文菜单中转到Maven2,应该有一个选项将项目转换为maven项目。

#1


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.

您可以在IntelliJ中执行此操作,但它生成的POM可能比您手动编写时更复杂。如果您的项目当前在JBuilder或Eclipse中,则可以先导入它。

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)

相反,我建议您在POM中描述您的项目并使用它来生成项目信息。你可以为eclipse和idea做这个(我假设其他的IDE)

#2


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.

一种方法是通过maven原型创建模板项目,然后将现有代码移动到模板。我建议这只适用于非常简单的项目。它会像这样工作。

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.

你会得到错误。要添加缺少的依赖项,请访问:http://www.mvnrepository.com/并开始查找它们。如果你选择一个接近你需要的原型,你就会在那里。

Once it all works.

一切都行之有效。

svn commit -m "hacky maven port"

#3


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

您现有的项目可能不使用Maven,因此基于它创建POM并非易事。

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.

我能想到的最简单的方法是获取Eclipse的Maven插件,生成一个新的maven项目,然后添加你的代码。

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

您还需要使用Maven的方法管理外部jar。在这种情况下,它们可能是系统罐。

#4


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.

在eclipse Galileo中,如果你有maven2插件,你可以选择项目,然后右键单击并在上下文菜单中转到Maven2,应该有一个选项将项目转换为maven项目。