Use ant to compile, run JUnit, and check the encoding

Source: Internet
Author: User
Tags echo message mkdir checkstyle

In Java development, Ant provides us with a very powerful project building capability. In daily development, the most commonly used functions are: Compile, package, run JUnit testcase, check coding specifications. Here are some of the most common features of an ant template file, shared with you.

<?xml version= "1.0" encoding= "gb2312"?>

<project name= "Test project" default= "All" basedir= "." >

<property name= "Src.code" value= "src"/>

<property name= "Src.junit" value= "JUnit"/>

<property name= "Lib.dir" value= "Lib"/>

<property name= "Lib.jar" value= "Testclass.jar"/>

<!--checkstyle configuration-->

<property name= "Checkstyle.config" value= "Checkstyle.xml"/>

<taskdef resource= "Checkstyletask.properties"

Classpath= "${lib.dir}/checkstyle-all-3.1.jar"/>

<!--output document-->

<property name= "Doc.dir" value= "Doc"/>

<property name= "Doc.api" value= "${doc.dir}/api"/>

<property name= "Javadoc.package" value= "com.*"/>

<!--output binary file-->

<property name= "Dist.root" value= "dist"/>

<property name= "dist.proj" value= "${dist.root}/proj"/>

<property name= "dist.classes" value= "${dist.proj}/classes"/>

<property name= "Dist.lib" value= "${dist.proj}/lib"/>

<property name= "Dist.junit" value= "${dist.root}/junit"/>

<!--classpath-->

<path id= "Classpath" >

<fileset dir= "${lib.dir}" >

<include name= "**/*.jar"/>

</fileset>

</path>

<path id= "Proj.libs" >

<fileset dir= "${dist.lib}" >

<include name= "**/*.jar"/>

</fileset>

</path>

<target name= "Init" >

<mkdir dir= "${doc.dir}"/>

<mkdir dir= "${dist.root}"/>

<mkdir dir= "${dist.proj}"/>

<mkdir dir= "${dist.lib}"/>

<tstamp/>

<echo message= "${tstamp}" ></echo>

</target>

<target name= "All" depends= "compilesrc, Javadoc, Checkstyle"/>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.