指定单个jar的类路径

时间:2021-04-24 06:27:56

I was trying to setup Selenium Grid and instead of using ant configuration available with Selenium Grid download I continued using my ant configuration.

我试图设置Selenium Grid,而不是使用Selenium Grid下载的ant配置,我继续使用我的ant配置。

For ant users who are not aware of Selenium Gird - it is a java lib which lets UI tests be distributed on different system specified in one "yml" file. Herein I can start one hub machine and which in turn can ctrl browser on different slave machines.

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

Ant configuration which I was using -

我正在使用的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>

Now while using this configuration, my hub always starts with "yml" file which is available in "selenium-grid-hub-standalone-1.0.8.jar" instead of considering the "yml" file which I defined on my project root.

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

Following this I changed the ant configuration as following, which is available in Selenium Grid distribution -

在此之后,我将蚂蚁配置更改为以下内容,可在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>

And now when I start the hub, it consider the "yml" file which is defined in my project root and not the one which is available in "selenium-grid-hub-standalone-1.0.8.jar" file.

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

I am no ant aficionado but I find both configuration almost similar, wherein first configuration has dependency on target while other uses the "pathid". Any one who could throw light on this?

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

1 个解决方案

#1


0  

I think the difference is that the classpath in the second example includes your project root dir:

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

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

whereas the first one does not.

而第一个没有。

#1


0  

I think the difference is that the classpath in the second example includes your project root dir:

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

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

whereas the first one does not.

而第一个没有。