Проблема с прокси при запуске скрипта Ant - PullRequest
0 голосов
/ 24 февраля 2011

Я разрабатываю сценарий Ant для целей своего проекта и выяснил, что мой прокси вызывает проблемы для меня.Вот простейший пример из документации Apache о задаче 'copy':

=================== 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"/>
            </resources>
        </copy>
    </target>
</project>

У меня следующая ошибка:

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.

Я пытался установить вид

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

И определить это свойство в командной строке

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

Но получил ту же ошибку:

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

Есть идеи как исправить?
Спасибо за помощь ...

Ответы [ 2 ]

4 голосов
/ 24 февраля 2011

Используйте задачу setproxy: http://ant.apache.org/manual/Tasks/setproxy.html

0 голосов
/ 26 января 2012

Я запустил сервер Tomcat, а затем выдал команду, и она работает

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...