当我在cmd中运行Ant时,它显示我在我的项目文件夹中有build.xml文件时不存在build.xml错误

时间:2013-08-13 13:16:46

标签: ant build

我是一名尝试使用Ant生成xslt报告的selenium用户,但是当我在cmd中运行Ant时,它显示我在项目文件夹中有build.xml文件时不存在build.xml错误。

  1. 我在Windows 7上使用eclispe juno,并将build.xml文件保存在项目中。
  2. 我的机器上有java JDK1.7,我已根据apache.org上的说明设置了环境变量(Java和ant)
  3. Ant版本是apache-ant-1.9.1
  4. 我在eclipse的项目中导入了所有必要的jar文件(selenium + maven + saxon + xslt报告通过ant所需的所有文件)。 当我试图通过cmd运行ant时,它向我显示此错误: -
  5. 建立失败

    D:\Projects\Project\Selenium\Workspace\build.xml:70: Compile failed; see the compiler error output for details.
    

    下面是我的build.xml文件: -

    <project name="Plumslice" default="usage" basedir=".">
    
    
    <property environment="env"/>
    <property name="ws.home" value="${basedir}"/>
    <property name="ws.jars" value="D:\All jars"/>
    <property name="test.dest" value="${ws.home}/build"/>
    <property name="test.src" value="${ws.home}/src"/>
    <property name="ng.result" value="test-output"/>
    
    <!--target name="start-selenium-server">
    <java jar="${ws.home}/lib/selenium-server.jar"/>
    </target-->
    
    <target name="setClassPath" unless="test.classpath">
    <path id="classpath_jars">
    <fileset dir="${ws.jars}" includes="*.jar"/>
    </path>
    <pathconvert pathsep=":"
    property="test.classpath"
    refid="classpath_jars"/>
    </target>
    
    <target name="init" depends="setClassPath">
    <tstamp>
    <format property="start.time" pattern="MM/dd/yyyy hh:mm aa" />
    </tstamp>
    <condition property="ANT"
    value="${env.ANT_HOME}/bin/ant.bat"
    else="${env.ANT_HOME}/bin/ant">
    <os family="windows" />
    </condition>
    <taskdef name="testng" classpath="${test.classpath}"
    classname="org.testng.TestNGAntTask" />
    
    </target>
    
    <!-- all -->
    <target name="all">
    </target>
    
    <!-- clean -->
    <target name="clean">
    <delete dir="${test.dest}"/>
    </target>
    
    
    <!-- compile -->
    <target name="compile" depends="init, clean" >
    <delete includeemptydirs="true" quiet="true">
    <fileset dir="${test.dest}" includes="**/*"/>
    </delete>
    <echo message="making directory..."/>
    <mkdir dir="${test.dest}"/>
    <echo message="classpath------: ${test.classpath}"/>
    <echo message="compiling..."/>
    
    <javac
    debug="true"
    destdir="${test.dest}"
    srcdir="${test.src}"
    target="1.7"
    classpath="${test.classpath}">
    </javac>
    <copy todir="${test.dest}">
    <fileset dir="${test.src}" excludes="**/*.java"/>
    </copy>
    </target>
    
    
    <!-- build -->
    <target name="build" depends="init">
    </target>
    
    <!-- run -->
    <target name="run" depends="compile">
    <testng classpath = "${test.classpath}:${test.dest}" suitename = "suite1" >
    <xmlfileset dir="${ws.home}" includes="testng.xml"/>
    </testng>
    <!--
    <testng classpath="${test.classpath}:${test.dest}" groups="fast">
    <classfileset dir="${test.dest}" includes="example1/*.class"/>
    </testng>
    -->
    </target>
    
    
    
    
    <target name="usage">
    <echo>
    ant run will execute the test
    </echo>
    </target>
    
    
    <path id="test.c">
    <fileset dir="${ws.jars}" includes="*.jar"/>
    
    </path>
    
    <target name="email" >
    <java classname="com.qtpselenium.util.SendMail" classpath="${test.dest}" classpathref="test.c" />
    </target>
    
          <target name="makexsltreports">
                    <mkdir dir="${ws.home}/XSLT_Reports/output"/>
    
                    <xslt in="${ng.result}/testng-results.xml" style="src/com/testing/xslt/testng-results.xsl"
                          out="${ws.home}/XSLT_Reports/output/index.html" classpathref="test.c" processor="SaxonLiaison">
                        <param name="testNgXslt.outputDir" expression="${ws.home}/XSLT_Reports/output/"/>
                        <param name="testNgXslt.showRuntimeTotals" expression="true"/>
                    </xslt>
                </target>
    
    
    </project>
    

1 个答案:

答案 0 :(得分:0)

感谢大家的帮助,我已经解决了这个错误..

它与jar文件的路径有关,我提供了不正确的jar文件路径。

这是第70行: -

        <javac debug="true" destdir="${test.dest}" srcdir="${test.src}"
        target="1.7" classpath="${test.classpath}">

这与罐子的路径有关,在我文件的顶行我提供了这条路径 - D:\所有罐子,而所有必需的罐子都不在这个文件夹中,现在我更新了jar文件夹,它现在工作正常。

相关问题