title: How to conditionally include manifest options when making a JAR in ANT
body: <p>I am using ANT to manage multiple projects.  I have a build-common.xml script that individual projects include.  Some projects are libraries, others are programs.  For the programs, I would like to include </p>
  
  <pre><code>&lt;manifest&gt;
      &lt;attribute name="Main-Class" value="${main.class}"/&gt;
  &lt;/manifest&gt;
  </code></pre>
  
  <p>in the <code>&lt;jar&gt;</code> tag.  For libraries, I would like to have an empty jar tag as follows.</p>
  
  <pre><code>&lt;target name="jar" depends="compile" description="generate a jar"&gt;
      &lt;mkdir dir="${build}/jar" /&gt;
      &lt;property name="jarfile" value="${jar}/${ant.project.name}.jar" /&gt;
      &lt;jar jarfile="${jarfile}" basedir="${classes}"&gt;
      &lt;/jar&gt;
  &lt;/target&gt;
  </code></pre>
  
  <p>Is there a way I can include the manifest attribute Main-Class only if the property main.class is defined?</p>
  
  <p>Thanks!</p>