尝试从 ant 运行 码头时出错:"failed to create task or type jetty.run"

Error while trying to run jetty from ant: "failed to create task or type jetty.run"

我收到以下错误:

Buildfile: ...\jetty.xml
jetty.run:

BUILD FAILED
...\jetty.xml:29: Problem: failed to create task or type jetty.run
Cause: The name is undefined.
Action: Check the spelling.
Action: Check that any custom tasks/types have been declared.
Action: Check that any <presetdef>/<macrodef> declarations have taken place.

Total time: 617 milliseconds

when 运行 ant jetty.run 在此:

<path id="jetty.plugin.classpath">
    <fileset dir="./lib/jetty" includes="*.jar" />
</path>

<taskdef classpathref="jetty.plugin.classpath" resource="tasks.properties" loaderref="jetty.loader" />
<typedef name="selectChannelConnector" classname="org.eclipse.jetty.server.nio.SelectChannelConnector" classpathref="jetty.plugin.classpath" loaderref="jetty.loader" />

<pathconvert property="classpathProp" refid="jetty.plugin.classpath" />
<target name="echo">
    <echo>Classpath is ${classpathProp}</echo>
</target>

<target name="jetty-run">
    <jetty>
        <connectors>
            <selectChannelConnector port="8080" />
        </connectors>
    </jetty>
</target>

<target name="jetty.run">
    <jetty.run stopPort="8080" stopKey="stopKey123">
    </jetty.run>
</target>

<target name="jetty.stop">
    <jetty.stop stopPort="8080" stopKey="stopKey123" stopWait="10" />
</target>

上述目标 (jetty.run) 在语法上与文档 here 相同(see/search for stopping)。为什么 jetty.run 不起作用,而 jetty-run 起作用?

jetty-run 输出:

Buildfile: ...\jetty.xml
jetty-run:
    [jetty] Configuring Jetty for project: system-tests
    [jetty] 2015-04-22 17:16:46.603:INFO:oejs.Server:jetty-8.1.16.v20140903
    [jetty] 2015-04-22 17:16:46.728:WARN:oejsh.RequestLogHandler:!RequestLog
    [jetty] 2015-04-22 17:16:46.884:INFO:oejs.AbstractConnector:Started SelectChannelConnector@0.0.0.0:8080

虽然 Jetty 9 docs use jetty.run and jetty.stop, this guide 没有。很明显,它与 <jetty.run ...><jetty ...> 有关,但我目前无法解释原因并且无法让 <jetty.run ...><jetty.stop ...> 工作。

类路径:

[echo] Classpath is 
...\com.sun.el-2.2.0.v201108011116.jar
...\javax.activation-1.1.0.v201105071233.jar
...\javax.annotation-1.1.0.v201108011116.jar
...\javax.el-2.2.0.v201108011116.jar
...\javax.mail.glassfish-1.4.1.v201005082020.jar
...\javax.servlet.jsp-2.2.0.v201112011158.jar
...\javax.servlet.jsp.jstl-1.2.0.v201105211821.jar
...\javax.transaction-1.1.1.v201105210645.jar
...\jetty-ajp-8.1.16.v20140903.jar
...\jetty-annotations-8.1.16.v20140903.jar
...\jetty-ant-8.1.16.v20140903.jar
...\jetty-client-8.1.16.v20140903.jar
...\jetty-continuation-8.1.16.v20140903.jar
...\jetty-deploy-8.1.16.v20140903.jar
...\jetty-http-8.1.16.v20140903.jar
...\jetty-io-8.1.16.v20140903.jar
...\jetty-jmx-8.1.16.v20140903.jar
...\jetty-jndi-8.1.16.v20140903.jar
...\jetty-monitor-8.1.16.v20140903.jar
...\jetty-overlay-deployer-8.1.16.v20140903.jar
...\jetty-plus-8.1.16.v20140903.jar
...\jetty-policy-8.1.16.v20140903.jar
...\jetty-rewrite-8.1.16.v20140903.jar
...\jetty-security-8.1.16.v20140903.jar
...\jetty-server-8.1.16.v20140903.jar
...\jetty-servlet-8.1.16.v20140903.jar
...\jetty-servlets-8.1.16.v20140903.jar
...\jetty-util-8.1.16.v20140903.jar
...\jetty-webapp-8.1.16.v20140903.jar
...\jetty-websocket-8.1.16.v20140903.jar
...\jetty-xml-8.1.16.v20140903.jar
...\org.apache.jasper.glassfish-2.2.2.v201112011158.jar
...\org.apache.taglibs.standard.glassfish-1.2.0.v201112081803.jar
...\org.eclipse.jdt.core-3.7.1.jar
...\org.objectweb.asm-3.1.0.v200803061910.jar
...\servlet-api-3.0.jar
...\spdy-core-8.1.16.v20140903.jar
...\spdy-jetty-8.1.16.v20140903.jar
...\spdy-jetty-http-8.1.16.v20140903.jar

jetty.run 在这种情况下不起作用而 jetty-run 的原因是因为目标 jetty.run 使用的任务 <jetty.run ... 是在版本 9 中添加的jetty-ant 任务,正如添加它的开发人员所述 (see this jetty-dev mailing list msg)。

我用版本 9 的 jetty-ant 尝试了版本 9 的码头,目标 jetty.run 按预期工作。我还尝试了 jetty 9 和 jetty-ant 8,但得到了这个:

BUILD FAILED
...\build.xml:9: typedef class org.eclipse.jetty.server.ServerConnector cannot be found