当前位置: 首页 > 知识库问答 >
问题:

Ant<javac>Jenkins中的“包不存在”错误

邢晗日
2023-03-14

当我尝试在 Jenkins 上编译我的项目时,我收到一条错误消息

建筑xml文件:

<project basedir="." default="build" name="EnergieAutoTest">
    <property environment="env"/>
    <property name="lib.location" value="C:\lib"/>
    <property name="TestAutomationLibrary.location" value="../TestAutomationLibrary"/>
    <property name="ECLIPSE_HOME" value="../../../../Program Files (x86)/IBM/SDP"/>
    <property name="junit.output.dir" value="junit"/>
    <property name="TestAutomationCommon.location" value="../TestAutomationCommon"/>
    <property name="BrowserCompatibilityLib.location" value="../BrowserCompatibilityLib"/>
    <property name="BrokerExtranetLib.location" value="C:/Users/fzs/.jenkins/workspace/Automation test Auto/BrokerExtranetLib/src/com/economical/test/brokerextranetlib/pageobjects"/>
    <property name="EnergieAutoLib.location" value="../EnergieAutoLib"/>
    <property name="debuglevel" value="source,lines,vars"/>
    <property name="target" value="1.7"/>
    <property name="source" value="1.7"/>
    <path id="TestAutomationCommon.classpath">
        <pathelement location="${TestAutomationCommon.location}/bin"/>
        <pathelement location="${lib.location}/apache/jakarta/commons/io/1.3.1/commons-io.jar"/>
        <pathelement location="${lib.location}/sun/javamail/1.4/mail.jar"/>
        <pathelement location="${TestAutomationLibrary.location}/DOWNLOADED/log4j/log4j-api-2.1.jar"/>
        <pathelement location="${TestAutomationLibrary.location}/DOWNLOADED/log4j/log4j-core-2.1.jar"/>
        <pathelement location="${lib.location}/apache/xml/serializer/2.7.1/serializer.jar"/>
        <pathelement location="${lib.location}/google/guava/18.0/guava.jar"/>
        <pathelement location="${lib.location}/apache/httpcomponents/httpclient/4.4.1/httpclient.jar"/>
        <pathelement location="${lib.location}/apache/httpcomponents/httpcore/4.4.1/httpcore.jar"/>
        <pathelement location="${lib.location}/hamcrest/1.3/hamcrest-all.jar"/>
        <pathelement location="${lib.location}/apache/jakarta/commons/codec/1.9/commons-codec.jar"/>
        <pathelement location="${lib.location}/eclipselink/moxy/2.5.0/org.eclipse.persistence.core.jar"/>
        <pathelement location="${lib.location}/selenium/2.43.1/selenium-java.jar"/>
        <pathelement location="${TestAutomationLibrary.location}/DOWNLOADED/seleniumsupport/json-20080701.jar"/>
        <pathelement location="${lib.location}/json-lib/2.4/json-lib.jar"/>
        <pathelement location="${lib.location}/apache/jakarta/commons/logging/1.1.3/commons-logging.jar"/>
        <pathelement location="${TestAutomationLibrary.location}/DOWNLOADED/seleniumsupport/commons-exec-1.1.jar"/>
        <pathelement location="${lib.location}/freemarker/2.3.20/freemarker-gae.jar"/>
        <pathelement location="${lib.location}/sun/validation/1.0/validation-api.jar"/>
        <pathelement location="${lib.location}/antlr/3.1.1/antlr-runtime.jar"/>
        <pathelement location="${lib.location}/apache/xml/xmlbeans/2.3.0/xmlbeans.jar"/>
        <pathelement location="${lib.location}/dom4j/1.6.1/dom4j.jar"/>
        <pathelement location="${lib.location}/apache/poi/3.9/poi-ooxml.jar"/>
        <pathelement location="${lib.location}/apache/poi/3.9/poi.jar"/>
        <pathelement location="${lib.location}/apache/poi/3.9/poi-ooxml-schemas.jar"/>
        <pathelement location="${lib.location}/eclipselink/moxy/2.5.0/org.eclipse.persistence.moxy.jar"/>
        <pathelement location="${lib.location}/ibm/mq/7.0.1.6/com.ibm.mq.pcf.jar"/>
        <pathelement location="${TestAutomationLibrary.location}/DOWNLOADED/mqsupport/connector.jar"/>
        <pathelement location="${TestAutomationLibrary.location}/DOWNLOADED/mqsupport/mqcontext.jar"/>
        <pathelement location="${lib.location}/ibm/mq/7.0.1.6/com.ibm.mq.jar"/>
        <pathelement location="${lib.location}/ibm/mq/7.0.1.6/com.ibm.mqjms.jar"/>
        <pathelement location="${TestAutomationLibrary.location}/DOWNLOADED/mqsupport/jms.jar"/>
        <pathelement location="${lib.location}/ibm/mq/7.0.1.6/com.ibm.mq.headers.jar"/>
        <pathelement location="${lib.location}/ibm/mq/7.0.1.6/com.ibm.mq.defaultconfig.jar"/>
        <pathelement location="${lib.location}/ibm/mq/7.0.1.6/com.ibm.mq.commonservices.jar"/>
        <pathelement location="${lib.location}/ibm/mq/7.0.1.6/com.ibm.mq.jmqi.jar"/>
        <pathelement location="${lib.location}/ibm/mq/6.0.2.4/dhbcore.jar"/>
        <pathelement location="${lib.location}/apache/jakarta/commons/beanutils/1.7.0/commons-beanutils.jar"/>
        <pathelement location="${TestAutomationLibrary.location}/DOWNLOADED/commons-lang3-3.3.2.jar"/>
        <pathelement location="${lib.location}/junit/4.12/junit.jar"/>
        <pathelement location="${lib.location}/slf4j/1.5.5/slf4j-api.jar"/>
        <pathelement location="${lib.location}/slf4j/1.5.5/slf4j-simple.jar"/>
    </path>
    <path id="BrokerExtranetLib.classpath">
        <pathelement location="${BrokerExtranetLib.location}/bin"/>
        <path refid="TestAutomationCommon.classpath"/>
        <pathelement location="${TestAutomationLibrary.location}/DOWNLOADED/log4j/log4j-api-2.1.jar"/>
        <pathelement location="${TestAutomationLibrary.location}/DOWNLOADED/log4j/log4j-core-2.1.jar"/>
        <pathelement location="${lib.location}/selenium/2.43.1/selenium-java.jar"/>
        <pathelement location="${lib.location}/google/guava/18.0/guava.jar"/>
    </path>
    <path id="BrowserCompatibilityLib.classpath">
        <pathelement location="${BrowserCompatibilityLib.location}/bin"/>
        <path refid="TestAutomationCommon.classpath"/>
        <pathelement location="${lib.location}/google/guava/18.0/guava.jar"/>
        <pathelement location="${lib.location}/selenium/2.43.1/selenium-java.jar"/>
        <pathelement location="${TestAutomationLibrary.location}/DOWNLOADED/log4j/log4j-api-2.1.jar"/>
        <pathelement location="${TestAutomationLibrary.location}/DOWNLOADED/log4j/log4j-core-2.1.jar"/>
        <pathelement location="${lib.location}/apache/jakarta/commons/io/1.3.1/commons-io.jar"/>
    </path>
    <path id="EnergieAutoLib.classpath">
        <path refid="BrowserCompatibilityLib.classpath"/>
        <pathelement location="${EnergieAutoLib.location}/bin"/>
        <path refid="TestAutomationCommon.classpath"/>
        <pathelement location="${lib.location}/google/guava/18.0/guava.jar"/>
        <pathelement location="${lib.location}/selenium/2.43.1/selenium-java.jar"/>
        <pathelement location="${lib.location}/junit/4.12/junit.jar"/>
        <pathelement location="${TestAutomationLibrary.location}/DOWNLOADED/log4j/log4j-api-2.1.jar"/>
        <pathelement location="${TestAutomationLibrary.location}/DOWNLOADED/log4j/log4j-core-2.1.jar"/>
        <path refid="BrokerExtranetLib.classpath"/>
        <pathelement location="${lib.location}/apache/jakarta/commons/io/1.3.1/commons-io.jar"/>
    </path>
    <path id="EnergieAutoTest.classpath">
        <pathelement location="bin"/>
        <path refid="TestAutomationCommon.classpath"/>
        <pathelement location="${lib.location}/google/guava/18.0/guava.jar"/>
        <pathelement location="${lib.location}/selenium/2.43.1/selenium-java.jar"/>
        <pathelement location="${lib.location}/junit/4.12/junit.jar"/>
        <pathelement location="${TestAutomationLibrary.location}/DOWNLOADED/log4j/log4j-api-2.1.jar"/>
        <pathelement location="${TestAutomationLibrary.location}/DOWNLOADED/log4j/log4j-core-2.1.jar"/>
        <path refid="BrokerExtranetLib.classpath"/>
        <path refid="EnergieAutoLib.classpath"/>
        <path refid="BrowserCompatibilityLib.classpath"/>
    </path>
    <target name="init">
        <mkdir dir="bin"/>
        <copy includeemptydirs="false" todir="bin">
            <fileset dir="src">
                <exclude name="**/*.launch"/>
                <exclude name="**/*.java"/>
            </fileset>
        </copy>
    </target>
    <target name="clean">
        <delete dir="bin"/>
    </target>
    <target depends="clean" name="cleanall">
        <ant antfile="build.xml" dir="${TestAutomationCommon.location}" inheritAll="false" target="clean"/>
        <ant antfile="build.xml" dir="${BrowserCompatibilityLib.location}" inheritAll="false" target="clean"/>
        <ant antfile="build.xml" dir="${BrokerExtranetLib.location}" inheritAll="false" target="clean"/>
        <ant antfile="build.xml" dir="${EnergieAutoLib.location}" inheritAll="false" target="clean"/>
    </target>
    <target depends="build-subprojects,build-project" name="build"/>
    <target name="build-subprojects">
        <ant antfile="build.xml" dir="${TestAutomationCommon.location}" inheritAll="false" target="build-project">
            <propertyset>
                <propertyref name="build.compiler"/>
            </propertyset>
        </ant>
        <ant antfile="build.xml" dir="${BrowserCompatibilityLib.location}" inheritAll="false" target="build-project">
            <propertyset>
                <propertyref name="build.compiler"/>
            </propertyset>
        </ant>
        <ant antfile="build.xml" dir="${BrokerExtranetLib.location}" inheritAll="false" target="build-project">
            <propertyset>
                <propertyref name="build.compiler"/>
            </propertyset>
        </ant>
        <ant antfile="build.xml" dir="${EnergieAutoLib.location}" inheritAll="false" target="build-project">
            <propertyset>
                <propertyref name="build.compiler"/>
            </propertyset>
        </ant>
    </target>   

    <target name="Compile">
        <mkdir dir="${classes.dir}"/>
        <javac srcdir="${src}" destdir="${bin}"/>
    </target>

    <target depends="init" name="build-project">
        <echo message="${ant.project.name}: ${ant.file}"/>
        <javac debug="true" debuglevel="${debuglevel}" destdir="bin" source="${source}" target="${target}">
            <src path="src"/>
            <classpath refid="EnergieAutoTest.classpath"/>
        </javac>
    </target>
    <target description="Build all projects which reference this project. Useful to propagate changes." name="build-refprojects"/>
    <target description="copy Eclipse compiler jars to ant lib directory" name="init-eclipse-compiler">
        <copy todir="${ant.library.dir}">
            <fileset dir="${ECLIPSE_HOME}/plugins" includes="org.eclipse.jdt.core_*.jar"/>
        </copy>
        <unzip dest="${ant.library.dir}">
            <patternset includes="jdtCompilerAdapter.jar"/>
            <fileset dir="${ECLIPSE_HOME}/plugins" includes="org.eclipse.jdt.core_*.jar"/>
        </unzip>
    </target>
    <target description="compile project with Eclipse compiler" name="build-eclipse-compiler">
        <property name="build.compiler" value="org.eclipse.jdt.core.JDTCompilerAdapter"/>
        <antcall target="build"/>
    </target>
    <target name="AlbertaCompany1">
        <mkdir dir="${junit.output.dir}"/>
        <junit fork="yes" printsummary="withOutAndErr">
            <formatter type="xml"/>
            <test name="com.economical.test.energieauto.testcases.AlbertaCompany1" todir="${junit.output.dir}"/>
            <classpath refid="EnergieAutoTest.classpath"/>
        </junit>
    </target>
    <target name="AlbertaCompany5">
        <mkdir dir="${junit.output.dir}"/>
        <junit fork="yes" printsummary="withOutAndErr">
            <formatter type="xml"/>
            <test name="com.economical.test.energieauto.testcases.AlbertaCompany5" todir="${junit.output.dir}"/>
            <classpath refid="EnergieAutoTest.classpath"/>
        </junit>
    </target>
    <target name="CompleteSmoke">
        <mkdir dir="${junit.output.dir}"/>
        <junit fork="yes" printsummary="withOutAndErr">
            <formatter type="xml"/>
            <test name="com.economical.test.energieauto.testsuite.CompleteSmoke" todir="${junit.output.dir}"/>
            <classpath refid="EnergieAutoTest.classpath"/>
        </junit>
    </target>
    <target name="OntarioCompany1">
        <mkdir dir="${junit.output.dir}"/>
        <junit fork="yes" printsummary="withOutAndErr">
            <formatter type="xml"/>
            <test name="com.economical.test.energieauto.testcases.OntarioCompany1" todir="${junit.output.dir}"/>
            <classpath refid="EnergieAutoTest.classpath"/>
        </junit>
    </target>
    <target name="OntarioCompany4">
        <mkdir dir="${junit.output.dir}"/>
        <junit fork="yes" printsummary="withOutAndErr">
            <formatter type="xml"/>
            <test name="com.economical.test.energieauto.testcases.OntarioCompany4" todir="${junit.output.dir}"/>
            <classpath refid="EnergieAutoTest.classpath"/>
        </junit>
    </target>
    <target name="QuebecNYear">
        <mkdir dir="${junit.output.dir}"/>
        <javac srcdir="src\com\economical\test\energieauto\testcases" destdir="bin\com\economical\test\energieauto\testcases"/>
        <junit fork="yes" printsummary="withOutAndErr">
            <formatter type="xml"/>
            <test name="com.economical.test.energieauto.testcases.QuebecNYear" todir="${junit.output.dir}"/>
            <jvmarg line="-Dapplication=EnergieAuto"/>
            <classpath refid="EnergieAutoTest.classpath"/>
        </junit>
    </target>

    <target name="junitreport">
        <junitreport todir="${junit.output.dir}">
            <fileset dir="${junit.output.dir}">
                <include name="TEST-*.xml"/>
            </fileset>
            <report format="frames" todir="${junit.output.dir}"/>
        </junitreport>
    </target>
</project>

然后是 Jenkins 上的控制台输出:

[javac]编译1个源文件到C:\用户\fzs.jenkins\工作空间\自动化测试自动\EnergieAutoTest\bin\com\经济\测试\energieauto\testcase

[javac]C:\ Users \ fzs . Jenkins \ workspace \ Automation test Auto \ EnergieAutoTest \ src \ com \ economic \ test \ energieauto \ test cases \ quebecnyear . Java:32:错误:包com . economic . test . brokerextrantelib . page objects不存在

[javac]进口com.economical.test.brokerextranetlib.pageobjects.HomePage;

这是我的Java类QuebecNyear,第32行:

import com.economical.test.brokerextranetlib.pageobjects.HomePage;

共有1个答案

经骁
2023-03-14

以下...

<javac srcdir="src\com\economical\test\energieauto\testcases" destdir="bin\com\economical\test\energieauto\testcases"/>

...应该成为...

<javac srcdir="src\com\economical\test\energieauto\testcases" destdir="bin\com\economical\test\energieauto\testcases">
    <classpath refid="EnergieAutoTest.classpath"/>
</javac>

 类似资料:
  • 我试图编译我的java文件'check 4PrimeTest.java'使用以下命令的命令提示符: javac-classpath.:朱尼特。jar CHECK4优先测试。JAVA 我得到以下错误: 错误:包junit。框架不存在导入junit。框架。*; 我不确定为什么会出现这个错误,因为我已经导入了junit。框架。*在我的节目里。 下面是我的代码:

  • 问题内容: 我正在尝试使用带有以下命令的命令提示符来编译我的Java文件’check4PrimeTest.java’: javac -classpath。:junit.jar check4PrimeTest.java 我收到以下错误: 错误:包junit.framework不存在import junit.framework。*; 我不确定为什么会收到此错误,因为我在程序中导入了junit.fram

  • 我尝试在Ubuntu11.02的命令行上运行ant build.xml中的javac。然后运行“ant deploy-live”之后,命令行打印如下: 我关于javac的任务: 操作系统:Ubuntu 11.10(oneiric) Java版本:Java版本“1.7.0”Java(TM)SE运行时环境(build 1.7.0-B147)Java HotSpot(TM)64位服务器VM(build

  • 我是ANT build新手,在编译ANT build时遇到错误“package org.testng.annotations不存在”和“package org.openqa.selenium不存在”。xml。 这里是build.xml 下面是错误列表 我还设置了JAVA\u HOME C:\Program Files\JAVA\jdk1.7.0\u 25\bin和ANT\u HOME C:\Use

  • 我有一个爪哇项目。它由以下层次结构组成: 项目: < li >服务器(包含server.java) < li >客户端(包含client.java) < li >协议(包含中的消息类型。java文件) 我正在用Eclipse运行这个项目。我已经到了需要用终端测试的地步。我如何使用 build.xml 文件来格式化它,以便每当我将其从 Eclipse 中取出并在服务器中运行时,它都能正常工作,但在上

  • 尽管类路径上有所需的JAR,但我的编译目标中的任务失败。有人能帮我弄清楚为什么会这样吗? 下面的错误是由。然而,commons-io-1.3.1。jar位于构建路径上(在中)。所以,奇怪的是构建失败了。 令人惊讶的是,Eclipse构建项目没有任何问题。我在项目构建路径上有相同的jars集。我也有相同的源目录被排除在编译之外。 试图在源代码文件夹上使用javac可执行文件,但不确定如何在源代码目录