blob: ba638a107f6b92b13cd2c10de96af094e3c5cf9c [file] [log] [blame]
<?xml version="1.0"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<project name="downloads" default="main" basedir=".">
<pathconvert property="compiler.tests" dirsep="/">
<path location="${basedir}"/>
</pathconvert>
<pathconvert property="compiler" dirsep="/">
<path location="${basedir}/../.."/>
</pathconvert>
<property name="external.lib.dir" value="${compiler}/lib/external"/>
<property name="download.dir" value="${compiler}/in"/>
<property file="${compiler}/../env.properties"/>
<property environment="env"/>
<property file="${compiler}/../local.properties"/>
<property file="${compiler}/../build.properties"/>
<!--
Notes:
For Apache, the JARS must be removed from the repository.
Licenses:
JUnit (4.10) - CPL 1.0
Commons Compress - Apache 2.0
Commons Lang3 - Apache 2.0
-->
<!--
Because the downloads requires a network connection and the JARs don't change very often,
they are each downloaded only if they don't already exist.
-->
<target name="main" depends="prepare, junit-jar, commons-compress-jar, commons-lang3-jar"
description="Downloads all the required thirdparty JARs"/>
<target name="prepare" >
<mkdir dir="${external.lib.dir}" />
</target>
<!--
Cleanup
-->
<target name="clean"
description="Removes thirdparty downloads.">
<delete includeEmptyDirs="true" failonerror="false">
<fileset dir="${download.dir}">
<include name="junit*/**"/>
<include name="commons-compress*/**"/>
</fileset>
</delete>
</target>
<!--
Download thirdparty JARs
-->
<!--
Download a jar file and optionally verify the checksum.
If the checksum fails, this script fails.
Params are:
srcUrl
srcJarFile
destJarFile
[md5]
-->
<target name="download-jar"
description="Downloads jar, and optionally verifies checksum.">
<get src="${srcUrl}/${srcJarFile}" dest="${destDir}/${destJarFile}" ignoreerrors="true"/>
<antcall target="get-from-cache-if-needed" >
<param name="srcFile" value="${srcJarFile}" />
<param name="destFile" value="${destJarFile}" />
<param name="destDir" value="${external.lib.dir}" />
</antcall>
<antcall target="fail-if-not-found" >
<param name="destFile" value="${destJarFile}" />
<param name="destDir" value="${external.lib.dir}" />
</antcall>
<checksum file="${destDir}/${destJarFile}" algorithm="MD5" property="${we.failed}"/>
<antcall target="fail-with-message">
<param name="message" value="Checksum mismatch for ${destDir}/${destJarFile}"/>
</antcall>
</target>
<target name="fail-with-message" if="we.failed"
description="Conditionally fails with the specified message">
<fail message="${message}"/>
</target>
<!--
junit
-->
<target name="junit-jar-check" description="Checks if JUnit JAR exists.">
<condition property="junit.jar.exists">
<and>
<available file="${external.lib.dir}/junit-4.10.jar"/>
</and>
</condition>
</target>
<target name="junit-jar" depends="junit-jar-check" unless="junit.jar.exists"
description="Copies the JUnit JAR to the lib directory.">
<echo message="Obtaining lib/external/junit-4.10.jar"/>
<antcall target="junit-download-jar"/>
</target>
<target name="junit-download-jar" depends="junit-jar-check" unless="junit.jar.exists"
description="Downloads the JUnit jar.">
<antcall target="download-jar">
<param name="srcUrl" value="http://search.maven.org/remotecontent?filepath=junit/junit/4.10"/>
<param name="srcJarFile" value="junit-4.10.jar"/>
<param name="destDir" value="${external.lib.dir}"/>
<param name="destJarFile" value="junit-4.10.jar"/>
</antcall>
</target>
<!--
commons-compress
-->
<target name="commons-compress-jar-check" description="Checks if commons-compress JAR exists.">
<condition property="commons-compress.jar.exists">
<and>
<available file="${external.lib.dir}/commons-compress-1.10.jar"/>
</and>
</condition>
</target>
<target name="commons-compress-jar" depends="commons-compress-jar-check" unless="commons-compress.jar.exists"
description="Copies the commons-compress JAR to the lib directory.">
<echo message="Obtaining lib/external/commons-compress-1.10.jar"/>
<antcall target="commons-compress-download-jar"/>
</target>
<target name="commons-compress-download-jar" depends="commons-compress-jar-check" unless="commons-compress.jar.exists"
description="Downloads the commons-compress jar.">
<antcall target="download-jar">
<param name="srcUrl" value="https://repo1.maven.org/maven2/org/apache/commons/commons-compress/1.10"/>
<param name="srcJarFile" value="commons-compress-1.10.jar"/>
<param name="destDir" value="${external.lib.dir}"/>
<param name="destJarFile" value="commons-compress-1.10.jar"/>
</antcall>
</target>
<!--
commons-lang3
-->
<target name="commons-lang3-jar-check" description="Checks if commons-lang3 JAR exists.">
<condition property="commons-lang3.jar.exists">
<and>
<available file="${external.lib.dir}/commons-lang3-3.4.jar"/>
</and>
</condition>
</target>
<target name="commons-lang3-jar" depends="commons-lang3-jar-check" unless="commons-lang3.jar.exists"
description="Copies the commons-lang3 JAR to the lib directory.">
<echo message="Obtaining lib/external/commons-lang3-3.4.jar"/>
<antcall target="commons-lang3-download-jar"/>
</target>
<target name="commons-lang3-download-jar" depends="commons-lang3-jar-check" unless="commons-lang3.jar.exists"
description="Downloads the commons-lang3 jar.">
<antcall target="download-jar">
<param name="srcUrl" value="https://repo1.maven.org/maven2/org/apache/commons/commons-lang3/3.4"/>
<param name="srcJarFile" value="commons-lang3-3.4.jar"/>
<param name="destDir" value="${external.lib.dir}"/>
<param name="destJarFile" value="commons-lang3-3.4.jar"/>
</antcall>
</target>
<target name="fail-if-not-found">
<fail message="${destDir}/${destJarFile} could not be downloaded or found in cache">
<condition>
<not>
<available file="${destDir}/${destJarFile}" />
</not>
</condition>
</fail>
</target>
<target name="double-check-file" >
<condition property="still-no-file" value="true">
<and>
<not>
<available file="${destDir}/${destJarFile}" />
</not>
<isset property="env.ROYALE_DOWNLOAD_CACHE" />
</and>
</condition>
<echo>Need file: ${still_no_file}</echo>
</target>
<target name="get-from-cache-if-needed" depends="double-check-file" if="still-no-file">
<copy file="${env.ROYALE_DOWNLOAD_CACHE}/${srcJarFile}" tofile="${destDir}/${destJarFile}" />
</target>
</project>