Ant 到 Maven - 多个构建目标 [英] Ant to Maven - multiple build targets

查看:34
本文介绍了Ant 到 Maven - 多个构建目标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 Ant 构建,目前正在转换为 Maven.但是,Ant 构建有 2 个构建目标 - 一个构建整个应用程序,一个从其中一些文件(只有几个)构建 JAR.在 Ant 中,很容易有多个构建目标来处理这个问题,但我正在尝试确定在 Maven 中处理这个问题的最佳方法.

I have an Ant build that is currently being converted to Maven. However, the Ant build has 2 build targets - one that builds the entire app, and one that builds a JAR from some of those files (only a few). In Ant, it's easy to have multiple build targets to handle this, but I'm trying to determine the best way to handle this in Maven.

我可以将文件子集拆分到第二个项目中,它将拥有自己的 POM.那么第一个项目可能依赖于这个项目.但是,由于文件的子集太小(少于 10 个),为此拥有一个全新的项目似乎有点过头了.

I could split the subset of files into a second project and it will have its own POM. Then the first project could depend on this one. However, since the subset of files is so small (less than 10), it seems like it might be overkill to have an entirely new project for that.

还有其他方法可以解决这个问题吗?

Are there other ways to handle this?

推荐答案

您的第一个想法是正确的.将 2 个部分拆分为 2 个项目.

Your first thought is the correct one. Split the 2 pieces into 2 projects.

maven 哲学是每个项目都应该构建一个且唯一的工件(jar、war 等等)

The maven philosophy is that each project should build one and only artifact (jar, war, whatever)

你可能会一起hack一些东西,这样你就只有一个maven项目构建2个工件,但这将是一种hack.

You could probably hack something together so that you only have one maven project building 2 atrifacts, but it would be a hack.

你可以从maven调用ant,所以如果你真的想这样做,那么我建议你开始看maven ant插件.工件 id 是maven-antrun-plugin"

You can call ant from maven, so if you really want to do this, then I suggest you start looking at the maven ant plugin. The artifact id is "maven-antrun-plugin"

这篇关于Ant 到 Maven - 多个构建目标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆