tomi
tomi

Reputation: 535

conditional ant rule

This is my custom_rules.xml which is called from 'build.xml'

<?xml version="1.0" encoding="UTF-8"?>
<project name="custom_rules">
<xmlproperty file="AndroidManifest.xml" prefix="mymanifest" collapseAttributes="true"/>
<property name="build.dir" value="releases" />   
  <property name="version.name" value="${mymanifest.manifest.android:versionName}" />   
   <property name="version.code" value="${mymanifest.manifest.android:versionCode}" />   
   <property name="out.file" value="${ant.project.name}-${version.name}_${version.code}.apk" />   
<target name="-post-build">
    <echo>Output filename: ${out.file}</echo>
    <copy file="${out.final.file}" tofile="${build.dir}/${out.file}"/>
</target>

What I want to do is that the above should only be executed if ant was launched with ant release

Upvotes: 3

Views: 263

Answers (1)

Nicolas Lalev&#233;e
Nicolas Lalev&#233;e

Reputation: 2013

The way I usually deal with it:

  • make the "release" target set a property. Something like:

<property name="isreleasing" value="true" />

  • add an if to the target to execute only is there is a release. With somehting like:

<target name="-post-build" if="isreleasing">

...

Upvotes: 1

Related Questions