当前位置:网站首页>Ant advanced task
Ant advanced task
2022-07-27 10:13:00 【51CTO】
One Task Command line parameters of
There are some task Acceptable parameters , And pass it to another process . In order to include space characters in variables , Nested arg Elements .
Attribute Description Required
value A command line variable ; Can contain space characters . Only one
line Space separated list of command line variables .
file File name as a command line variable ; Will be replaced by the absolute name of the file .
path As a single command line variable path-like String ; Or as a separator ,Ant Will turn it into a platform specific separator .
Example
<arg value="-l -a"/> Is a single command line variable with spaces .
<arg line="-l -a"/> Is a command line variable separated by two spaces .
<arg path="/dir;/dir2:\dir3"/> Is a command line variable , Its value is DOS The system is \dir;\dir2;\dir3; stay Unix The system is /dir:/dir2:/dir3 .
Two Time stamp <tstamp/>
Use the current time and date in the build environment , Mark the output of a build task in some way , In order to record when it was generated , This is often desirable . This may involve editing a file , To insert a string specifying the date and time , Or combine this information into JAR or zip The file name of the file .
This need is through simple but very useful tstamp Task to solve . This task is usually called at the beginning of a generation process , Like in one init On target . This task does not require attributes , In many cases, just <tstamp/> That's enough .
tstamp No output ; contrary , It is set according to the current system time and date Ant attribute . Here is tstamp Set some properties of 、 Description of each attribute , And examples of values to which these attributes can be set :
Attribute description example
DSTAMP Set as current date , The default format is yyyymmdd 20031217
TSTAMP Set to current time , The default format is hhmm 1603
TODAY Set as current date , With full month 2003 year 12 month 17 Japan
for example , In the previous section , We created a JAR file :
<jar destfile="package.jar" basedir="classes"/>
Calling tstamp After the mission , We can name this according to the date JAR file , As shown below :
<jar destfile="package-{DSTAMP}.jar" basedir="classes"/>
therefore , If the task is 2003 year 12 month 17 Day call , The JAR The file will be named package-20031217.jar.
It can also be configured tstamp Task to set different properties , Apply a time offset before or after the current time , Or format the string in a different way . All of these are using a nested format Elements , As shown below :
The above list will OFFSET_TIME Property is set to the distance from the current time 10 Hours after minutes 、 Minutes and seconds .
The characters used to define the format string are the same as java.text.SimpleDateFormat The format characters defined by the class are the same .
3、 ... and send out email Of task
Use SMTP The server sends mail
Example :
Four ssh and scp
stay ant in , Use ssh Command to remotely start and stop tomcat
Here is the remote stop 192.168.0.2 On this machine tomcat:
The following is remote startup 192.168.0.2 On this machine tomcat:
stay ant in , Use scp Put the local file (appwar A file in a directory ) Remote copy to another machine tomcat Next :
5、 ... and input
Interactive input with users task
6、 ... and exec
Execute other processes task
VII. Others task
if task
ant It could be in target Level carry if Judge (unless,if attribute ), But it's too inconvenient .
Conditions
but Ant A bunch of pre packaged condition It's very convenient . these condition Proceed completely from reality , Including whether the file exists , http://localhost:8080 Connectivity can be used as a condition , see Ant Reference manual for .
For task
Support "a,b,c,d" Loop of string array and file directory ,Fileset The cycle of .
Parallel task
Parallel Very useful , For example, I want to drive tomcat, While doing something else , You need to use it , Otherwise, it will only be used spawn=true Attribute to tomcat Run in the background .spawn There are a lot of bad things , For example, you can't immediately console See the message , stop it ant Running cannot turn tomcat Turn it off, etc .
Parallel Equivalent to a container , Every one in it task Will be executed in parallel . If you want to put some task Sequential execution , It is equivalent to () Of Sequential task wrap up .
Waitfor task
Pause ant Execute until the conditions are met , such as <waitfor><http url=http://localhost:8080/></waitfor> Will wait tomcat The execution will continue after startup .
8、 ... and antcall And ant
depends:depends Medium targets In Ben target Before execution, call .
antcall : Used to call the same build.xml Other in target, Equivalent to function call in high-level language .
ant: Call other build.xml Medium target.
Nine Customize TASK Use
ANT There are many built-in task, image copy、replace、javac wait , But sometimes some specific tasks are needed to complete the operation , For example, when generating JAD file when , Need one Midlet-Jar-Size Parameters of , obtain JAR File size , But through the inside task It can't be done , Therefore, you can write your own classes to achieve this function , But it must be guaranteed This kind of certificate is from Task Class inherited .
example :
End !
author :iTech
WeChat official account : cicdops
github: https://github.com/cicdops/cicdops

边栏推荐
猜你喜欢

PCL各模块概述(1.6)

After one year, the paper was finally accepted by the international summit

Shell综合应用案例,归档文件、发送消息

Food safety | is sugar free really sugar free? These truths need to be known

Food safety | the kitchen board environment is very important. Do you know these use details?

Excellent Kalman filter detailed article

Open3d library installation, CONDA common instructions, importing open3d times this error solving environment: failed with initial frozen solve Retrying w

Brush the title "sword finger offer" day04

Robotframework+eclispe environment installation

3D修复论文:Shape Inpainting using 3D Generative Adversarial Network and Recurrent Convolutional Networks
随机推荐
Matlab-实时编辑器介绍
Engineering survey simulation volume a
01_ Movie recommendation (contentbased)_ Object portrait
Simple use of tflite
Matlab-绘制叠加阶梯图和线图
备战金九银十Android面试准备(含面试全流程,面试准备工作面试题和资料等)
WGAN、WGAN-GP、BigGAN
[scm] source code management - lock of perforce branch
Visual slam lecture notes (I): Lecture 1 + Lecture 2
How to create a.Net image with diagnostic tools
oracle rac 19c pdb实例当掉
如何创建一个带诊断工具的.NET镜像
Shell中的文本处理工具、cut [选项参数] filename 说明:默认分隔符是制表符、awk [选项参数] ‘/pattern1/{action1}filename 、awk 的内置变量
卸载CUDA11.1
Understand chisel language. 22. Chisel sequential circuit (II) -- detailed explanation of chisel counter: counter, timer and pulse width modulation
食品安全 | 无糖是真的没有糖吗?这些真相要知道
Pytorch installation (very detailed)
圆环工件毛刺(凸起)缺口(凹陷)检测案例
Anchor free detector: centernet
Shell integrated application cases, archiving files, sending messages