如何将两个属性与数值进行比较? [英] How can I compare two properties with numeric values?

查看:27
本文介绍了如何将两个属性与数值进行比较?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何找出两个数字属性中的哪一个最大?

How can I find out which of two numeric properties is the greatest?

以下是检查两者是否相等的方法:

Here's how to check wheather two are equal:

<condition property="isEqual">
    <equals arg1="1" arg2="2"/>
</condition>

推荐答案

The Ant script task 允许您以脚本语言实现任务.如果您安装了 JDK 1.6,Ant 可以执行 JavaScript,而无需任何额外的依赖库.例如,这个 JavaScript 读取一个 Ant 属性值,然后根据条件设置另一个 Ant 属性:

The Ant script task allows you to implement a task in a scripting language. If you have JDK 1.6 installed, Ant can execute JavaScript without needing any additional dependent libraries. For example, this JavaScript reads an Ant property value and then sets another Ant property depending on a condition:

<property name="version" value="2"/>

<target name="init">
  <script language="javascript"><![CDATA[
    var version = parseInt(project.getProperty('version'));
    project.setProperty('isGreater', version > 1);
  ]]></script>

  <echo message="${isGreater}"/>
</target>

这篇关于如何将两个属性与数值进行比较?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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