Common ant operations

Source: Internet
Author: User
Frequently-used ant operations are convenient for self-query, so they are uploaded to the Internet. If a friend thinks it is not enough, please add:

The main contents include:

(1) create a project
(2) create attributes
(3) Database Operations
(4) javac Compilation
(5) delete a directory
(6) create a directory
(7) copy a file group
(8) jar is a package
(9) copy a single object
(10) Run
There are more and better common ones that I did not expect. I hope you can add them.

<! -- (1) create a project. The default operation is target = all. -->
<Project name = "proj" default = "all" basedir = ".">

<! -- (2) create some attributes for the following operations -->
<Property name = "root" value = "./"/>
<Property name = "deploy_path" value = "D:/deploy"/>
<Property name = "srcfile" value = "D:/srcfile"/>

<Target name = "all" depends = "compile, deploy"/>

<! -- (3) database operation demo. DDL writes the SQL statement driver, URL, userid, and password as needed -->
<! -- Oracle -->
<Target name = "db_setup_oracle" Description = "database setup for Oracle">
<Antcall target = "check_params_results"/>
<SQL driver = "oracle. JDBC. Driver. oracledriver"
Url = "JDBC: oracle: thin: @ 192.168.0.1: 1521: OA"
Userid = "OA" Password = "OA"
Onerror = "continue"
Print = "yes"
Src = "./demo. DDL"/>
</Target>

<! -- (4) javac Compilation -->
<Target name = "compile">
<Javac srcdir = "$ {srcfile }"
Destdir = "$ {root}/OA /"
Includes = "*. Java"
Classpath = "$ {classpath}; $ {client_classes}/utils_common.jar" <! -- Classpath and client_classes are environment variables -->
/>
</Target>
 
<Target name = "deploy" depends = "compile">
<! -- Create the time stamp -->
<Tstamp/>

<! -- (5) delete a directory -->
<! -- (6) create a directory -->
<Delete dir = "$ {root}/Dist/"/>
<Mkdir dir = "$ {root}/Dist/"/>

<Delete dir = "$ {deploy_path}"/>
<Mkdir dir = "$ {deploy_path}"/>

<! -- (7) copy a file group -->
<Copy todir = "$ {root}/Dist/">
<Fileset dir = "$ {root}/OA/">
<Include name = "*. Class"/>
</Fileset>
</Copy>

<! -- (8) jar is a package -->
<Jar jarfile = "$ {deploy_path}/classjar. Jar" basedir = "$ {root}/Dist" update = "yes"> </jar>

<! -- (9) copy a single file (the file group is above, and this is a single file) -->
<Copy file = "$ {deploy_path}/classjar. Jar" todir = "$ {root}/Dist/"/>

</Target>
 
<! -- (10) Run (ARGs is a parameter, which varies with the specific situation of the Application)->
<Target name = "simplesql" depends = "compile, db_setup_oracle">
<Java classname = "examples. JDBC. Oracle. simplesql"
Fork = "yes" failonerror = "yes"
ARGs = "-user ZRB
-Password ZRB
"/>

</Project>

 

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.