Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
<project name="envchange-task"><!-- C O P Y R I G H T N O T I C EThis material is confidential to ERG and may not be disclosed in wholeor in part to any third party nor used in any manner whatsoever otherthan for the purposes expressly consented to by ERG in writing.This material is also copyright and may not be reproduced, stored in aretrieval system or transmitted in any form or by any means in whole orin part without the express written consent of ERG.--><!-- "REPLACE_ANT_WINDOWS" below gets replaced by ant-windows version whenthis package is released. --><using name="ant-windows" version="REPLACE_ANT_WINDOWS"/><!-- Invoke another copy of Ant and run the specified target.This allows modification of the environment by:- attribute "pathadditions=" - append the given string to the Path/PATHenvironment variable. String can contain multiple extra pathsseparated by either ";" or ":".- "<env>" elements as per the standard "<exec>" Ant task.This is used for e.g. ensuring the Borland compiler can find the Borlandlinker (ilink32).Note "using.nocache=true" is set on the new Ant to flag that all ant-usingcaching has already been done on the first Ant, so no need to do it all again.--><macrodef name="envchange"><attribute name="target"/><attribute name="pathadditions" default="NO_ADDITIONS"/><!-- Any elements inside <envchange> implicitly are part of <envchange-elements>.This is to pick up <env> elements for <exec>. --><element name="envchange-elements" implicit="yes" optional="yes"/><sequential><!-- Get existing Path/PATH env var --><if><isset property="windows"/><then><property name="envchange.oldpath" value="${env.Path}"/></then><else><property name="envchange.oldpath" value="${env.PATH}"/></else></if><!-- Add specified additions to old path, or just use old path as isif no additions were specified --><if><equals arg1="@{pathadditions}" arg2="NO_ADDITIONS"/><then><property name="envchange.newpath" value="${envchange.oldpath}"/></then><else><property name="envchange.newpath" value="${envchange.oldpath};@{pathadditions}"/></else></if><if><isset property="windows"/><then><!-- Note we can't use executable=ant.bat because we don't get error codespropagated back to detect build failures. This is an inconsistency inWindows - that you'll get the error code of the batch file's last commandeven if it's something irrelevant like a goto! However if you run a batchfile in an existing shell then an error code will be maintained. e.g.if from the cmd line you echo %ERRRORLEVEL%. So that's why we need toexec cmd.exe instead and call the batch file from there.--><exec executable="cmd.exe" failonerror="true"><arg value="/c"/><arg value="call ant.bat -f ${ant.file} -Dusing.nocache=true @{target}"/><env key="Path" path="${envchange.newpath}"/> <!-- Windows: use "Path" env var --><envchange-elements/></exec></then><else><!-- Not Windows - so invoke ant directly --><exec executable="ant" failonerror="true"><arg value="-f"/><arg value="${ant.file}"/><arg value="-Dusing.nocache=true"/><arg value="@{target}"/><env key="PATH" path="${envchange.newpath}"/> <!-- Unix: use "PATH" env var --><envchange-elements/></exec></else></if></sequential></macrodef></project>