0
votes

I am using QAF with ant as build script and IVY as dependency management tool. In order to automatic ivy install the build script have following ant target:

<target name="download-ivy" unless="skip.download">
    <mkdir dir="${ivy.jar.dir}" />
    <!-- download Ivy from web site so that it can be used even without any 
        special installation -->
    <echo message="installing ivy..." />
    <get src="http://repo1.maven.org/maven2/org/apache/ivy/ivy/${ivy.install.version}/ivy-${ivy.install.version}.jar" dest="${ivy.jar.file}" usetimestamp="true" />
</target>

There is build.properties where property skip.download provided to download-ivy ON or OFF by providing respective value true or false.

Now the problem is whatever value i provide for skip.download in build.properties it considers it true, and always executes the target (downloads ivy).

#not working
skip.download=false

I referred IVY + Ant documentation where it has similar following target with different property name.

<target name="download-ivy" unless="offline">

    <mkdir dir="${ivy.jar.dir}"/>
    <!-- download Ivy from web site so that it can be used even without any special installation -->
    <get src="https://repo1.maven.org/maven2/org/apache/ivy/ivy/${ivy.install.version}/ivy-${ivy.install.version}.jar" 
         dest="${ivy.jar.file}" usetimestamp="true"/>
</target>

I found workaround and as workaround need to remove or comment that property in order to skip download.

Is there any way so that the property value works fine with unless attribute in target?

1

1 Answers

1
votes

I use the following target to install ivy. Note how it uses the available task to determine if ivy is already installed:

<available classname="org.apache.ivy.Main" property="ivy.installed"/>

<target name="install-ivy" description="Install ivy" unless="ivy.installed">
    <mkdir dir="${user.home}/.ant/lib"/>
    <get dest="${user.home}/.ant/lib/ivy.jar" src="http://search.maven.org/remotecontent?filepath=org/apache/ivy/ivy/2.4.0/ivy-2.4.0.jar"/>
    <fail message="Ivy has been installed. Run the build again"/>
</target>

Note:

  • The directory "$HOME/.ant/lib" is one of the standard locations ivy uses to load 3rd party extensions.