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

当我在cmd中运行Ant时,它向我显示build.xml不存在的错误,而我的项目文件夹中有build.xml文件,ant,build,Ant,Build,我是一个试图使用Ant生成xslt报告的selenium用户,但当我在cmd中运行Ant时,它向我显示build.xml不存在的错误,而我的项目文件夹中有build.xml文件 我在windows 7上使用eclispe juno,并将build.xml文件保存在项目下 我的机器上有JavaJDK1.7,我已经按照apache.org上的说明设置了环境变量(java和ant都有) Ant版本是apache-Ant-1.9.1 我已经在eclipse中的项目中导入了所有必要的jar文件(selen

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

  • 我在windows 7上使用eclispe juno,并将build.xml文件保存在项目下
  • 我的机器上有JavaJDK1.7,我已经按照apache.org上的说明设置了环境变量(java和ant都有)
  • Ant版本是apache-Ant-1.9.1
  • 我已经在eclipse中的项目中导入了所有必要的jar文件(selenium+maven+saxon+xslt报告所需的所有文件)。 当我试图通过cmd运行ant时,它向我显示了以下错误:-
  • 构建失败

    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>
    
    
    ant run将执行测试
    
    谢谢大家的大力帮助,我已经解决了这个错误

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

    这是第70行:-

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

    这与jar的路径有关,我在文件的顶行提供了路径-D:\All jar,虽然所有必需的jar都不在此文件夹中,但现在我更新了jar文件夹,它现在工作正常。

    你忘了添加.xml文件了吗?@NREZ-抱歉,现在上传了它。请帮助它看起来不像Ant无法找到您的构建文件。错误消息显示生成文件的第70行发生错误。那么,如果上面发布的构建文件就是这个,你能把第70行标记出来吗?另外,它显示“编译失败”,所以我认为它是由javac报告的;而且应该有更多的信息,你可以发布它们(如果太长,使用gist等服务并在那里发布链接)。