java中标准的build.xml配置文件

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project basedir= "D:\selenium\AutoTest" default="build" name="AutoTest" >    
    <!--配置基本属性-->
    <property name="src" value="src\CommonMain"/>
    <property name=" build "   value=" build " />
    <property name="lib" value="lib"/>
    <property name="dist" value="dist"/>
    <property name="classpath" location="${bin}"/>
    
    <!--配置测试报告的属性-->
    <property name="report" value="report"/>
    <property name="report.xml" value="${report}/junit/xml"/>
    <property name="report.html" value="${report}/junit/html"/>

    <!--配置运行时classpath-->
    <path id="classpath.run">
        <pathelement path="${classpath}"/>
        <fileset dir="${lib}">
            <include name="*.jar"/>
        </fileset>
    </path>

    <!--配置测试时classpath-->
    <path id="classpath.test">
    <path refid="classpath.run"/>
        <path location="${dist}/lib/*.jar"/>
    </path>

    <!--任务初始化-->
    <target name="init">
        <tstamp/>
            <mkdir dir="${ build }" />
    </target>

    <!--配置编译任务-->
    <target name="compile" depends="init">
        <javac destdir="${ build }"   srcdir="${src}"   includeantruntime="on">
            <classpath refid="classpath.run"/>
        </javac>
    </target>

    <!--配置打包任务-->
    <target name="dist" depends="compile">
        <mkdir dir="${dist}/lib"/>
        <jar basedir="${bin}" jarfile="${dist}/lib/*.jar"/>
    </target>

    <!--配置运行任务-->
    <target name="run" depends="compile, dist">
        <java classname="${ build }/PublicSuite.class" >
        <classpath>
            <path refid="classpath.run"/>
        </classpath>
    </java>
    </target>

    <!--配置JUnit测试,打印测试结果-->
    <target name="build" depends="compile, dist">
        <mkdir dir="${report.xml}"/>
        <mkdir dir="${report.html}"/>
        <junit haltonfailure="no" printsummary="yes">
        <classpath refid="classpath.run"/>
            <formatter type="xml"/>
            <batchtest todir="${report.xml}" fork="yes">
        <fileset dir="${src}" includes="**/Test*.java"/>
    </batchtest>
    </junit>
    
        <junitreport todir="${report.html}">
            <fileset dir="${report.xml}">
            <include name="*.xml"/>
            </fileset>
            <report todir="${report.html}" format="frames"/>
        </junitreport>
    </target>        

</project>  



  • 3
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
要配置 build.xml 文件,您需要遵循以下步骤: 1. 创建一个新的 build.xml 文件或编辑现有的 build.xml 文件。 2. 在 build.xml 文件定义项目的基本属性,例如项目的名称、默认目标等。您可以使用 `<project>` 元素来定义这些属性。例如: ```xml <project name="MyProject" default="compile"> <!-- 其他属性 --> </project> ``` 3. 定义项目的目标(target)。目标是 build.xml 文件执行的任务。您可以使用 `<target>` 元素来定义目标。例如,下面是一个名为 "compile" 的目标示例: ```xml <target name="compile"> <!-- 执行编译操作的命令 --> </target> ``` 4. 在目标定义任务(task)。任务是执行特定操作的命令或脚本。您可以使用 Ant 的内置任务,也可以使用自定义任务。例如,下面是一个编译 Java 代码的任务示例: ```xml <target name="compile"> <javac srcdir="src" destdir="build"/> </target> ``` 5. 配置目标和任务的依赖关系。如果一个目标依赖于另一个目标,您可以使用 `depends` 属性来指定依赖关系。例如: ```xml <target name="build" depends="clean, compile"> <!-- 执行构建操作的命令 --> </target> ``` 6. 添加其他必要的配置,例如文件路径、编译选项等。 7. 保存并运行 build.xml 文件。您可以使用 Ant 的命令行工具运行 build.xml 文件,或者将其集成到集成开发环境(IDE)。 请注意,这只是一个基本的配置示例。根据您的项目需求,您可能需要添加更多的目标和任务,并进行适当的配置。 希望这可以帮助您配置 build.xml 文件!如果您有任何进一步的问题,请随时提问。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值