title: Apache Ant conditionally copy file from template and load properties
body: <p>I have a property file (x.props) that contains properties required for an Ant build:</p>
  
  <p>x.props:</p>
  
  <pre><code> prop1=something
   prop2=somethingElse
  </code></pre>
  
  <p>set in build.xml:</p>
  
  <pre><code> &lt;property file="x.props" /&gt;
  </code></pre>
  
  <p>The properties contained in x.props are then used in a path task:</p>
  
  <pre><code> &lt;path id="project.class.path"&gt;
      &lt;pathelement location="${prop1}/important.jar"/&gt;
      &lt;pathelement location="${prop2}/anotherImportant.jar"/&gt;
   &lt;/path&gt;
  </code></pre>
  
  <p>Before compilation starts.  I don't explicitly create these properties in build.xml</p>
  
  <p>The x.props file can be different for each local user, but for server builds it doesn't change. </p>
  
  <p>I created an x.props.template file to address the problem of users accidentally checking in or updating this file (but they need to be able to check it out).  I want to be able to create an x.props file from the x.props.template (I set x.props as svn:ignore).</p>
  
  <p>Users can save the template file as x.props and edit it and - theoretically, the server Ant build.xml can copy the template file to the server x.props if it doesn't exist.</p>
  
  <p>But that's not happening.  I tried using a target:</p>
  
  <pre><code> &lt;target name="x-props-file" unless="prop1" description="create a  
        local.properties file if it doesn't exist"&gt;
      &lt;copy file="x.props.template" tofile="x.props" /&gt;     
    &lt;/target&gt;
  </code></pre>
  
  <p>But it's called AFTER the path is set.</p>
  
  <p>I tried creating the file as a condition:</p>
  
  <pre><code> &lt;condition available="x.props"&gt;
      &lt;not&gt;
        &lt;copy file="x.props.template" tofile="x.props" /&gt;  
      &lt;/not&gt;
  &lt;/condition&gt;
  </code></pre>
  
  <p>But 'not' and 'condition' don't work with copy.</p>
  
  <p>loadProperties will fail if the file isn't found - but it won't copy a file.</p>
  
  <p>Ideally I'd like to be able to copy the new x.props right after the initial file load fails.</p>
  
  <p>Is there any way around this?</p>
  
  <p>ant version 1.1
  java 7</p>
  
  <p>Thanks</p>