如何在Maven 2中将目标字符串指定为defaultGoal? [英] How do you specify a string of goals as the defaultGoal in maven 2?

查看:887
本文介绍了如何在Maven 2中将目标字符串指定为defaultGoal?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是很好奇,有没有一种方法可以指定您要将一串目标作为Maven项目中的默认目标运行?有与蚂蚁的<project name="MyProject" basedir="." default="main"><target name="main" depends="clean,run"/>等效的东西吗?

I'm just curious, is there a way to specify that you want a string of goals run as the default goal in a maven project? Is there an equivalent to Ant's <project name="MyProject" basedir="." default="main"><target name="main" depends="clean,run"/>?

推荐答案

大致等效,您可以定义默认目标或阶段,如果build元素中未给出任何目标或阶段,则将执行该默认目标或阶段:

There is something roughly equivalent, you CAN define a default goal or phase that will be executed if none is given in the build element:

<build>
  <defaultGoal>install</defaultGoal>
  ...
</build>

但这必须是一个单个阶段或目标,您不能通过多个阶段/目标(因为一个阶段会触发所有先前的阶段,所以这并不是一个真正的问题).

But this has to be a single phase, or goal, you can't pass multiple phases/goals (not really a problem since a phase triggers all preceding phases).

这是POM参考关于defaultGoal的内容:

Here is what the POM Reference writes about defaultGoal:

defaultGoal: (如果未指定)将执行的默认目标或阶段.如果给出了目标,则应在命令行中对其进行定义(例如jar:jar).如果定义了阶段(例如安装),也是如此.

defaultGoal: the default goal or phase to execute if none is given. If a goal is given, it should be defined as it is in the command line (such as jar:jar). The same goes for if a phase is defined (such as install).

参考

  • POM参考
    • 3.1.1 BaseBuild元素集
    • Reference

      • POM Reference
        • 3.1.1 The BaseBuild Element Set
        • 这篇关于如何在Maven 2中将目标字符串指定为defaultGoal?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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