0
votes

I am getting an error message when I try to compile my project on Jenkins.

<target name="QuebecNYear"> is the class I am trying to compile and run on Jenkins.

build.xml file:

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

And then there is the console output on Jenkins:

[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;

And here is my Java class QuebecNyear, line 32:

import com.economical.test.brokerextranetlib.pageobjects.HomePage;
1
This is the target class in case its not clear in build.xml <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>Fawad

1 Answers

0
votes

<javac> needs a <classpath> so it knows where to look for other compiled classes.

The following...

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

...should become...

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