I gave up on the built-in HTTP Tasks and used the BSF support to create
a 'simple' upload script that using the Apache HttpClient classes:
In my build.xml
<target name="upload">
<description>
Uses the HTTP PUT method to upload several files to a WebDAV
server(s)
</description>
<!-- NOTE: this task depends on having the js.jar file
from the Mozilla Rhino project in you ant/lib directory
(and also the commons-http libs). -->
<property name="xml.dir" value="some/directory"/>
<script language="javascript" src="upload.js"/>
</target>
In the script.js file:
importClass(java.io.File);
importClass(java.io.FileInputStream);
importClass(Packages.org.apache.commons.httpclient.HttpClient);
importClass(Packages.org.apache.commons.httpclient.UsernamePasswordCredentials);
importClass(Packages.org.apache.commons.httpclient.methods.PutMethod);
var srcDir = new File(project.getProperty("xml.dir"));
var style = project.getProperty("build.style");
var files = srcDir.listFiles();
var echo = xview_skins.createTask("echo");
var user = project.getProperty("svn.user");
var password = project.getProperty("svn.password");
var client = new HttpClient();
client.getState().setCredentials(null, null, new
UsernamePasswordCredentials(user, password));
for (var i = 0; i < files.length; i++) {
if (files[i].isFile()) {
var put = new PutMethod('http://' + style +
'.svn.ipov.net/svn/stage/' + files[i].getName());
put.setRequestBody( new FileInputStream(files[i]) );
client.executeMethod(put);
put = new PutMethod('http://' + style +
'.svn.ipov.net/svn/_live/' + files[i].getName());
put.setRequestBody( new FileInputStream(files[i]) );
client.executeMethod(put);
}
}
-----Ursprüngliche Nachricht-----
Von: Ivan Ivanov [mailto:[EMAIL PROTECTED]
Gesendet: Freitag, 1. Juli 2005 23:02
An: user@ant.apache.org
Betreff: HTTP tasks
Dear Colleagues,
I am looking for an Ant task that implements HTTP PUT method
so that I can upload files to a web server. Is there such a
task or should I write it myself?
Also, while I was googling for it, I noticed that there is a
proposal in Ant for http tasks, located at [1], that claim
they will support basic http requests.
I would like to know what is their status. Are they planned to
be part of Ant distribution at some time and if so when to expect them?
Regards
Ivan
[1]http://cvs.apache.org/viewcvs.cgi/ant/proposal/sandbox/httptasks/
--
Robert r. Sanders
Chief Technologist
iPOV
(334) 821-5412
www.ipov.net
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]