Ant中的条件ivysettings文件
我正在尝试调整Ant build.xml脚本,使其能够在本地办公网络和AWS中工作。因此,根据构建发生的位置,我必须使用不同的ivysettings.xml文件。在这两种情况下,构建都是在詹金斯开始的。我的想法是在从aws启动时注入一个属性“aws=true”,否则该属性将不存在。我们正在AWS中使用Ant 1.7.1 local和一个更新的版本,但我现在不知道哪一个版本,build.xml应该能够在这两个版本上运行,所以1.7.1是限制。如果有必要,我可以升级这个 有人能帮我修改build.xml文件的语法吗Ant中的条件ivysettings文件,ant,Ant,我正在尝试调整Ant build.xml脚本,使其能够在本地办公网络和AWS中工作。因此,根据构建发生的位置,我必须使用不同的ivysettings.xml文件。在这两种情况下,构建都是在詹金斯开始的。我的想法是在从aws启动时注入一个属性“aws=true”,否则该属性将不存在。我们正在AWS中使用Ant 1.7.1 local和一个更新的版本,但我现在不知道哪一个版本,build.xml应该能够在这两个版本上运行,所以1.7.1是限制。如果有必要,我可以升级这个 有人能帮我修改build.x
<!-- Resolve dependencies -->
<target name="resolve" description="retrieve dependencies with ivy">
<ivy:settings file="ivysettings.xml"/>
<ivy:retrieve sync="true"/>
</target>
如果aws=true,我想使用名为ivysettings_aws.xml的文件,否则为ivysettings.xml
谢谢。我用ant_contrib解决了这个问题
<!-- Resolve dependencies -->
<target name="resolve" description="retrieve dependencies with ivy">
<if>
<equals arg1="${aws}" arg2="true" />
<then>
<ivy:settings file="ivysettings_aws.xml"/>
</then>
<else>
<ivy:settings file="ivysettings.xml"/>
</else>
</if>
<ivy:retrieve sync="true"/>
</target>
有效。我用ant_contrib解决了这个问题
<!-- Resolve dependencies -->
<target name="resolve" description="retrieve dependencies with ivy">
<if>
<equals arg1="${aws}" arg2="true" />
<then>
<ivy:settings file="ivysettings_aws.xml"/>
</then>
<else>
<ivy:settings file="ivysettings.xml"/>
</else>
</if>
<ivy:retrieve sync="true"/>
</target>
有效。以下内容是否更简单
<property name="ivy.settings" value="ivysettings.xml"/>
<target name="resolve" description="retrieve dependencies with ivy">
<ivy:settings file="${ivy.settings}"/>
..
</target>
下面的内容会更简单吗
<property name="ivy.settings" value="ivysettings.xml"/>
<target name="resolve" description="retrieve dependencies with ivy">
<ivy:settings file="${ivy.settings}"/>
..
</target>
您应该使用来摆脱对antcontrib的额外依赖,顺便说一句,它在将近10年前1.0b3就已经停止使用了。类似于:
<project
xmlns:if="ant:if"
xmlns:unless="ant:unless"
>
<!-- Resolve dependencies -->
<target name="resolve" description="retrieve dependencies with ivy">
<ivy:settings file="ivysettings_aws.xml" if:true="${aws}"/>
<ivy:settings file="ivysettings.xml" unless:true="${aws}"/>
<ivy:retrieve sync="true" />
</target>
</project>
或者使用Mark O'Connor提出的解决方案,但您需要记住更改-Divy.settings=…
参数以满足您的需要。您应该使用来摆脱对antcontrib的附加依赖关系,它在将近10年前就已经停止使用了。类似于:
<project
xmlns:if="ant:if"
xmlns:unless="ant:unless"
>
<!-- Resolve dependencies -->
<target name="resolve" description="retrieve dependencies with ivy">
<ivy:settings file="ivysettings_aws.xml" if:true="${aws}"/>
<ivy:settings file="ivysettings.xml" unless:true="${aws}"/>
<ivy:retrieve sync="true" />
</target>
</project>
或者使用Mark O'Connor提出的解决方案,但您需要记住更改
-Divy.settings=…
参数以满足您的需要。很好,谢谢!它更简单。cmd行会覆盖声明吗?@eric-g是的,在命令行上设置的属性将覆盖ANT文件中的默认值。很好,谢谢!它更简单。cmd行是否会覆盖声明?@eric-g是的,命令行上设置的属性将覆盖ANT文件中的默认值。