As per Dominiques's suggestion, I have used
setNewProperty("isLabelFrozen", String.valueOf(isLabelFrozen)) and I got
the correct value of the property inside the checkout task, but having
issues with if/unless attributes.

I have tried if/unless in <target> or in <fail> task (which is inside
checkout) and got the following results:

1) With "unless" attributes in checkout target, the checkout is always
successful (no matter what ever the value of property "isLabelFrozen"
[true or false]).
2) With "if" attribute in checkout target, the checkout target never ran
(no matter what ever the value of property "isLabelFrozen" [true or
false]).
3) With "if" attribute in <fail> task which is inside checkout target
and no "if" or "unless" in the target, the checkout is always successful
(no matter what ever the value of property "isLabelFrozen" [true or
false]).
4) With "unless" attribute in <fail> task which is inside checkout
target and no "if" or "unless" in the target, the checkout target always
failed (no matter what ever the value of property "isLabelFrozen" [true
or false]).

Is there an issue with "if" and "unless" when creating new property with

"setNewProperty" method inside the java code? 

Note: checkout target depends on the labelFrozen target. 

I'm using ANT 1.6.5. I have attached java class and the build file.

Thanks,
Mohan


-----Original Message-----
From: Scott Hebert [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, May 03, 2006 12:56 PM
To: Ant Users List
Subject: Re: How to initialize the value of a boolean property based on
the output from Custom Java ANT task?

Here's what I do:

1) in your label task, add an attribute called 'outputproperty'.

2) in the label task's execute method, add this:

                    if (outputproperty != null) {
                        log("Setting output property to be: " +
isLabelFrozen);
                        this.getProject().setProperty(outputproperty,
isLabelFrozen);
                    }

isLabelFrozen is the result of your checking if the label is frozen.

3) you can then use the outputproperty in the "if/unless" attributes of
a
target.

<target name="checkout" if="someOutputProp"/>

SH

On 5/2/06, John Sisson <[EMAIL PROTECTED]> wrote:
>
> Surely the java task can create a property file for the host build.xml
> to read; a judicious hit of 'antcall' and 'depends' should be able to
> inhale it as needed
> js
>
> -----Original Message-----
> From: Guttula, Mohan [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, May 02, 2006 4:34 PM
> To: Ant Users List
> Subject: How to initialize the value of a boolean property based on
the
> output from Custom Java ANT task?
>
> Hello All,
>
> I have a requirement of checking out files from StarTeam only if the
> Label is frozen.
> StarTeam Doesn't provide a way to check the Status of a Label (Frozen
or
> not) using StarTeam Client. So I have written a Java class to get the
> status of label with Custom ANT Task. Now I have 2 tasks, one for Java
> and one for checkout.
>
> I want to know how I can initialize one of the build property based on
> the output from Custom Java (so that I can use the property value to
> invoke the checkout task). Is it possible?
> ----
> Output of the custom ANT Java task:
> labelFrozen:
> [labelStatus] Label Frozen: true
> ----
>
> I have attached the java class and build.xml for convenience.
>
> Thanks,
> Mohan
>
>
> **************************************************************
> This message, including any attachments, contains confidential
> information intended for a specific individual and purpose, and is
> protected by law. If you are not the intended recipient, please
contact
> sender immediately by reply e-mail and destroy all copies. You are
> hereby notified that any disclosure, copying, or distribution of this
> message, or the taking of any action based on it, is strictly
> prohibited.
> TIAA-CREF
> **************************************************************
>
>


**************************************************************
This message, including any attachments, contains confidential information 
intended for a specific individual and purpose, and is protected by law.  If 
you are not the intended recipient, please contact sender immediately by reply 
e-mail and destroy all copies.  You are hereby notified that any disclosure, 
copying, or distribution of this message, or the taking of any action based on 
it, is strictly prohibited.
TIAA-CREF
**************************************************************

<?xml version="1.0" encoding="UTF-8" ?>
<project basedir="." name="gateway" default="help">

	<property name="stserver" value="localhost" />
	<property name="stport" value="11111" />
	<property name="stproject" value="myproject" />
	<property name="stuser" value="vijay" />
	<property name="stlabel" value="RE_FIX_1.4.a"/>
	<property name="base_staging_area"   value="C:/downloads/StarTeam/StarTeam_Ant/star_ant.1.6.5"/>
	<property name="checkout_dir" value="${base_staging_area}/release"/> 
	<taskdef resource="net/sf/antcontrib/antcontrib.properties">
		<classpath>
			<pathelement location="C:\ant-contrib\lib\ant-contrib.jar"/>
		</classpath>
	</taskdef>
	<taskdef resource="net/sf/antcontrib/antlib.xml">
		<classpath>
			<pathelement location="C:\ant-contrib\lib\ant-contrib.jar"/>
		</classpath>
	</taskdef>
    <taskdef name="labelStatus" classname="LabelStatus"/>
    
	<target name="checkout" depends="labelFrozen" if="${isLabelFrozen}">
	  <!-- Checks out the files from StarTeam using a label -->  
	  <condition property="starteam.cp.client.dir" value="C:/Program Files/Borland/StarTeam 6.0" >
		  <os family="windows"/>
	  </condition>       

	  <condition property="starteam.cp.client.dir" value="/autovol/tiaa.utils/starteam" >
		  <os family="unix"/>
	  </condition> 
	  <echo>Value of the property isLabelFrozen in checkout target: ${isLabelFrozen}</echo>
      <!--fail message="Status of the Label: ${isLabelFrozen}" unless="${isLabelFrozen}"/-->
	  <echo> Checking out the files from StarTeam. Please wait...</echo>
	  <exec dir="${starteam.cp.client.dir}" executable="${starteam.cp.client.dir}/stcmd" >
		  <arg value="co"/>
		  <arg value="-p"/>
		  <arg value="${stuser}:[EMAIL PROTECTED]:${stport}/${stproject}" />
		  <arg value="-is" />
		  <arg value="-q" />
		  <arg value="-stop" />
		  <arg value="-vl" />
		  <arg value="${stlabel}" />
		  <arg value="-nologo" />
		  <arg value="-o" />
		  <arg value="-ts" />
		  <arg value="-eol" />
		  <arg value="on" />
		  <arg value="-fs" />
		  <arg value="-fp" />
		  <arg value="${checkout_dir}" />
	  </exec>
	</target>
		
	<target name="labelFrozen">
		<labelStatus m_strServer="${stserver}" m_nPort="${stport}" m_strUser="${stuser}" m_strPassword="${stpassword}" m_strProject="${stproject}" m_strLabel="${stlabel}"/>
		<echo>Value of the property isLabelFrozen in labelFrozen target: ${isLabelFrozen}</echo>
	</target>
    
</project>
    
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to