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>