开发者

Issue with proxy while running Ant script

I'm developing an Ant script for my project purposes and figured out that my proxy causes problem for me. Here is the simplest example from Apache documentation of 'copy' task:

=================== build.xml =====================
<project default="simplestCopy">
    <property name="test.dir" value="${basedir}/test/" />

    <target name="simplestCopy">
        <mkdir dir="${test.dir}" />
        <copy todir="${test.dir}" flatten="true">
            <resources>
                <url url="http://ant.apache.org/index.html"/>
            </resou开发者_如何转开发rces>
        </copy>
    </target>
</project>

I've got next error:

d:\temp>ant
Buildfile: d:\temp\build.xml

simplestCopy:
java.net.ConnectException: Connection refused: connect

BUILD FAILED
d:\temp\build.xml:7: Warning: Could not find resource url "http://ant.apache.org/index.html" to copy.

I've tried to set kind of

<property name="java.net.useSystemProxies" value="true" />

And define this property in command line

d:\temp>ant -Djava.net.useSystemProxies=true -verbose

But got same error:

d:\temp>ant -Djava.net.useSystemProxies=true -verbose
Apache Ant version 1.8.1 compiled on April 30 2010
Trying the default build file: build.xml
Buildfile: d:\temp\build.xml
Detected Java version: 1.6 in: c:\ProgramFiles\Java\jdk1.6.0_24\jre
Detected OS: Windows XP
parsing buildfile d:\temp\build.xml with URI = file:/d:/temp/build.xml
Project base dir set to: d:\temp
parsing buildfile jar:file:/C:/ProgramFiles/Java/apache-ant-1.8.1/lib/ant.jar!/org/apache/tools/ant/antlib.xml with URI = jar:file:/C:/ProgramFiles/Java/apache-ant-1.8.1/lib/ant.jar!/org/apache/tools/ant/antlib.xml from a zip file
Build sequence for target(s) `simplestCopy' is [simplestCopy]
Complete build sequence is [simplestCopy, ]

simplestCopy:
    [mkdir] Skipping d:\temp\test because it already exists.
java.net.ConnectException: Connection refused: connect

BUILD FAILED
d:\temp\build.xml:7: Warning: Could not find resource url "http://ant.apache.org/index.html" to copy.
        at org.apache.tools.ant.taskdefs.Copy.execute(Copy.java:487)
        at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
        at org.apache.tools.ant.Task.perform(Task.java:348)
        at org.apache.tools.ant.Target.execute(Target.java:390)
        at org.apache.tools.ant.Target.performTasks(Target.java:411)
        at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1397)
        at org.apache.tools.ant.Project.executeTarget(Project.java:1366)
        at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
        at org.apache.tools.ant.Project.executeTargets(Project.java:1249)
        at org.apache.tools.ant.Main.runBuild(Main.java:801)
        at org.apache.tools.ant.Main.startAnt(Main.java:218)
        at org.apache.tools.ant.launch.Launcher.run(Launcher.java:280)
        at org.apache.tools.ant.launch.Launcher.main(Launcher.java:109)

Total time: 1 second

Any ideas how to fix?

Thanks for help...


Use the setproxy task: http://ant.apache.org/manual/Tasks/setproxy.html


I started the tomcat server and then issue the command and it works

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜