| <project name="get dependent zips/tar.gz files for running plugin project tests" default="getBundle"> |
| <!-- these scripts are called by another script, such as getDependencies.xml or getTestDependencies.xml --> |
| |
| <target name="getBundle"> |
| <!-- <echo message="getDependenciesHelper.xml: basedir = ${basedir}"/> --> |
| <!-- requires the following params to be set --> |
| <!-- |
| <property name="url"/> [url to download and unpack, eg., http://.../.../foo.zip] |
| <property name="file"/> [filename of the url to download and unpack, eg., foo.zip] |
| --> |
| <!-- get the zip or tar.gz from the remote server if it's not already been downloaded --> |
| <available file="${downloadsDir}/${file}" property="theZipExists"/> |
| <antcall target="downloadFile"> |
| <param name="theFile" value="${file}"/> |
| <param name="theURL" value="${url}"/> |
| </antcall> |
| </target> |
| <target name="unpackBundle"> |
| <!-- requires the following params to be set --> |
| <!-- |
| <property name="file"/> [filename of the url to download and unpack, eg., foo.zip] |
| <property name="unpackDest"/> [path where to unpack, eg., ${buildDirectory}/.. or .] |
| <property name="isUnpackedFile"/> [filename and path for which if it exists we can assume that the unpack has already occurred, eg., ./plugins/org.eclipse.foo/plugin.xml] |
| --> |
| <sequential> |
| <!-- check if we've done this already --> |
| <available property="isUnpacked" file="${isUnpackedFile}"/> |
| |
| <!-- check the bundle type and unpack it accordingly --> |
| <condition property="isAZip"><contains string="${file}" substring=".zip" /></condition> |
| <condition property="isATar"><contains string="${file}" substring=".tar.gz" /></condition> |
| <antcall target="unzipFile"><param name="theFile" value="${downloadsDir}/${file}"/><param name="theDir" value="${unpackDest}"/></antcall> |
| <antcall target="untarFile"><param name="theFile" value="${downloadsDir}/${file}"/><param name="theDir" value="${unpackDest}"/></antcall> |
| |
| <!-- reset these properties for the next loop --> |
| <condition property="isAZip"><contains string="a" substring="z"/></condition> |
| <condition property="isATar"><contains string="a" substring="z"/></condition> |
| <condition property="isUnpacked"><contains string="a" substring="z"/></condition> |
| </sequential> |
| </target> |
| |
| <!-- helper methods --> |
| <target name="downloadFile" unless="theZipExists"><get src="${theURL}" dest="${downloadsDir}/${theFile}" usetimestamp="true"/><touch file="${downloadsDir}/${theFile}"/></target> |
| <target name="unzipFile" unless="isUnpacked" if="isAZip"><unzip src="${theFile}" dest="${theDir}" overwrite="true" /></target> |
| <target name="untarFile" unless="isUnpacked" if="isATar"><untar src="${theFile}" dest="${theDir}" overwrite="true" compression="gzip"/></target> |
| <target name="unpackJar" unless="isUnpacked" if="jarExists"><unjar src="${theJar}" dest="${theDir}" overwrite="true"/></target> |
| </project> |