2015-10-06 78 views
0

當我嘗試在Jenkins上編譯我的項目時,出現錯誤消息。Ant <javac> Jenkins中的「包不存在」錯誤

<target name="QuebecNYear">是我正在編譯並在Jenkins上運行的類。

build.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> 

再有就是對詹金斯的控制檯輸出:

[javac] Compiling 1 source file to C:\Users\fzs.jenkins\workspace\Automation test Auto\EnergieAutoTest\bin\com\economical\test\energieauto\testcases

[javac] C:\Users\fzs.jenkins\workspace\Automation test Auto\EnergieAutoTest\src\com\economical\test\energieauto\testcases\QuebecNYear.java:32: error: package com.economical.test.brokerextranetlib.pageobjects does not exist

[javac] import com.economical.test.brokerextranetlib.pageobjects.HomePage;

這裏是我的Java類QuebecNyear 32行:

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

這是目標類的情況下,其在build.xml中不明確的<目標名稱=「QuebecNYear 「> \t \t \t \t <格式化類型= 「XML」/> \t \t \t <測試名稱= 「com.economical.test.energieauto.testcases.QuebecNYear」 todir = 「$ {junit.output.dir}」/> \t \t \t Fawad

回答

0

<javac>需要<classpath>,所以它知道在哪裏查找其他編譯類。

下...

<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> 
+0

我想這是每您的建議,並沒有奏效 – Fawad

+0

<目標名稱= 「QuebecNYear」> \t \t \t \t <類路徑REFID = 「EnergieAutoTest.classpath」/> \t \t \t \t <格式化類型= 「XML」/> \t \t \t <測試名稱= 「com.economical.test.energieauto.testcases.QuebecNYear」 todir =「$ {junit.output.dir}」/> \t \t \t Fawad

+0

含有'com.economical.test.brokerextranetlib.pageobjects.HomePage'需要是對類路徑.jar文件''成功。 –