Hi Eric,
Sorry, I have been away from this list for a few days.
Did you get that fixed/worked around yet?

A)
I see you are loading the "unset" task from Antelope.
What happens if you don't load it?
Is that task used in any of the xml files you are importing?

B)
the code below works for me on Windows - results first. I think this is the 
results you wanted?
- the "HOSTNAME" was not set before I started, so the "COMPUTERNAME" was used.
- after the HOSTNAME was set the output came from the other property file.

--- OUTPUT: ---------
C:\tools\personal\ant-test>ant
Buildfile: C:\tools\personal\ant-test\build.xml

main:
     [echo] from files: stagefiles

BUILD SUCCESSFUL
Total time: 0 seconds

C:\tools\personal\ant-test>set HOSTNAME=me

C:\tools\personal\ant-test>ant
Buildfile: C:\tools\personal\ant-test\build.xml

main:
     [echo] from files: stage

BUILD SUCCESSFUL
Total time: 0 seconds
------ END OUTPUT ---------

My code is below.  
Your code did not work for me. 
Maybe you have a file "antlib.xml" in the path named?
- I am using different code than you are to load the ant contrib.
- My path to the code is split into two pieces. Fix for your own location.
- The filename I am using for the jar file may also not work for you.

On a different note, I normally store properties in properties files, not XML 
code.

--- code to load properties from a file ---
<property file="${TOOLS_HOME}/build/common.properties"/>

--- content of a properties file (# marks a comment line) ---
# directories
directories.stuff                 = ${ TOOLS _HOME}/Tools/stuff
directories.stuff-frameworks      = ${ TOOLS _HOME}/Tools/Oxygen/frameworks
--- end properties file ---

--- Start code from build.xml ---
<project name="ReportsBuild" default="main" basedir=".">
  <!--Set Host Info-->
  <property environment="env"/>
  <property name="env.HOSTNAME" value="${env.COMPUTERNAME}"/>

  <property name="TOOLS_HOME" value="/svn/TechPubs-trunk"/>
  <!--Import antcontrib-->
  <taskdef resource="net/sf/antcontrib/antlib.xml" >
    <classpath>
      <fileset dir="${TOOLS_HOME}/Tools/ant-contrib-1.0b3">
        <include name="ant-contrib-1.0b3.jar"/>
      </fileset>
    </classpath>
  </taskdef>

  <if>
    <equals arg1="${env.HOSTNAME}" arg2="YOW-RECHLIN-L1"/>
    <then>
      <import file="properties_stagefiles.xml" />
    </then>
    <else>
      <import file="properties_stage.xml" />
    </else>
  </if>

<target name="main">
  <echo message="from files: ${stage}"/>
</target>
</project>
--- end build.xml ---

--- start properties_stagefiles.xml ---
<project>
  <property name="stage" value=" stagefiles "/>
</project>
--- end properties_ stagefiles.xml ---

--- start properties_stage.xml ---
<project>
  <property name="stage" value="stage"/>
</project>
--- end properties_stage.xml ---

Rob




-----Original Message-----
From: Eric Fetzer [mailto:elstonk...@yahoo.com] 
Sent: Tuesday, May 08, 2012 12:01 PM
To: Ant Users List
Subject: Re: Build directly on machine vs. SSH to machine and start build

Thanks Rob!  So here's what I'm seeing which doesn't make sense to me:
 
bash-3.2$ ssh buildUser@buildMachine
[buildUser@buildMachine] /home/buildUser-> echo $HOSTNAME
buildMachine
[buildUser@buildMachine] /home/buildUser->
 
 
So $HOSTNAME IS already set.  Maybe that's not the issue.  Could it be that I'm 
outside of a task when I do this check?
 
<project name="ReportsBuild" default="main" basedir=".">
  <!--Set Host Info-->
  <property environment="env"/>
  <property name="env.HOSTNAME" value="${env.COMPUTERNAME}"/>
  <!--Import antcontrib-->
  <taskdef resource="net/sf/antcontrib/antlib.xml"/>
  <taskdef name="unset" classname="ise.antelope.tasks.Unset"/>
  <!--Import properties-->
  <import file="properties.xml" />
  <!--Import this prop file based on what build machine you're on-->
  <if>
    <equals arg1="${env.HOSTNAME}" arg2="buildMachine"/>
    <then>
      <import file="properties_stagefiles.xml" />
    </then>
    <else>
      <import file="properties_stage.xml" />
    </else>
  </if>
 
I guess this strategy, <property name="env.HOSTNAME" 
value="${env.COMPUTERNAME}"/>, is used to make the script portable.  I really 
don't care about that aspect of it, this will be run on unix only.  Could this 
be clearing the value?  Doesn't seem like it to me unless the variable was 
unset first but I don't understand why it's not working.
 
 
Thanks,
Eric


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@ant.apache.org
For additional commands, e-mail: user-h...@ant.apache.org

Reply via email to