如何用Maven替换Ant?

时间:2022-12-09 21:07:27

What are the minimum steps I should follow to replace Ant with Maven?

使用Maven替换Ant应该遵循的最小步骤是什么?

3 个解决方案

#1


  1. Set up your project according to the standard directory layout.
  2. 根据标准目录布局设置项目。

  3. Create a minimal pom.xml with groupId, artifactId and version.
  4. 使用groupId,artifactId和version创建最小的pom.xml。

  5. Add your dependencies to the pom.xml
  6. 将依赖项添加到pom.xml

  7. Compare the WAR/JAR/EAR to the old version see if there is any change. Take actions to minimize the differences as told here.
  8. 将WAR / JAR / EAR与旧版本进行比较,看看是否有任何变化。采取措施尽量减少差异,如此处所述。

You should now be able to build a simple project, run the tests and package it.

您现在应该能够构建一个简单的项目,运行测试并打包它。

#2


Anecdote: Once you are in Maven, the reverse trip (though why would you ever go back!) is so simple:

轶事:一旦你在Maven,反向旅行(虽然你为什么要回去!)是如此简单:

mvn ant:ant

generates functionally equivalent ant scripts. Now if only an Ant->Maven generator existed.

生成功能相当的ant脚本。现在,如果只存在Ant-> Maven生成器。

#3


You can have a look to ant2maven script, that builds pom.xml from Ant scripts. I've never tried it, but it can be used to have a good pom.xml to start with...

您可以查看ant2maven脚本,该脚本从Ant脚本构建pom.xml。我从来没有尝试过,但它可以用来开始一个好的pom.xml ...

#1


  1. Set up your project according to the standard directory layout.
  2. 根据标准目录布局设置项目。

  3. Create a minimal pom.xml with groupId, artifactId and version.
  4. 使用groupId,artifactId和version创建最小的pom.xml。

  5. Add your dependencies to the pom.xml
  6. 将依赖项添加到pom.xml

  7. Compare the WAR/JAR/EAR to the old version see if there is any change. Take actions to minimize the differences as told here.
  8. 将WAR / JAR / EAR与旧版本进行比较,看看是否有任何变化。采取措施尽量减少差异,如此处所述。

You should now be able to build a simple project, run the tests and package it.

您现在应该能够构建一个简单的项目,运行测试并打包它。

#2


Anecdote: Once you are in Maven, the reverse trip (though why would you ever go back!) is so simple:

轶事:一旦你在Maven,反向旅行(虽然你为什么要回去!)是如此简单:

mvn ant:ant

generates functionally equivalent ant scripts. Now if only an Ant->Maven generator existed.

生成功能相当的ant脚本。现在,如果只存在Ant-> Maven生成器。

#3


You can have a look to ant2maven script, that builds pom.xml from Ant scripts. I've never tried it, but it can be used to have a good pom.xml to start with...

您可以查看ant2maven脚本,该脚本从Ant脚本构建pom.xml。我从来没有尝试过,但它可以用来开始一个好的pom.xml ...