0

I have a standard android generated build script. My custom_rules.xml build script.

<project>

    <target name="-minify" >
        // More code here
    </target>
    <target name="-modify-index-html" >
        // More code here
    </target>

    <target name="-post-compile" depends="-minify"/>

    <target name="-post-package" depends="-modify-index-html"/>

</project>

The problem is I do not want targets -minify and -modify-index-html to run when debug build is being run. In fact they must run only when release target is run.

AppleGrew
  • 9,302
  • 24
  • 80
  • 124

1 Answers1

0

Ok I finally found my solution.

Both my custom targets will be executed after -set-release-mode is run (in case of release). So, here it goes:-

<target name="-minify" if="isReleaseTarget">
    ...
</target>

<target name="-modify-index-html" if="isReleaseTarget">
    ...
</target>

<target name="-set-release-mode" depends="android_rules.-set-release-mode">
    <property name="isReleaseTarget" value="true"/>
</target>

Notice that I override the android provided -set-release-mode target and make it depended on the actual target. However, it sets the property isReleaseTarget. I use that on my custom targets to make sure they run only when this is set.

AppleGrew
  • 9,302
  • 24
  • 80
  • 124