Java ant属性以另一个属性为条件

Java ant属性以另一个属性为条件,java,ant,properties,version,Java,Ant,Properties,Version,我想在ant中执行以下操作 if javac.version >= 1.7 then <property name="myproperty" value="somevalue"/> else <property name="myproperty" value="someothervalue"/> endif 如果javac.version>=1.7 然后 其他的 恩迪夫 看起来很简单,但对ant不够熟悉,无法做到这一点 您可以使用任何帮助来检查java版

我想在ant中执行以下操作

if javac.version >= 1.7
then
  <property name="myproperty" value="somevalue"/>
else
  <property name="myproperty" value="someothervalue"/>
endif
如果javac.version>=1.7
然后
其他的
恩迪夫
看起来很简单,但对ant不够熟悉,无法做到这一点

您可以使用任何帮助来检查java版本系统属性的内容是否包含所需的版本。以下是一个例子:

<project name="test" default="target">
    <target name="target">
        <condition property="property" value="value1" else="value2">
            <contains string="${java.version}" substring="1.7"/>
        </condition>
        <echo>Java version: ${java.version}. Result: ${property}</echo>
    </target>
</project>

也许会有帮助。有任务。很高兴知道。如果你能接受这个答案,那就太好了。另见:
Java version: 1.7.0_60. Result: value1