blob: 8ecf5311b3dcd9b900e70d1f687506312d101a0a [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="FALCONJS_HOME" location="."/>
<!-- properties -->
<!--<property file="${FALCONJS_HOME}/build.properties"/>-->
<property name="lib.dir" value="${FALCONJS_HOME}/lib"/>
<property name="download.dir" value="${FALCONJS_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 (r08) - Apache 2.0
felix (1.10.1) - CPL 1.0
closure (9.2) - Apache 2.0
-->
<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-r08"/>
<property name="felix.name" value="felix-3.0.2"/>
<property name="closure.name" value="compiler"/>
<!--
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, felix-jar, closure-jar"
description="Downloads all the required thirdparty JARs"/>
<target name="prepare" >
<echo message="Making lib directory ${basedir}/${lib.dir}"/>
<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="felix*/**"/>
<include name="compiler*/**"/>
<include name="temp*/**"/>
</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.
If the checksum fails, this script fails.
Params are:
srcUrl
zipFile - 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"
description="Downloads tar/zip, and optionally verifies checksum and copies extracted jar.">
<mkdir dir="${download.dir}"/>
<get src="${srcUrl}/${zipFile}" dest="${download.dir}/${zipFile}"/>
<condition property="zip.compressed">
<matches string="${zipFile}" pattern="^*.zip$"/>
</condition>
<antcall target="untar-file"/>
<antcall target="unzip-file"/>
<antcall target="check-sum">
<param name="message" value="Checksum mismatch for ${download.dir}/${zipFile}"/>
</antcall>
<condition property="destination.known">
<and>
<isset property="srcJarPath"/>
<isset property="destJarFile"/>
</and>
</condition>
<antcall target="copy-downloaded-jar"/>
</target>
<target name="download-bz2"
description="Downloads bz2, and optionally verifies checksum and copies extracted jar.">
<mkdir dir="${download.dir}"/>
<get src="${srcUrl}/${zipFile}" dest="${download.dir}/${zipFile}"/>
<untar src="${download.dir}/${zipFile}" dest="${download.dir}/temp" compression="bzip2"/>
<antcall target="check-sum">
<param name="message" value="Checksum mismatch for ${download.dir}/${zipFile}"/>
</antcall>
<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:
srcUrl
srcJarFile
destJarFile
[md5]
-->
<target name="download-jar"
description="Downloads jar, and optionally verifies checksum.">
<get src="${srcUrl}/${srcJarFile}" dest="${destJarFile}"/>
<checksum file="${destJarFile}" algorithm="MD5" property="${we.failed}"/>
<antcall target="fail-with-message">
<param name="message" value="Checksum mismatch for ${destJarFile}"/>
</antcall>
</target>
<target name="untar-file" unless="zip.compressed" description="Untars zipFile">
<untar src="${download.dir}/${zipFile}" dest="${download.dir}/temp" compression="gzip"/>
</target>
<target name="unzip-file" if="zip.compressed" description="Unzips zipFile">
<unzip src="${download.dir}/${zipFile}" dest="${download.dir}/temp"/>
</target>
<target name="check-sum" if="md5"
description="Verifies MD5 checksum, and fails if checksum doesn't match">
<checksum file="${download.dir}/${zipFile}" algorithm="MD5" property="${we.failed}"/>
<antcall target="fail-with-message">
<param name="message" value="${message}"/>
</antcall>
</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="${basedir}/lib/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.">
<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="srcUrl" value="http://antlr3.org/download"/>
<param name="srcJarFile" value="antlr-3.3-complete.jar"/>
<param name="destJarFile" value="${lib.dir}/antlr.jar"/>
<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.">
<antcall target="download-zip">
<param name="srcUrl" value="http://archive.apache.org/dist/commons/cli/binaries"/>
<param name="zipFile" 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.">
<antcall target="download-zip">
<param name="srcUrl" value="http://archive.apache.org/dist/commons/io/binaries"/>
<param name="zipFile" 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.">
<antcall target="download-zip">
<param name="srcUrl" value="http://guava-libraries.googlecode.com/files/"/>
<param name="zipFile" value="${guava.name}.zip"/>
<param name="srcJarPath" value="${guava.name}/${guava.name}.jar"/>
<param name="md5" value="b73fe1bb5f443993adcf8b274f6a48b2"/>
<param name="destJarFile" value="${lib.dir}/guava.jar"/>
</antcall>
<get src="http://www.apache.org/licenses/LICENSE-2.0" dest="${lib.dir}/guava-LICENSE.txt"/>
<delete dir="${download.dir}/temp/${guava.name}"/>
</target>
<!--
felix - for codegen of certain java source files
-->
<target name="felix-jar-check" description="Checks if felix.jar is in lib directory.">
<available file="${lib.dir}/org.apache.felix.framework-3.0.2.jar" property="felix.jar.exists"/>
</target>
<target name="felix-jar" depends="felix-jar-check" unless="felix.jar.exists"
description="Copies felix.jar to the lib directory.">
<antcall target="download-jar">
<param name="srcUrl" value="http://archive.apache.org/dist/felix"/>
<param name="srcJarFile" value="org.apache.felix.framework-3.0.2.jar"/>
<param name="destJarFile" value="${lib.dir}/org.apache.felix.framework-3.0.2.jar"/>
<param name="md5" value="d49b926d3f16321b95935119fd4b8db5"/>
</antcall>
<get src="http://archive.apache.org/dist/felix/LICENSE" dest="${lib.dir}/felix-LICENSE.txt"/>
</target>
<!--
closure - JS compiler, minimizer, etc.
-->
<target name="closure-jar-check" description="Checks if closure jar exists.">
<available file="${lib.dir}/google/closure-compiler/compiler.jar" property="closure.jar.exists" />
</target>
<target name="closure-jar" depends="closure-jar-check" unless="closure.jar.exists"
description="Copies the closure build jars.">
<mkdir dir="${lib.dir}/google/closure-compiler" />
<antcall target="download-zip">
<param name="srcUrl" value="http://closure-compiler.googlecode.com/files"/>
<param name="zipFile" value="compiler-20110615.zip"/>
<param name="sha1" value="7bece33b7535315143374f252955833164bc5b38"/>
</antcall>
<get src="http://www.apache.org/licenses/LICENSE-2.0" dest="${lib.dir}/google/closure-compiler/closure-LICENSE.txt"/>
<copy todir="${lib.dir}/google/closure-compiler">
<fileset dir="${download.dir}/temp">
<include name="${closure.name}.jar"/>
</fileset>
</copy>
<delete includeemptydirs="true">
<fileset dir="${download.dir}/temp" includes="**/*"/>
</delete>
</target>
</project>