Conditions
You're creating an Ant build script, and you need to determine the operating system the script is running on, so you can make conditional decisions within the build script. You typically want/need to do this if you're going to run tasks/targets that are different for each operating system (Mac. Intego's Mac Premium Bundle X9 offers a ton of features and services. The company recently released more robust Windows malware detection for Macs, as well as a dedicated antivirus for Windows PCs.
Conditions are nested elements of the and
tasks. There are core conditions andcustom conditions. Custom conditions are describedin Custom Conditions. CoreConditions are described below.
Core Conditions
These are the nested elements that can be used as conditions inthe and
tasks.
not
The element expects exactly one other condition to be nested into thiselement, negating the result of the condition. It doesn't have any attributes and accepts allnested elements of the condition task as nested elements as well.
and
The element doesn't have any attributes and accepts an arbitrary numberof conditions as nested elements—all nested elements of the condition task are supported.This condition is true if all of its contained conditions are, conditions will be evaluated in theorder they have been specified in the build file.
The condition has the same shortcut semantics as theJava
&&
operator, as soon as one of the nested conditions is false, no othercondition will be evaluated.
or
The element doesn't have any attributes and accepts an arbitrary numberof conditions as nested elements—all nested elements of the condition task are supported.This condition is true if at least one of its contained conditions is, conditions will be evaluatedin the order they have been specified in the build file.
The condition has the same shortcut semantics as the Java
||
operator, as soon as one of the nested conditions is true, no other condition will be evaluated.
xor
The element performs an exclusive or on all nested elements, similar tothe
^
operator in Java. It only evaluates to true if an odd number of nested conditionsare true. There is no shortcutting of evaluation, unlike the and
tests. It doesn't have any attributes and accepts all nested elementsof the condition task as nested elements as well.
available
This condition is identical to the Available task, all attributesand nested elements of that task are supported, the property and value attributes are redundant andwill be ignored.
uptodate
This condition is identical to the Uptodate task, all attributes andnested elements of that task are supported, the property and value attributes are redundant and willbe ignored.
os
Test whether the current operating system is of a given type. Each defined attribute is testedand the result is true only if all the tests succeed.
Attribute | Description | Required |
---|---|---|
family | The name of the operating system family to expect. | No |
name | The name of the operating system to expect. | No |
arch | The architecture of the operating system to expect. | No |
version | The version of the operating system to expect. | No |
Supported values for the family attribute are:
windows
—for all versions of Microsoft Windowsdos
—for all Microsoft DOS based operating systems including Microsoft Windows and OS/2mac
—for all Apple Macintosh systems prior to Mac OS Xunix
—for all Unix(-like) operating systems, including Linux and Mac OS X/macOSnetware
—for Novell NetWareos/2
—for OS/2tandem
—for HP's NonStop Kernel, formerly Tandemwin9x
—for Microsoft Windows 95 and 98, ME and CEwinnt
—for Microsoft Windows NT-based systems, including Windows 2000, XP and successorsz/os
—for z/OS and OS/390os/400
—for OS/400openvms
—for OpenVMS
equals
Tests whether the two given values are equal.
Attribute | Description | Required |
---|---|---|
arg1 | First value to test. | Yes |
arg2 | Second value to test. | Yes |
casesensitive | Perform a case sensitive comparison. | No; default is true |
trim | Trim whitespace from arguments before comparing them. | No; default is false |
forcestring | Force string comparison of arg1/arg2. Since Apache Ant 1.8.1 | No; default is false |
isset
Test whether a given property has been set in this project.
Attribute | Description | Required |
---|---|---|
property | The name of the property to test. | Yes |
checksum
This condition is identical to the Checksum task, all attributes andnested elements of that task are supported, the property and overwrite attributes are redundant andwill be ignored.
http
The http
condition checks for a valid response from a web server of the specifiedURL. By default, HTTP responses errors of 400 or greater are viewed as invalid.
Attribute | Description | Required |
---|---|---|
url | The full URL of the page to request. The web server must return a status code below the value of errorsBeginAt | Yes |
errorsBeginAt | The lowest HTTP response code that signals an error; server errors, not-authorized, not-found and the like are detected | No; default is 400 |
requestMethod | The HTTP method to be used when issuing the request. Any of GET, POST, HEAD, OPTIONS, PUT, DELETEand TRACEare valid, subject to protocol restrictions. since Ant 1.8.0 | No; default is GET |
followRedirects | Whether redirects should be followed. since Ant 1.9.7 | No; default is true |
readTimeout | Read timeout, in milliseconds, that will be used while reading from the target URL. Accepts any value ≥ 0. Value of 0 implies wait indefinitely. Value < 0 will be silently ignored. since Ant 1.10.6 | No; defaults to 0 |
socket
The socket
condition checks for the existence of a TCP/IP listener at the specifiedhost and port.
Attribute | Description | Required |
---|---|---|
server | The DNS name or IP address of the server. | Yes |
port | The port number to connect to. | Yes |
filesmatch
Test two files for matching. Nonexistence of one file results in false
, although ifneither exists they are considered equal in terms of content. This test does a byte for bytecomparison, so test time scales with byte size. Note: if the files are differentsizes, one of them is missing or the filenames match the answer is so obvious the detailed test isomitted.
Attribute | Description | Required |
---|---|---|
file1 | First file to test | Yes |
file2 | Second file to test | Yes |
textfile | Whether to ignore line endings when comparing files. Since Ant 1.7 | No; defaults to falsewhich triggers a binary comparison |
contains
Build in time mac os. Tests whether a string contains another one.
Attribute | Description | Required |
---|---|---|
string | The string to search in. | Yes |
substring | The string to search for. | Yes |
casesensitive | Perform a case sensitive comparison. | No; default is true |
istrue
Tests whether a string equals any of the Ant definitions of true, thatis true
, yes
, or on
Attribute | Description | Required |
---|---|---|
value | value to test | Yes |
isfalse
Tests whether a string is not true, the negation of
Attribute | Description | Required |
---|---|---|
value | value to test | Yes |
isreference
Test whether a given reference has been defined in this project and—optionally—is ofan expected type.
Since Apache Ant 1.6.
Attribute | Description | Required |
---|---|---|
refid | The id of the reference to test. | Yes |
type | Name of the data type or task this reference is expected to be. | No |
issigned
Test whether a jarfile is signed. If the name of the signature is passed, the file is checkedfor presence of that particular signature; otherwise the file is checked for the existence of anysignature. It does not perform rigorous signature validation; it only looks for the presence of asignature.
Since Apache Ant 1.7.
Attribute | Description | Required |
---|---|---|
file | The jarfile that is to be tested for the presence of a signature. | Yes |
name | The signature name to check for. | No |
isfileselected
Test whether a file passes an embedded selector.
Since Apache Ant 1.6.3.
Attribute | Description | Required |
---|---|---|
file | The file to check if is passes the embedded selector. | Yes |
basedir | The base directory to use for name based selectors. It this is not set, the project's basedir will be used. | No |
Example usage:
typefound
Test whether a given type is defined, and that its implementation class can be loaded. Typesinclude tasks, datatypes, scriptdefs, macrodefs and presetdefs.
Since Apache Ant 1.7.
Attribute | Description | Required |
---|---|---|
name | Name of the type | Yes |
uri | The URI that this type lives in. | No |
Example usages:
scriptcondition
Evaluate a condition based on a script in any Apache BSFor JSR 223 supported language.
See the Script task for an explanation of scripts anddependencies.
Since Apache Ant 1.7.
Attribute | Description | Required |
---|---|---|
language | script language | Yes |
manager | The script engine manager to use. See the script task for using this attribute. | No; default is auto |
value | default boolean value | No; default is false |
src | filename of script source | No |
encoding | The encoding of the script source. Since Ant 1.10.2. | No; defaults to default JVM character encoding |
setbeans | whether to have all properties, references and targets as global variables in the script. since Ant 1.8.0 | No; default is true |
classpath | The classpath to pass into the script. | No |
classpathref | The classpath to use, given as a reference to a path defined elsewhere. | No |
Parameters specified as nested elements
classpathHackz memories mac os. See the script task for using this nested element.
Description
The script supports script language inline, this script has access to the same beans asthe </code> task, and to the <code>self</code> bean, which refers back to thecondition itself. If the script evaluates to a boolean result, this is the result of the condition'sevaluation (<em>since Ant 1.7.1</em>). Alternatively, <code>self.value</code> can be used to setthe evaluation result.</p><p>Example:</p><p>Sets the default value of the condition to <q>true</q>, then in the script, sets the valueto <q>false</q>. This condition always evaluates to <q>false</q>. <a href='https://site-4775595-9827-2056.mystrikingly.com/blog/plague-doctor-gxpinheiro-mac-os'>Plague doctor (gxpinheiro) mac os</a>.</p><h4>parsersupports</h4><p>Tests whether Ant's XML parser supports a given feature or property, as per the SAX/JAXPspecifications, by attempting to set the appropriate property/feature</p><p><em>Since Apache Ant 1.7</em>.</p><table><tbody><tr><th scope='col'>Attribute</th><th scope='col'>Description</th><th scope='col'>Required</th></tr><tr><td>property</td><td>property to set</td><td rowspan='2'>Exactly one of the two</td></tr><tr><td>feature</td><td>feature to set</td></tr><tr><td>value</td><td>string (property) or boolean (feature)</td><td>For property tests, but not for feature tests</td></tr></tbody></table><p>Check for namespace support. All SAX2 parsers should have this.</p><p>Check for XML Schema support. <a href='https://lucky-mobile-casino-red-app-ql-bonusmost.peatix.com'>Lucky red casino mobile app</a>.</p><p>Check for Xerces-specific definition of the location of the no namespace schema.</p><h4>isreachable</h4><p>Uses Java 5+ networking APIs to probe for a (remote) system being reachable. Exactly what probemechanisms are used is an implementation feature of the JVM. They may include ICMP 'ping' packets,UDP or TCP connections to port 7 'echo service' or other means.</p><p>This condition turns unknown host exceptions into false conditions. This is because on a laptop,DNS is one of the first services when the network goes; you are implicitly offline.</p><p>If a URL is supplied instead of a <var>host</var>, the hostname is extracted and used in thetest—all other parts of the URL are discarded.</p><p>The test may not work through firewalls, that is, something may be reachable using a protocolsuch as HTTP, while the lower level ICMP packets get dropped on the floor. Similarly, a host maydetected as reachable with ICMP, but not reachable on other ports (i.e. port 80), because offirewalls.</p><p><em>Since Apache Ant 1.7</em>.</p><table><tbody><tr><th scope='col'>Attribute</th><th scope='col'>Description</th><th scope='col'>Required</th></tr><tr><td>host</td><td>host to check for</td><td rowspan='2'>Exactly one of the two</td></tr><tr><td>url</td><td>URL containing hostname</td></tr><tr><td>timeout</td><td>timeout in seconds</td><td>No; default is <q>30</q></td></tr></tbody></table><p>Probe for the Maven repository being reachable.</p><p>Probe for the Maven repository being reachable using the hostname, ten second timeout. <a href='https://site-4776308-4882-3371.mystrikingly.com/blog/mokmok-mac-os' title='Mokmok mac os'>Mokmok mac os</a>.</p><h4>length</h4><p><em>Since Ant 1.6.3</em></p><p>This condition is a facet of the Length task. It is used to test thelength of a string or one or more files.</p><p>Verify a string is of a certain length.</p><p>Verify that file <samp>foo</samp> is not empty.</p><h4>isfailure</h4><p><em>Since Ant 1.7</em></p><p>Test the return code of an executable (see the Exec task) forfailure.</p><table><tbody><tr><th scope='col'>Attribute</th><th scope='col'>Description</th><th scope='col'>Required</th></tr><tr><td>code</td><td>The return code to test.</td><td>Yes</td></tr></tbody></table><h4>resourcecount</h4><p><em>Since Ant 1.7</em></p><p>This condition is a facet of the ResourceCount task. It is usedto test the size of a resourcecollection.</p><p>Verify that a resource collection is not empty.</p><h4>resourcesmatch</h4><p><em>Since Ant 1.7</em></p><p>Test resources for matching. Nonexistence of one or more resources results in <q>false</q>,although if none exists they are considered equal in terms of content. By default, this test does abyte for byte comparison, so test time scales with byte size. <strong>Note</strong>: if the filesare different sizes, one of them is missing or the filenames match the answer is so obvious thedetailed test is omitted. The resources to check are specified asnested resource collections, meaning that more thantwo resources can be checked; in this case all resources must match.</p><table><tbody><tr><th scope='col'>Attribute</th><th scope='col'>Description</th><th scope='col'>Required</th></tr><tr><td>astext</td><td>Whether to ignore line endings when comparing resource content; <q>true</q> triggers a binary comparison.</td><td>No; defaults to <q>false</q></td></tr></tbody></table><h4>resourcecontains</h4><p><em>Since Ant 1.7.1</em></p><p>Tests whether a resource contains a given (sub)string.</p><p>The resources to check are specified via references or—in the case of fileresources—via the <var>resource</var> attribute. <a href='https://petorrent.mystrikingly.com/blog/note-chomper-mac-os'>Note chomper mac os</a>.</p><table><tbody><tr><th scope='col'>Attribute</th><th scope='col'>Description</th><th scope='col'>Required</th></tr><tr><td>resource</td><td>Name of a file that is the resource to test.</td><td rowspan='2'>Exactly one of the two</td></tr><tr><td>refid</td><td>Reference to a resource defined inside the project.</td></tr><tr><td>substring</td><td>The string to search for.</td><td>Yes</td></tr><tr><td>casesensitive</td><td>Perform a case sensitive comparison.</td><td>No; default is <q>true</q></td></tr></tbody></table><h4>hasmethod</h4><p><em>Since Ant 1.7</em></p><p>Tests for a class having a method or field. If the class is not found or fails to load, the buildfails.</p><table><tbody><tr><th scope='col'>Attribute</th><th scope='col'>Description</th><th scope='col'>Required</th></tr><tr><td>classname</td><td>name of the class to load</td><td>yes</td></tr><tr><td>field</td><td>name of a field to look for</td><td rowspan='2'>Exactly one of the two</td></tr><tr><td>method</td><td>name of a method to look for</td></tr><tr><td>ignoreSystemClasses</td><td>should system classes be ignored?</td><td>No; default is <q>false</q></td></tr><tr><td>classpath</td><td>a class path</td><td>No</td></tr><tr><td>classpathref</td><td>reference to a class path</td><td>No</td></tr></tbody></table><p>There is also a nested <code><classpath></code> element, which can be used to specify aclasspath.</p><p>Looks for the method <code>trimToSize()</code> inthe <code>java.util.ArrayList</code> class.</p><h4>matches</h4><p><a href='https://site-4775991-2610-5411.mystrikingly.com/blog/space-prank-mac-os'>Space prank mac os</a>. <em>Since Ant 1.7</em></p><p>Test if the specified string matches the specified regular expression pattern</p><table><tbody><tr><th scope='col'>Attribute</th><th scope='col'>Description</th><th scope='col'>Required</th></tr><tr><td>string</td><td>The string to test.</td><td>Yes</td></tr><tr><td>pattern</td><td>The regular expression pattern used to test.</td><td>Yes, unless there is a nested <code><regexp></code> element</td></tr><tr><td>casesensitive</td><td>Perform a case sensitive match.</td><td>No; default is <q>true</q></td></tr><tr><td>multiline</td><td>Perform a multi line match.</td><td>No; default is <q>false</q></td></tr><tr><td>singleline</td><td>This allows <q>.</q> to match new lines. <var>SingleLine</var> is not to be confused with multiline, <var>SingleLine</var> is a perl regex term, it corresponds to <var>dotall</var> in Java regex.</td><td>No; default is <q>false</q></td></tr></tbody></table><p>There is also an optional <code><regexp></code> element, which can be used to specify aregular expression instead of the <var>pattern</var> attribute.See Regexp Type for the description of the nested element regexpand of the choice of regular expression implementation.</p><p>An example:</p><p>The following example sets the property <code>ok</code> if the property <code>input</code> isthree characters long, starting with <q>a</q> and ending with <q>b</q>.</p><p>The following defines a reference regular expression for matching dates and then uses antunit tocheck if the property <code>today</code> is in the correct format:</p><p>The following example shows the use of the <var>singleline</var> and the <var>casesensitive</var>flags.</p><h4>antversion</h4><p>This condition is identical to the Antversion task, all attributesare supported, the <var>property</var> attribute is redundant and will be ignored.</p><h4>hasfreespace</h4><p><em>Since Ant 1.7.0</em></p><p>Tests a partition to see if there is enough space.</p><p>Needed attribute can be specified using standard computing terms:</p><ul><li>K : Kilobytes (1024 bytes)</li><li>M : Megabytes (1024 K)</li><li>G : Gigabytes (1024 M)</li><li>T : Terabytes (1024 G)</li><li>P : Petabytes (1024 T)</li></ul><table><tbody><tr><th scope='col'>Attribute</th><th scope='col'>Description</th><th scope='col'>Required</th></tr><tr><td>partition</td><td>The partition or filesystem to check for free space</td><td>Yes</td></tr><tr><td>needed</td><td>The amount of free space needed.</td><td>Yes</td></tr></tbody></table><p>An example:</p><h4>islastmodified</h4><p><em>Since Ant 1.8.0</em></p><p>Tests the last modified date of a resource.</p><h2 id='cricket-and-the-ant-mac-os-catalina'>Cricket And The Ant Mac Os Catalina</h2><table><tbody><tr><th scope='col'>Attribute</th><th scope='col'>Description</th><th scope='col'>Required</th></tr><tr><td>millis</td><td>Specifies the expected modification time of the resource in milliseconds since midnight Jan 1 1970.</td><td rowspan='2'>Exactly one of the two</td></tr><tr><td>datetime</td><td>Specifies the expected modification time of the resource. The special value <q>now</q> indicates the current time.</td></tr><tr><td>pattern</td><td>SimpleDateFormat-compatible pattern string.</td><td>No; defaults to <q>MM/dd/YYYY hh:mm a</q> or <q>MM/dd/YYYY hh:mm:ss a</q></td></tr><tr><td>mode</td><td>How to compare the timestamp. Accepted values are <q>equals</q>, <q>before</q>, <q>not-before</q>, <q>after</q> and <q>not-after</q>. </td><td>No; defaults to <q>equals</q></td></tr></tbody></table><p>The actual resource to test is specified as a nested element.</p><p>An example:</p><h4>resourceexists</h4><p><em>Since Ant 1.8.0</em></p><p>Tests a resource for existence.</p><p>The actual resource to test is specified as a nested element.</p><p>An example:</p><h4>javaversion</h4><p><em>Since Ant 1.10.2</em></p><p>Tests the version of the JVM executing Ant.</p><h2 id='cricket-and-the-ant-mac-os-pro'>Cricket And The Ant Mac Os Pro</h2><table><tbody><tr><th scope='col'>Attribute</th><th scope='col'>Description</th><th scope='col'>Required</th></tr><tr><td>atleast</td><td>The version that this JVM is of at least. The format is <code>major.minor.point</code>. Starting with Java 9 really only the major number is determined.</td><td rowspan='3'>Exactly one of the three</td></tr><tr><td>atmost</td><td>The version that this JVM is of at most. The format is <code>major.minor.point</code>. Starting with Java 9 really only the major number is determined.<br><em>Since Ant 1.10.10</em></td></tr><tr><td>exactly</td><td>The version that this JVM is of exactly. The format is <code>major.minor.point</code>. Starting with Java 9 really only the major number is determined.</td></tr></tbody></table><p>An example:</p><p>will evaluate to true if the current JVM is Java 9 or above.</p><br><br><br><br>