【问题标题】:Specifying class path for individual jar为单个 jar 指定类路径
【发布时间】:2011-06-24 16:01:22
【问题描述】:

我试图设置 Selenium Grid,但我没有使用 Selenium Grid 下载提供的 ant 配置,而是继续使用我的 ant 配置。

对于不了解 Selenium Gird 的 ant 用户 - 它是一个 java 库,可让 UI 测试分布在一个“yml”文件中指定的不同系统上。在这里,我可以启动一台集线器机器,然后它可以在不同的从机上ctrl浏览器。

我使用的 Ant 配置 -

<target name="setClassPath">
    <path id="classpath_jars">
        <fileset dir="${lib.dir}" includes="*.jar"/>
    </path>
    <pathconvert pathsep=":" property="test.classpath"
        refid="classpath_jars" />
</target>

<target name="launch-hub" description="Launch Selenium Hub" depends="setClassPath">
    <java classname="com.thoughtworks.selenium.grid.hub.HubServer" 
        classpathref="classpath_jars" 
        fork="true" 
        failonerror="true">

        <sysproperty key="http.proxyHost" value="${http.proxyHost}" />
        <sysproperty key="http.proxyPort" value="${http.proxyPort}" />
        <sysproperty key="https.proxyHost" value="${https.proxyHost}" />
        <sysproperty key="https.proxyPort" value="${https.proxyPort}" />

    </java>
 </target>

现在在使用此配置时,我的集线器始终以“selenium-grid-hub-standalone-1.0.8.jar”中可用的“yml”文件开头,而不是考虑我在我的项目根目录。

在此之后,我将 ant 配置更改如下,可在 Selenium Grid 发行版中使用 -

<path id="hub.classpath">
    <pathelement path="${basedir}/"/>
    <fileset dir="${basedir}/lib">
        <include name="selenium-grid-hub-standalone-1.0.8.jar"/>
    </fileset>
</path>

<target name="launch-hub" description="Launch Selenium Hub">
    <java classname="com.thoughtworks.selenium.grid.hub.HubServer"
          classpathref="hub.classpath"
          fork="true"
          failonerror="true" >

        <sysproperty key="http.proxyHost" value="${http.proxyHost}"/>
        <sysproperty key="http.proxyPort" value="${http.proxyPort}"/>
        <sysproperty key="https.proxyHost" value="${https.proxyHost}"/>
        <sysproperty key="https.proxyPort" value="${https.proxyPort}"/>
    </java>
</target>

现在,当我启动集线器时,它会考虑在我的项目根目录中定义的“yml”文件,而不是“selenium-grid-hub-standalone-1.0.8.jar”文件中可用的文件。

我不是蚂蚁爱好者,但我发现两种配置几乎相似,其中第一个配置依赖于目标,而其他配置使用“pathid”。任何人都可以阐明这一点?

【问题讨论】:

    标签: java ant selenium-grid


    【解决方案1】:

    我认为区别在于第二个示例中的类路径包含您的项目根目录:

    <pathelement path="${basedir}/"/>
    

    而第一个没有。

    【讨论】:

    • 实际上属性 lib.dir 被定义为 - 因此它有 basedir 的引用,我可以发布整个构建, 但这会让它变得冗长
    • 但是${basedir} 本身不在第一个示例中的类路径上,对吧?这是您要使用的 yml 文件所在的目录,如果我理解的话。
    • 我不是,但你这么说真好 :)
    猜你喜欢
    • 2011-08-31
    • 2010-10-03
    • 2012-07-13
    • 2013-10-06
    • 2012-02-06
    • 2019-06-27
    • 2023-03-04
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多