RESTful httpclient for Ant

I need a RESTful httpclient for Ant.

None of the tasks related to the contribution work anymore.

Has anyone else combined Commons-HTTPClient and Ant yet?

+3
source share
4 answers

Try the Ant exec and curl task .

+3
source

I used CURL from ANT to POST files with the following macrodeck:

<pathconvert property="curl.path" targetos="windows">
    <path location="${lib.dir}/curl/curl.exe"/>
</pathconvert>
<macrodef name="post-file" description="Use Curl to post the file to the WEBDAV path">
    <attribute name="file"/>
    <attribute name="url" />    
    <attribute name="username" default="${username}" />
    <attribute name="password" default="${password}" />
    <sequential>
        <echo message="Using CURL to upload @{file} to @{url}" />
        <!--Execute curl to post the file to the URL -->
        <exec executable="${curl.path}">
            <arg value='-L'/>
            <arg value='-k'/>
            <arg value='-f'/>
            <arg value='-s'/>
            <arg value="--anyauth"/>
            <arg value="-u"/>
            <arg value="@{username}:@{password}"/>              
            <arg value="-T" />
            <arg value='"@{file}"' /> 
            <arg value='@{url}'/>  
        </exec>
    </sequential>
</macrodef>

Run the macro grandfather as follows:

<target name="test-upload">
        <post-file file="${file}" 
                   url="${url}" 
                   username="${username}" 
                   password="${password}" />
    </target>
+1
source
0

http post Antelope, , , .:/

0

Source: https://habr.com/ru/post/1734838/


All Articles