blob: 1b25be917e5e313723fc3cfc6a7d3c74ebc33ec3 [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=".">
<property name="FALCON_HOME" location="."/>
<!-- this script supports the usingDownloadCache property and
downloadCacheFolder property to cache downloads in the
folder specified by downloadCacheFolder. This can make
a huge difference in future runs although there is some
risk around caching bad downloads and/or needing to
clean up the cache -->
<!-- properties -->
<!--<property file="${FALCON_HOME}/build.properties"/>-->
<property name="lib.dir" value="${FALCON_HOME}/lib"/>
<property name="download.dir" value="${FALCON_HOME}/in"/>
<!--
Notes:
For Apache, the JARS must be removed from the repository.
Licenses:
antlr (3) - BSD
commons-cli (1.2) - Apache 2.0
commons-io (2.0.1) - Apache 2.0
guava (15.0) - Apache 2.0
JBurg (1.10.1) - CPL 1.0
lzma-sdk (9.2) - Public Domain
-->
<property name="antlr.name" value="antlr"/>
<property name="commons-cli.name" value="commons-cli-1.2"/>
<property name="commons-io.name" value="commons-io-2.0.1"/>
<property name="guava.name" value="guava-15.0"/>
<property name="jflex.name" value="jflex-1.5.1"/>
<property name="jburg.name" value="jburg-1.10.1"/>
<property name="lzma.name" value="lzma-sdk-9.2"/>
<!--<property name="antlr.src.url" value="http://antlr3.org/download"/>-->
<!--<property name="antlr.src.file" value="antlr-3.3-complete.jar"/>-->
<property name="antlr.src.url" value="http://search.maven.org"/>
<property name="antlr.src.folder" value="remotecontent?filepath=org/antlr/antlr-complete/3.5.2"/>
<property name="antlr.cache.folder" value="org/antlr/antlr-complete/3.5.2"/>
<property name="antlr.src.file" value="antlr-complete-3.5.2.jar"/>
<property name="INFO_DOWNLOADING_FILE_FROM" value="Downloading {0} from: {1}" />
<!--
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, antlr-jar, commons-jars, guava-jar, jflex-jar, jburg-jar, lzma-jar"
description="Downloads all the required thirdparty JARs"/>
<target name="prepare" >
<mkdir dir="${lib.dir}" />
</target>
<!--
Cleanup
-->
<target name="clean"
description="Removes thirdparty downloads.">
<delete includeEmptyDirs="true" failonerror="false">
<fileset dir="${download.dir}">
<include name="antlr*/**"/>
<include name="commons-cli*/**"/>
<include name="commons-io*/**"/>
<include name="guava*/**"/>
<include name="jflex*/**"/>
<include name="jburg*/**"/>
<include name="lzma*/**"/>
</fileset>
</delete>
</target>
<!--
Download thirdparty JARs
-->
<!--
Download a zip or gz file, extracts the jar file, and optionally copies the jar
file to a different location and optinally verifies the checksum and optionally
caches the file, and optionally pulls the file from the cache instead of downloading.
If the checksum fails, this script fails.
Params are:
srcDomain - the domain
srcFolder - path to file
cacheFolder - path to file in cache (usually srcFolder minus illegal characters)
srcFile - a .gz file for untar with gzip, else unzip
[md5]
[srcJarPath] - both src and dest required for the copy
[destJarFile]
Note: This is purposely coded without <if><else><then> so that a dependency on
ant-contrib.jar isn't required.
-->
<target name="download-zip" depends="check-cache"
description="Downloads tar/zip, and optionally verifies checksum and copies extracted jar.">
<mkdir dir="${download.dir}"/>
<antcall target="get-if-not-cached">
<param name="dest" value="${download.dir}/${srcFile}"/>
<param name="message" value="Checksum mismatch for ${download.dir}/${srcFile}"/>
</antcall>
<antcall target="copy-if-cached">
<param name="dest" value="${download.dir}/${srcFile}"/>
</antcall>
<condition property="zip.compressed">
<matches string="${srcFile}" pattern="^*.zip$"/>
</condition>
<antcall target="untar-file"/>
<antcall target="unzip-file"/>
<condition property="destination.known">
<and>
<isset property="srcJarPath"/>
<isset property="destJarFile"/>
</and>
</condition>
<antcall target="copy-downloaded-jar"/>
</target>
<target name="download-bz2" depends="check-cache"
description="Downloads bz2, and optionally verifies checksum and copies extracted jar.">
<mkdir dir="${download.dir}"/>
<antcall target="get-if-not-cached">
<param name="dest" value="${download.dir}/${srcFile}"/>
<param name="message" value="Checksum mismatch for ${download.dir}/${srcFile}"/>
</antcall>
<antcall target="copy-if-cached">
<param name="dest" value="${download.dir}/${srcFile}"/>
</antcall>
<untar src="${download.dir}/${srcFile}" dest="${download.dir}/temp" compression="bzip2"/>
<condition property="destination.known">
<and>
<isset property="srcJarPath"/>
<isset property="destJarFile"/>
</and>
</condition>
<antcall target="copy-downloaded-jar"/>
</target>
<!--
Download a jar file and optionally verify the checksum.
If the checksum fails, this script fails.
Params are:
srcDomain
srcFolder
srcFile
destJarFile
[md5]
-->
<target name="download-jar" depends="check-cache"
description="Downloads jar, and optionally verifies checksum.">
<antcall target="get-if-not-cached">
<param name="dest" value="${destJarFile}"/>
<param name="message" value="Checksum mismatch for ${destJarFile}"/>
</antcall>
<antcall target="copy-if-cached">
<param name="dest" value="${destJarFile}"/>
</antcall>
</target>
<target name="untar-file" unless="zip.compressed" description="Untars zipFile">
<untar src="${download.dir}/${srcFile}" dest="${download.dir}/temp" compression="gzip"/>
</target>
<target name="unzip-file" if="zip.compressed" description="Unzips zipFile">
<unzip src="${download.dir}/${srcFile}" dest="${download.dir}/temp"/>
</target>
<target name="get-if-not-cached" unless="found-in-cache">
<get src="${srcDomain}/${srcFolder}/${srcFile}" dest="${dest}"/>
<antcall target="check-sum">
<param name="dest" value="${dest}" />
<param name="message" value="Checksum mismatch for ${dest}"/>
</antcall>
<antcall target="put-in-cache" />
</target>
<target name="copy-if-cached" if="found-in-cache">
<!-- this string comes from the FlexJS en_US.properties because for now, this
target won't get called unless this script is called from the FlexJS install -->
<echo>${INFO_USING_CACHED_FILE} ${downloadCacheFolder}/${cacheFolder}/${srcFile}</echo>
<copy file="${downloadCacheFolder}/${cacheFolder}/${srcFile}" tofile="${dest}" overwrite="true"/>
</target>
<target name="check-cache" if="usingDownloadCache">
<available file="${downloadCacheFolder}/${cacheFolder}/${srcFile}" property="found-in-cache" />
</target>
<target name="put-in-cache" if="usingDownloadCache">
<copy tofile="${downloadCacheFolder}/${cacheFolder}/${srcFile}" file="${dest}" />
</target>
<target name="check-sum" if="md5"
description="Verifies MD5 checksum, and fails if checksum doesn't match">
<checksum file="${dest}" algorithm="MD5" verifyproperty="we.failed" property="${md5}" />
<fail message="${message}">
<condition>
<equals arg1="${we.failed}" arg2="false" />
</condition>
</fail>
</target>
<target name="copy-downloaded-jar" if="destination.known">
<mkdir dir="${lib.dir}"/>
<copy file="${download.dir}/temp/${srcJarPath}" toFile="${destJarFile}" verbose="true"/>
</target>
<target name="fail-with-message" if="we.failed"
description="Conditionally fails with the specified message">
<fail message="${message}"/>
</target>
<!--
antlr
-->
<target name="antlr-jar-check" description="Checks if antlr jar exists.">
<condition property="antlr.jar.exists">
<and>
<available file="${lib.dir}/antlr.jar"/>
</and>
</condition>
</target>
<target name="antlr-jar" depends="antlr-jar-check" unless="antlr.jar.exists"
description="Copies the antlr jar to the lib directory.">
<echo file="${basedir}/antlr.properties">antlr.echo=${INFO_DOWNLOADING_FILE_FROM}</echo>
<replace file="${basedir}/antlr.properties" token="{0}" value="${antlr.src.file}" />
<replace file="${basedir}/antlr.properties" token="{1}" value="${antlr.src.url}/${antlr.src.folder}" />
<property file="${basedir}/antlr.properties" />
<delete file="${basedir}/antlr.properties" />
<echo>${antlr.echo}</echo>
<antcall target="antlr-download-jar"/>
<echo file="${lib.dir}/antlr-LICENSE.TXT">http://www.antlr.org/license.html</echo>
</target>
<target name="antlr-download-jar" depends="antlr-jar-check" unless="antlr.jar.exists"
description="Downloads the antlr jars.">
<antcall target="download-jar">
<param name="srcDomain" value="${antlr.src.url}"/>
<param name="srcFolder" value="${antlr.src.folder}"/>
<param name="cacheFolder" value="${antlr.cache.folder}"/>
<param name="srcFile" value="${antlr.src.file}"/>
<param name="destJarFile" value="${lib.dir}/antlr.jar"/>
<param name="md5" value="acfa69f928a0f1653555bda73091efca"/>
<!--<param name="md5" value="238becce7da69f7be5c5b8a65558cf63"/>-->
</antcall>
</target>
<!--
commons
-->
<target name="commons-jars" depends="commons-cli-jar,commons-io-jar" />
<!--
commons-cli
-->
<target name="commons-cli-jar-check" description="Checks if common-cli.jar has been downloaded.">
<available file="${lib.dir}/commons-cli.jar" property="commons.cli.jar.exists"/>
</target>
<target name="commons-cli-jar" depends="commons-cli-jar-check" unless="commons.cli.jar.exists"
description="Downloads and copies common-cli.jar to the lib directory.">
<echo file="${basedir}/cli.properties">cli.echo=${INFO_DOWNLOADING_FILE_FROM}</echo>
<replace file="${basedir}/cli.properties" token="{0}" value="${commons-cli.name}-bin.tar.gz" />
<replace file="${basedir}/cli.properties" token="{1}" value="http://archive.apache.org/dist/commons/cli/binaries" />
<property file="${basedir}/cli.properties" />
<delete file="${basedir}/cli.properties" />
<echo>${cli.echo}</echo>
<antcall target="download-zip">
<param name="srcDomain" value="http://archive.apache.org"/>
<param name="srcFolder" value="dist/commons/cli/binaries"/>
<param name="cacheFolder" value="dist/commons/cli/binaries"/>
<param name="srcFile" value="${commons-cli.name}-bin.tar.gz"/>
<param name="md5" value="a05956c9ac8bacdc2b8d07fb2cb331ce"/>
<param name="srcJarPath" value="${commons-cli.name}/${commons-cli.name}.jar"/>
<param name="destJarFile" value="${lib.dir}/commons-cli.jar"/>
</antcall>
<copy todir="${lib.dir}">
<fileset dir="${download.dir}/temp/${commons-cli.name}">
<include name="LICENSE.txt"/>
</fileset>
<globmapper from="*" to="commons-cli-*"/>
</copy>
<delete dir="${download.dir}/temp/${commons-cli.name}"/>
</target>
<!--
commons-io
-->
<target name="commons-io-jar-check" description="Checks if commons-io.jar is in lib directory.">
<available file="${lib.dir}/commons-io.jar" property="commons.io.jar.exists"/>
</target>
<target name="commons-io-jar" depends="commons-io-jar-check"
unless="commons.io.jar.exists"
description="Copies commons-io.jar to the lib directory.">
<echo file="${basedir}/io.properties">io.echo=${INFO_DOWNLOADING_FILE_FROM}</echo>
<replace file="${basedir}/io.properties" token="{0}" value="${commons-io.name}-bin.tar.gz" />
<replace file="${basedir}/io.properties" token="{1}" value="http://archive.apache.org/dist/commons/io/binaries" />
<property file="${basedir}/io.properties" />
<delete file="${basedir}/io.properties" />
<echo>${io.echo}</echo>
<antcall target="download-zip">
<param name="srcDomain" value="http://archive.apache.org"/>
<param name="cacheFolder" value="dist/commons/io/binaries"/>
<param name="srcFolder" value="dist/commons/io/binaries"/>
<param name="srcFile" value="${commons-io.name}-bin.tar.gz"/>
<param name="md5" value="4f2c26f9d80f89d15939619cc8524f78"/>
<param name="srcJarPath" value="${commons-io.name}/${commons-io.name}.jar"/>
<param name="destJarFile" value="${lib.dir}/commons-io.jar"/>
</antcall>
<copy todir="${lib.dir}">
<fileset dir="${download.dir}/temp/${commons-io.name}">
<include name="LICENSE.txt"/>
</fileset>
<globmapper from="*" to="commons-io-*"/>
</copy>
<delete dir="${download.dir}/temp/${commons-io.name}"/>
</target>
<!--
guava - collections and other common constructs
-->
<target name="guava-jar-check" description="Checks if guava.jar is in lib directory.">
<available file="${lib.dir}/guava.jar" property="guava.jar.exists"/>
</target>
<target name="guava-jar" depends="guava-jar-check"
unless="guava.jar.exists"
description="Downloads and copies guava.jar to the lib directory.">
<echo file="${basedir}/guava.properties">guava.echo=${INFO_DOWNLOADING_FILE_FROM}</echo>
<replace file="${basedir}/guava.properties" token="{0}" value="guava-15.0.jar" />
<replace file="${basedir}/guava.properties" token="{1}" value="http://search.maven.org/remotecontent?filepath=com/google/guava/guava/15.0" />
<property file="${basedir}/guava.properties" />
<delete file="${basedir}/guava.properties" />
<echo>${guava.echo}</echo>
<antcall target="download-jar">
<param name="srcDomain" value="http://search.maven.org"/>
<param name="srcFolder" value="remotecontent?filepath=com/google/guava/guava/15.0"/>
<param name="cacheFolder" value="com/google/guava/guava/15.0"/>
<param name="srcFile" value="guava-15.0.jar"/>
<param name="destJarFile" value="${lib.dir}/guava.jar"/>
<param name="md5" value="2c10bb2ca3ac8b55b0e77e54a7eb3744"/>
</antcall>
<get src="http://www.apache.org/licenses/LICENSE-2.0" dest="${lib.dir}/guava-LICENSE.txt"/>
</target>
<!--
jflex
-->
<target name="jflex-jar-check" description="Checks if jflex.jar has been downloaded.">
<available file="${lib.dir}/jflex.jar" property="jflex.jar.exists"/>
</target>
<target name="jflex-jar" depends="jflex-jar-check" unless="jflex.jar.exists"
description="Downloads and copies jflex.jar to the lib directory.">
<echo file="${basedir}/jflex.properties">jflex.echo=${INFO_DOWNLOADING_FILE_FROM}</echo>
<replace file="${basedir}/jflex.properties" token="{0}" value="${jflex.name}.tar.gz" />
<replace file="${basedir}/jflex.properties" token="{1}" value="http://jflex.de" />
<property file="${basedir}/jflex.properties" />
<delete file="${basedir}/jflex.properties" />
<echo>${cli.echo}</echo>
<antcall target="download-zip">
<param name="srcDomain" value="http://jflex.de"/>
<param name="srcFolder" value="."/>
<param name="cacheFolder" value="."/>
<param name="srcFile" value="${jflex.name}.tar.gz"/>
<param name="md5" value="c388c909eb0024d546489a89e608e096"/>
<param name="srcJarPath" value="${jflex.name}/lib/${jflex.name}.jar"/>
<param name="destJarFile" value="${lib.dir}/JFlex.jar"/>
</antcall>
<copy todir="${lib.dir}">
<fileset dir="${download.dir}/temp/${jflex.name}">
<include name="LICENSE.txt"/>
</fileset>
<globmapper from="*" to="JFlex-*"/>
</copy>
<delete dir="${download.dir}/temp/${jflex.name}"/>
</target>
<!--
jburg - for codegen of certain java source files
-->
<target name="jburg-jar-check" description="Checks if jburg.jar is in lib directory.">
<available file="${lib.dir}/jburg.jar" property="jburg.jar.exists"/>
</target>
<target name="jburg-jar" depends="jburg-jar-check" unless="jburg.jar.exists"
description="Copies jburg.jar to the lib directory.">
<echo file="${basedir}/jburg.properties">jburg.echo=${INFO_DOWNLOADING_FILE_FROM}</echo>
<replace file="${basedir}/jburg.properties" token="{0}" value="${jburg.name}.tar.gz" />
<replace file="${basedir}/jburg.properties" token="{1}" value="http://downloads.sourceforge.net/project/jburg" />
<property file="${basedir}/jburg.properties" />
<delete file="${basedir}/jburg.properties" />
<echo>${jburg.echo}</echo>
<antcall target="download-zip">
<param name="srcDomain" value="http://downloads.sourceforge.net"/>
<param name="srcFolder" value="project/jburg"/>
<param name="cacheFolder" value="project/jburg"/>
<param name="srcFile" value="${jburg.name}.tar.gz"/>
<param name="md5" value="76830ee877cac40b981779325b3fa89f"/>
<param name="srcJarPath" value="lib/jburg.jar"/>
<param name="destJarFile" value="${lib.dir}/jburg.jar"/>
</antcall>
<copy todir="${lib.dir}">
<fileset dir="${download.dir}/temp">
<include name="LICENSE"/>
</fileset>
<globmapper from="*" to="jburg-*"/>
</copy>
<delete includeemptydirs="true">
<fileset dir="${download.dir}/temp" includes="**/*"/>
</delete>
</target>
<!--
lzma - compression
-->
<target name="lzma-jar-check" description="Checks if lzma jar exists.">
<available file="${lib.dir}/lzma-sdk.jar" property="lzma.jar.exists" />
</target>
<target name="lzma-jar" depends="lzma-jar-check" unless="lzma.jar.exists"
description="Copies the lzma build jars.">
<echo file="${basedir}/lzma.properties">lzma.echo=${INFO_DOWNLOADING_FILE_FROM}</echo>
<replace file="${basedir}/lzma.properties" token="{0}" value="lzma-9.20.jar.zip" />
<replace file="${basedir}/lzma.properties" token="{1}" value="http://www.java2s.com/Code/JarDownload/lzma" />
<property file="${basedir}/lzma.properties" />
<delete file="${basedir}/lzma.properties" />
<echo>${lzma.echo}</echo>
<antcall target="download-zip">
<param name="srcDomain" value="http://www.java2s.com"/>
<param name="srcFolder" value="Code/JarDownload/lzma"/>
<param name="cacheFolder" value="Code/JarDownload/lzma"/>
<param name="srcFile" value="lzma-9.20.jar.zip"/>
<param name="md5" value="d5f7343bbd03bf1c4a4806b372cc5354"/>
<param name="srcJarPath" value="lzma-9.20.jar"/>
<param name="destJarFile" value="${lib.dir}/lzma-sdk.jar"/>
</antcall>
<echo file="${lib.dir}/lzma-sdk-LICENSE.TXT">http://www.7-zip.org/sdk.html</echo>
<delete includeemptydirs="true">
<fileset dir="${download.dir}/temp" includes="**/*"/>
</delete>
</target>
</project>