> OK, now that Ant1.6 has antlibs, it is time to think of the > next step: > auto download of antlibs and (perhaps) dependencies. > > 1. Possible requirements > > -allow users to specify the URLs of dependent antlibs
Why only AntLibs? Maybe resources in general (jars, AntLets, ...) > -allow teams to provide an override point that specifies their location of course :-) I wrote a snippet for the download :-) <project name="common-define-require"> <scriptdef name="require" language="javascript"> <attribute name="file"/> <attribute name="url"/> <![CDATA[ // If 'file' is not present, download it from 'url'. // Maybe you have to set the proxy before with <setproxy> f = new java.io.File(attributes.get("file")); if (!f.exists()) { url = new java.net.URL(attributes.get("url")); get = project.createTask("get"); get.setDest(f); get.setSrc(url); get.execute(); } ]]> </scriptdef> </project> <property name="ant.test.lib" value="ant-testutil.jar"/> <import file="${antcommon.dir}/define-require.xml"/> <require file="${ant.test.lib}" url="http://gump.covalent.net/jars/latest/ant/${ant.test.lib}"/> > -secure download -only files from trusted sources are fetched. - download the MD5 file and check for consistency Have that :-) But it´s longer so see at the buttom > -caching of downloads, global or per-user or per-project > -go through proxies > -allow antlib providers to move their files (handle redirects) > -allow antlib providers to mirror, by having a mirror file that lists > possible sources > -support private repositories (intranet/internet, https, > authenticated) > as well as public sources > -make it easy to publish an antlib, and register it in the > ant central list I had only a half ear on the thread, but Forrest a feature like "autodownload skin" which sounds like the whole stuff here ... > Anything else? Be open to plug in another kind of repo. Not only file based. Maybe a scm tool (cvs, ...). > > 2. What things implement this? What do Maven and Ruper do? Yep. Talk with them. Maybe we can get their code ... or decide not to do anything ... > 3. do we want to integrate this with ant, or have some more standalone > tool that can be used to keep a component repository up to date, a tool > with an ant task for use in a build file. A sort of apt-getfor apache > stuff... More something in the middle: an AntLib. Jan check-downloads.xml ------------------------------------------ <project default="main"> <taskdef resource="net/sf/antcontrib/antcontrib.properties"/> <property name="result.file" value="check-downloads-results.properties"/> <property file="check-downloads.properties"/> <property file="${result.file}"/> <target name="main"> <setproxy proxyHost="${proxy.host}" proxyPort="${proxy.port}"/> <foreach list="${file.list}" param="file" target="checkFile"/> </target> <target name="checkFile" depends="check.download,check.md5-1,check.md5-2" if="file"/> <target name="check.init"> <property name="zip.file" value="${file}"/> <property name="md5.file" value="${file}.md5"/> <condition property="md5-ok"><isset property="${zip.file}.isValid"/></condition> <condition property="download-ok"> <and> <available file="${dest.dir}/${zip.file}"/> <available file="${dest.dir}/${md5.file}"/> </and> </condition> </target> <target name="check.download" unless="download-ok" depends="check.init"> <echo>Download ${md5.file}</echo> <get src="${download.md5.dir}/${md5.file}" dest="${dest.dir}/${md5.file}"/> <echo>Download ${zip.file}</echo> <get src="${download.zip.dir}/${zip.file}" dest="${dest.dir}/${zip.file}"/> </target> <target name="check.md5-1" if="md5-ok" depends="check.init"> <echo>${zip.file}: just processed</echo> </target> <target name="check.md5-2" unless="md5-ok" depends="check.init"> <trycatch><try> <!-- what is the valid md5 value specified in the md5 file --> <loadfile srcFile="${md5.file}" property="md5.valid"> <filterchain> <striplinebreaks/> <tokenfilter> <stringtokenizer/> <replaceregex pattern="${zip.file}" replace=""/> </tokenfilter> <tokenfilter> <trim/> </tokenfilter> </filterchain> </loadfile> <!-- what is the actual md5 value --> <checksum file="${zip.file}" property="md5.actual"/> <!-- compare them --> <condition property="md5.isValid"> <equals arg1="${md5.valid}" arg2="${md5.actual}"/> </condition> <property name="md5.isValid" value="false"/> <!-- print the result --> <if> <istrue value="${md5.isValid}"/> <then> <echo>${zip.file}: ok</echo> <echo file="${result.file}" append="true" message="${zip.file}.isValid=true${line.separator}"/> </then> <else> <echo>${zip.file}: Wrong MD5 checksum !!!</echo> <echo>- expected: ${md5.valid}</echo> <echo>- actual : ${md5.actual}</echo> <move file="${zip.file}" tofile="${zip.file}.wrong-checksum"/> </else> </if> </try><catch/></trycatch> </target> </project> check-downloads.properties -------------------------- download.zip.dir=ftp://sunsite.informatik.rwth-aachen.de/pub/mirror/eclipse/ S-3.0M5-200311211210/ download.md5.dir=ftp://sunsite.informatik.rwth-aachen.de/pub/mirror/eclipse/ S-3.0M5-200311211210/checksum/ dest.dir=. file.list=eclipse-Automated-Tests-3.0M5.zip,eclipse-FTP-WebDAV-3.0M5.zip,ecl ipse-JDT-3.0M5.zip,eclipse-SDK-3.0M5-win32.zip,eclipse-examples-3.0M5-win32. zip,eclipse-examples-3.0M5.zip,eclipse-platform-3.0M5-win32.zip proxy.host=A011-34 proxy.port=8080