user1563560
user1563560

Reputation: 79

Ant: Having a condition inside tar task

Is there a way of having a condition on the tar task so as to only include certain files if a condition is met? I want some files to always be included and some to only be included when a condition is true.

Upvotes: 0

Views: 460

Answers (1)

Christopher Peisert
Christopher Peisert

Reputation: 24154

You could use conditional targets to wrap the <tar> task.

<target name="tar1" if="condition1">
  <tar>
    <tarfileset dir="${dir}">
      <include name="**/*.alwaysIncluded" />
      <include name="**/*.conditionallyIncluded" />
    </tarfileset>
  </tar>
</target>

<target name="tar2" unless="condition1">
  <tar>
    <tarfileset dir="${dir}">
      <include name="**/*.alwaysIncluded" />
    </tarfileset>    
  </tar>
</target>

Upvotes: 1

Related Questions