| 您所在的位置: >
> ant simple v1.8.4标签名称更新时间&&&&&&&&&&wodHttpDLX是一款http客户端activex控件。可以方便的在上层或者底层对http协议进行访问。它的本意是从网络上抓取信息。它具有一个很友好的编程界面,能够让你很轻松的得到你想要的资源。...sinojelly 的BLOG
用户名:sinojelly
文章数:264
评论数:1484
访问量:1195064
注册日期:
阅读量:5863
阅读量:12276
阅读量:396562
阅读量:1087143
51CTO推荐博文
Ant跟make很相似,它有target,和生成target的一系列操作。但它又与make不同,ant具有如下特点:(1)跨平台。(它是基于java的)(2)用xml来实现脚本,控制运行过程。&一、准备1、下载***ant。下载地址:***方法:(1)解压缩。(2)设置环境变量。set ANT_HOME=c:\antset J***A_HOME=c:\jdk-1.5.0.05set PATH=%PATH%;%ANT_HOME%\bin2、下载***jdk。&二、基本概念参见:1、Projects它有三个属性:项目名字、默认目标、基础目录(所有相对路径均基于它计算)
Description
the name of the project.
the default target to use when no target is supplied.
No; however,&since Ant 1.6.0, every
project includes an implicit target that contains any and all top-level
tasks and/or types. This&target will always be executed as
part&of the project's
initialization, even when Ant is run with the&&option.
the base directory from which all path calculations are done.
This attribute might be overridden by setting the &basedir& property
beforehand. When this is done, it must be omitted in the project tag. If
neither the attribute nor the property have been set, the parent directory
of the buildfile will be used.
No2、Targets目标。可以依赖其它目标。Ant会处理这个依赖关系。(类似于make)3、TasksTask是可以被执行的一段代码。基本结构:&name attribute1=&value1& attribute2=&value2& ... /&Ant有一系列的内建task,和很多的可选task。4、Properties属性,用于定义构建过程,或者定义一些变量代表某个长字符串。三、脚本示例1、一个基本的构建脚本。&project name=&MyProject& default=&dist& basedir=&.&&
&description&
simple example build file
&/description&
&!-- set global properties for this build --&
&property name=&src& location=&src&/&
&property name=&build& location=&build&/&
&property name=&dist&
location=&dist&/&
&target name=&init&&
&!-- Create the time stamp --&
&!-- Create the build directory structure used by compile --&
&mkdir dir=&${build}&/&
&target name=&compile& depends=&init&
description=&compile the source & &
&!-- Compile the java code from ${src} into ${build} --&
&javac srcdir=&${src}& destdir=&${build}&/&
&target name=&dist& depends=&compile&
description=&generate the distribution& &
&!-- Create the distribution directory --&
&mkdir dir=&${dist}/lib&/&
&!-- Put everything in ${build} into the MyProject-${DSTAMP}.jar file --&
&jar jarfile=&${dist}/lib/MyProject-${DSTAMP}.jar& basedir=&${build}&/&
&target name=&clean&
description=&clean up& &
&!-- Delete the ${build} and ${dist} directory trees --&
&delete dir=&${build}&/&
&delete dir=&${dist}&/&
&/target&&/project&把此文件保存为build.xml,并且建立与之平级的src目录,里面写入HelloWorld.java,再运行ant,可以自动编译出class和jar。2、path定义和使用。
&path id=&base.path&&
&pathelement path=&${classpath}&/&
&fileset dir=&lib&&
&include name=&**/*.jar&/&
&/fileset&
&pathelement location=&classes&/&
&path id=&tests.path& cache=&true&&
&path refid=&base.path&/&
&pathelement location=&testclasses&/&
&/path&例子:下面代码定义classpath为三部分组成,${classpath}、多个jar、classes目录。四、基本使用1、查看帮助。D:\Tools\apache-ant-1.8.0-bin&ant -helpant [options] [target [target2 [target3] ...]]Options:
print this message
-projecthelp, -p
print project help information
print the version information and exit
-diagnostics
print information that might be helpful to
diagnose or report problems.
-quiet, -q
be extra quiet
-verbose, -v
be extra verbose
-debug, -d
print debugging information
-emacs, -e
produce logging information without adornments
-lib &path&
specifies a path to search for jars and classes
-logfile &file&
use given file for log
-logger &classname&
the class which is to perform logging
-listener &classname&
add an instance of class as a project listener
do not allow interactive input
-buildfile &file&
use given buildfile
-D&property&=&value&
use value for given property
-keep-going, -k
execute all targets that do not depend
on failed target(s)
-propertyfile &name&
load all properties from file with -D
properties taking precedence
-inputhandler &class&
the class which will handle input requests
-find &file&
(s)earch for buildfile towards the root of
the filesystem and use it
A niceness value for the main thread:
1 (lowest) to 10 (highest); 5 is the default
-nouserlib
Run ant without using the jar files from
${user.home}/.ant/lib
-noclasspath
Run ant without using CLASSPATH
-autoproxy
Java1.5+: use the OS proxy settings
-main &class&
override Ant's normal entry point2、用ant执行lint。(1)写一个main.c文件。int main(){
int a = 0;
int b = a * 10;
//return 0;}(2)在命令行执行lint-nt main.c得到如下结果:D:\Tools\apache-ant-1.8.0-bin\test_jelly\lint&lint-nt main.cPC-lint for C/C++ (NT) Vers. 8.00w, Copyright Gimpel Software --- Module:
main.c (C)
Info 783: Line does not end with new-linemain.c
Warning 529: Symbol 'b' (line 5) not subsequently referencedmain.c
Info 830: Location cited in prior message(3)写如下的build.xml&project name=&MyProject& default=&dist& basedir=&.&&
&target name=&dist&&
&exec dir=&.& executable=&lint-nt& os=&${os.name}&
failonerror=&true&&
&arg value=&main.c&/&
&/target&&/project&然后执行ant,得到如下结果(跟命令行执行lint是一样的)D:\Tools\apache-ant-1.8.0-bin\test_jelly\lint&antBuildfile: D:\Tools\apache-ant-1.8.0-bin\test_jelly\lint\build.xmldist:
[exec] PC-lint for C/C++ (NT) Vers. 8.00w, Copyright Gimpel Software 1985-2007
[exec] --- Module:
main.c (C)
[exec] main.c
Info 783: Line does not end with new-line
[exec] main.c
Warning 529: Symbol 'b' (line 5) not subsequently referenced
[exec] main.c
Info 830: Location cited in prior messageBUILD FAILEDD:\Tools\apache-ant-1.8.0-bin\test_jelly\lint\build.xml:6: exec returned: 3Total time: 1 second通过指定-v参数,可以得到更多运行过程信息:D:\Tools\apache-ant-1.8.0-bin\test_jelly\lint&ant -vApache Ant version 1.8.0 compiled on February 1 2010Trying the default build file: build.xmlBuildfile: D:\Tools\apache-ant-1.8.0-bin\test_jelly\lint\build.xmlDetected Java version: 1.6 in: C:\Program Files\Java\jdk1.6.0_18\jreDetected OS: Windows 7parsing buildfile D:\Tools\apache-ant-1.8.0-bin\test_jelly\lint\build.xml with URI = file:/D:/Tools/apache-ant-1.8.0-bin/test_jelly/lint/build.xmlProject base dir set to: D:\Tools\apache-ant-1.8.0-bin\test_jelly\lintBuild sequence for target(s) `dist' is [dist]Complete build sequence is [dist, ]dist:parsing buildfile jar:file:/D:/Tools/apache-ant-1.8.0-bin/lib/ant.jar!/org/apache/tools/ant/antlib.xml with URI = jar:file:/D:/Tools/apache-ant-1.8.0-bin/lib/ant.jar!/org/apache/tools/ant/antlib.xml from a zip file
[exec] Current OS is Windows 7
[exec] Executing 'lint-nt' with arguments:
[exec] 'files.lnt'
[exec] The ' characters around the executable and arguments are
[exec] not part of the command.
[exec] PC-lint for C/C++ (NT) Vers. 8.00w, Copyright Gimpel Software 1985-2007
[exec] --- Module:
main.c (C)
[exec] main.c
Info 783: Line does not end with new-line
[exec] main.c
Warning 529: Symbol 'b' (line 5) not subsequently referenced
[exec] main.c
Info 830: Location cited in prior messageBUILD FAILEDD:\Tools\apache-ant-1.8.0-bin\test_jelly\lint\build.xml:4: exec returned: 3
at org.apache.tools.ant.taskdefs.ExecTask.runExecute(ExecTask.java:650)
at org.apache.tools.ant.taskdefs.ExecTask.runExec(ExecTask.java:676)
at org.apache.tools.ant.taskdefs.ExecTask.execute(ExecTask.java:502)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:390)
at org.apache.tools.ant.Target.performTasks(Target.java:411)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1360)
at org.apache.tools.ant.Project.executeTarget(Project.java:1329)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
at org.apache.tools.ant.Project.executeTargets(Project.java:1212)
at org.apache.tools.ant.Main.runBuild(Main.java:801)
at org.apache.tools.ant.Main.startAnt(Main.java:218)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:280)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:109)Total time: 1 second
了这篇文章
类别:未分类┆阅读(0)┆评论(0)