Maven-如何执行条件执行 [英] Maven - How to perform conditional execution

查看:265
本文介绍了Maven-如何执行条件执行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在pom.xml中执行代码段的条件执行? 我的要求是根据pom.xml中定义的变量复制文件/目录以部署结构.

Is there a way to perform conditional execution of snippet in pom.xml? my requirement is to copy a file/directory to deploy structure based on variable defined in pom.xml...

例如:

< if >
    < equals arg1="package" arg2="package"/>
       < then>
              ....
           < /then>
     < /if>

不确定如何实现!

任何指针都将受到高度赞赏.

Any pointers would be highly appreciated.

谢谢, SR

推荐答案

可能您需要使用 Maven AntRun插件.

通常,POM中没有条件表达式.与此类似的唯一事物是构建配置文件在某些指定条件下被激活,但是它们可能不适合您当前的情况.

In general, there's no conditional expressions in POM. The only thing similar somehow to this are build profiles that can be activated on some specified conditions, however they probably don't fit into your current case.

最后,我的建议在这里.我们不确切知道您的案子是什么,甚至没有任何真实的代码片段,但是根据我的经验,必须在Maven中使用这种hackin的东西真的很不寻常.对我来说,这听起来像是Maven理解,项目结构之类的问题.我可能是错的,也许您的情况确实需要这样做,但是请考虑使用其他选项来适合Maven的默认方法和约定.

And, at the end, my suggestion here. We don't know exactly what your case is about and don't even have any real code snippet, however from my experience it's really unusual to have to use such hackin' stuff in Maven. For me it smells like some problems with Maven understanding, project structure or stuff like that. I may be wrong and maybe your case really needs that, but consider other options to fit into Maven default approach and conventions instead.

这篇关于Maven-如何执行条件执行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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