用户登录
用户注册

分享至

ant apache regexp

  • 作者: 狂欢48863251
  • 来源: 51数据库
  • 2020-09-22
destdir全称是 destination dir,目标目录,比如编译时的输出目录,复制时的目标目录
一、Ant工具
????Ant是一种基于Java的build工具。理论上来说,它有些类似于(Unix)C中的make ,但没有make的缺陷。目前的最新版本为:Ant 1.9.4
????当一个代码项目大了以后,每次重新编译,打包,测试等都会变得非常复杂而且重复,因此c语言中有make脚本来帮助这些工作的批量完成。在Java 中应用是平台无关性的,当然不会用平台相关的make脚本来完成这些批处理任务了,ANT本身就是这样一个流程脚本引擎,用于自动化调用程序完成项目的编译,打包,测试等。除了基于JAVA是平台无关的外,脚本的格式是基于XML的,比make脚本来说还要好维护一些。
二、Ant的使用:
1、下载安装
????1)下载网址:http://ant.apache.org
????2)设置环境变量:
????????ANT_HOME:ant的安装目录
????????JAVA_HOME:jdk的安装目录
????????PATH:把%ANT_HOME%\bin目录加到path变量,以便于从命令行下直接运行ant
2、工程文件目录结构
????C:\workspace\ant.test:工程主目录
????\src :源程序目录
????\build\classes :编译后的 class 文件目录
????\lib :开发工程所需要的类库目录,比如开发数据库时所需要的 jdbc lib(这次没用到)
????\jar :打包好的 jar 程序目录(这次没用到)
????\build.xml :工程配置文件
????\build.propertiees:工程资源文件
3、建立工程描述文件和建立工程资源文件build.xml
<?xml?version="1.0"?>

<project?default="main"?basedir=".">

????<echo?message="pulling?in?property?files"?/>
????<property?file="build.properties"?/>

????<target?name="init">
????????<echo?message="init.?delete?the?old?class?files.?and?create?the?new?folds."?/>
????????<delete?dir="${classpath}"?/>
????????<mkdir?dir="${classpath}"?/>
????</target>

????<target?name="compile"?depends="init">
????????<echo?message="compile?the?java?source?files."?/>
????????<javac?srcdir="src\hello\ant"?destdir="${classpath}"?/>
????</target>

????<target?name="main"?depends="compile">
????????<echo?message="calling?java?to?run?this?java?project."?/>
????????<java?classname="hello.ant.HelloAnt">
????????????<classpath>
????????????????<pathelement?path="${classpath}"?/>
????????????</classpath>
????????</java>
????</target>

</project>4、建立java源文件:hello.ant.HelloAnt.java
package?hello.ant;

public?class?HelloAnt?{
????public?static?void?main(String[]?args)?{
????????System.out.println("hello?ant,?the?first?time?using?ant...?it?is?great.");
????}
}5、编译
C:\workspace\ant.test>ant?-buildfile?build.xml
Buildfile:?build.xml
?????[echo]?pulling?in?property?files

init:
?????[echo]?init.?delete?the?old?class?files.?and?create?the?new?folds.
???[delete]?Deleting?directory?C:\workspace\ant.test\build\classes
????[mkdir]?Created?dir:?C:\workspace\ant.test\build\classes

compile:
?????[echo]?compile?the?java?source?files.
????[javac]?Compiling?1?source?file?to?C:\workspace\ant.test\build\classes

main:
?????[echo]?calling?java?to?run?this?java?project.
?????[java]?hello?ant,?the?first?time?using?ant...?it?is?great.

BUILD?SUCCESSFUL
Total?time:?890?milliseconds

C:\workspace\ant.test>



  你好!

全称是 destination dir,目标目录,比如编译时的输出目录,复制时的目标目录 ...,你对照着 task 的功能来确定它是指哪个目录。

如有疑问,请追问。
软件
前端设计
程序设计
Java相关