我们可以在 ANT 中使用 pom.xml 吗
我知道,我们可以很好地使用ANT和Maven一起构建项目。我们可以通过Maven的POM.xml来运行ANT脚本。但我的问题是我们可以通过 ANT 的 build.xml 运行 pom.xml 吗? 即我们可以从 build.xml 创建 Maven 构建吗
I know that, we can very well use ANT and Maven together to build the project.We can run ANT scripts through Maven's POM.xml. But my question is can we run pom.xml through ANT's build.xml ?
i.e. can we create maven build from build.xml
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
是的,使用 maven ant 任务。
该页面列出了多个可以集成到 ant 构建脚本中的 Maven 任务,从而结合了两者的功能。举个例子,有 mvn 任务,根据文档可以从 ant 进行完整的 Maven 构建。
除此之外,还有
任务,每个任务都配有示例。
Yes, using maven ant tasks.
The page lists out multiple maven tasks which can be integrated into an ant build script, thus combining the features of both. To take an example, there is the mvn task, which as documented can do a full maven build from ant.
Besides this, there are
each described with examples.
Maven 和 ANT 是非常不同的构建工具。在 ANT 中,您自己编写所有逻辑,而标准构建过程是使用 Maven“内置”的。
POM 文件不包含任何逻辑,而是包含一系列有关您的项目的声明。
如果您很好地理解 Maven 的工作原理,理论上可以采用 POM 并生成模拟 Maven 构建行为的 ANT 构建。我不知道有任何解决方案可以轻松地向另一个方向转换,主要是因为 ANT 缺少 Maven 功能,例如依赖关系管理。
我建议您保留现有的构建逻辑并将类路径的管理委托给 ivy 或 Maven ANT 任务。这些工具还提供将构建输出发布到 Maven 存储库的任务,使您的项目能够与使用 Maven 的其他项目共享。
最后,我是一个 ivy 倡导者,并写了一篇 ant2ivy 脚本,可以协助升级过程。它创建一组初始配置文件,用于从 Maven 中央存储库下载项目依赖项。
Maven and ANT are very different build tools. In ANT you write all the logic yourself, whereas a standard build process is "baked in" with Maven.
The POM file contains no logic, instead it contains a series of declarations about your project.
If you understand well how Maven works, it is theoretically possible to take a POM and generate an ANT build that emulates the behaviour of the Maven build. I'm not aware of any solution which can easily convert in the other direction, mainly because ANT is missing Maven functionality, such as dependency management.
Instead of trying to convert an ANT build into Maven, I'd recommend that you keep your existing build logic and delegate the management of your classpath to the ivy or Maven ANT tasks. These tools also provide tasks to publish your build output to a Maven repository, enabling your project to share with other projects using Maven.
Finally, I'm an ivy advocate and wrote an ant2ivy script which can assist in upgrade process. It creates an initial set of configuration files for downloading your projects dependencies from the Maven central repository.