ANT (1.6) Advanced Features: Process Control

zhaozj2021-02-16  90

Ant

Not introduced

Shell

,ratio

Make

There are many troubles, but the process control

(Flow Control)

It is also not possible, or if it can't complete the complex task.

Ant

Built-in simple process control methods, and we can implement complex process control from the outside of the scripting language.

ANT built-in process control method

1.

Depends

When defining a Target, the dependent Target is specified by Depends, then these dependencies must pass the Target before running this Target:

So, if just run B, A will be called first; just run C, A first call, then B, then C; run D, ​​A first call, then B, then C, finally D Note B and A will only be called once instead of twice.

2. If and unsses define a Target, the dependent properties are specified by IF and UNSS. For example: ->

You only define the property ENU before calling the TRANSENU, then this target will be executed. Note is definition, no matter what value is given to this property. Look at the results: Unless and IF, once this property is assigned, this target will not be executed. 3. Condition IF and Unless or dead, to remove the corresponding attributes or plus them to determine if they are executed. Use condition to add a point of flexibility:

Result: Condition task does not do anything outside of the property when you meet the condition . These conditions include NOT, AND, OR, Available, Uptodate, Os, Equals, Isset, Checksum, HTTP, Socket, FileSmatch, Contains, Istrue, IsFalse, IsReference. The properties of this setting can be used to trigger a Target that calls this property to IF / UnsS. Flow control using scripting language

Using ANT built-in process control, first is very troublesome, followed by only some simple if / unless judgment, slightly complicated loop traversal traversal traversal, no way to complete the system. Ant doesn't define a set of scripts yourself, but introduces external scripts. Ant supports a lot of scripts, from JavaScript, Python, Ruby, Beanshell, TCL, to Judoscript, and even define script languages ​​themselves. Unfortunately, is this not required to master a language? Let's talk about how to use a more common Mozilla JavaScript. First, download BSF from http://jakarta.apache.org/BSF/, I use BSF 2.3.0; go to http://www.mozilla.org/rhino/ download Rhino, I use Rhino1. 5r3. Put the JAR files

installation manual

> / lib

Under contents.

Here is a simple example: < Script language = "javascript">

转载请注明原文地址:https://www.9cbs.com/read-13732.html

New Post(0)