Ant-contrib.unkrig.de: Difference between revisions

From unkrig.de
Jump to navigation Jump to search
No edit summary
 
(53 intermediate revisions by the same user not shown)
Line 1: Line 1:
== Abstract ==
<meta name="keywords" content="apache, ant, antlib, library, extension, tasks, types, filters"></meta>
Some contributions to APACHE ANT, e.g. the <code><swingDialog></code> task which significantly enhances ANT's <code><input></code> task.
<meta name="description" content="A library for APACHE ANT that contributes many useful, resource collections, and other types"></meta>
This project was renamed to "[[Antology]]" to get rid of the constant confusion with the (related, but otherwise independent) "[http://ant-contrib.sourceforge.net/ ant-contrib]" project on SOURCEFORGE.


== Tasks ==
As a consequence, in all your ANT build scripts, you have to change


=== <code><follow></code> ===
  <taskdef resource="de/unkrig/antcontrib/ant.xml" classpath="path/to/de.unkrig.ant-contrib.jar" />
Waits until a file grows.


The name refers to the 'follow mode' of the LESS utility (or the 'follow' option of the TAIL command), which does more or less the same.
to


===== '''Attributes''' =====
  <taskdef resource="de/unkrig/antology/ant.xml" classpath="path/to/antology-x.y.z-jar-with-dependencies.jar" />
;<code>file="..."</code> (mandatory)
:The file to monitor.


;<code>outputFile="..."</code> (optional)
. That's all, folks!
:Write the additional data to the named file.
 
;<code>stdout="true"</code> (optional)
:Write the additional data to STDOUT.
 
;<code>stderr="true"</code> (optional)
:Write the additional data to STDERR.
 
;<code>encoding="..."</code> (optional)
:If a <code><filterchain></code> is configured, then the data from the <code>file</code> is DECODED with this encoding, then fed through the <code><filterchain></code>, and then ENCODED again. Defaults to the system default encoding.
 
;<code>periodTime="..."</code> (optional)
:The period in milliseconds to check the file's size. The default is 500.
 
;<code>timeout="..."</code> (optional)
:The time (in seconds) when to give up if the file size does not change. The default is 300 (5 minutes); a value of '0' indicates to wait indefinitely.
 
;<code>failOnTimeout="false"</code> (optional)
:Whether the execution of the current target should fail or not if the file size does not change. The default is to fail on timeout.
 
===== '''Subelements''' =====
 
;<code><filterchain></code>
:If given, then the data that is added to the file is fed through this [http://ant.apache.org/manual/Types/filterchain.html <code><filterchain></code>], and the task will complete only when the <code><filterchain></code> produces some output. This is useful to check if a specific line of text was appended to the file.
 
=== <code><jsonProperty></code> ===
 
Parses a JSON document into a set of properties, in analogy with [http://ant.apache.org/manual/Tasks/xmlproperty.html the standard ANT <code><xmlproperty></code> task].
 
===== '''Attributes''' =====
;<code>file="..."</code> (mandatory)
:The file from which to read the JSON document.
 
;<code>encoding="..."</code> (optional)
:The encoding of the JSON document. The default is 'UTF-8'.
 
;<code>name="..."</code> (mandatory)
:The prefix of the names of the properties to set.
 
=== <code><nslookup></code> ===
 
Resolves a host name or IP address.
 
===== '''Attributes''' =====
 
;<code>host="..."</code> (mandatory)
:Either a machine name, such as "java.sun.com", or a textual representation of its IP address. For host specified in literal IPv6 address, either the form defined in RFC 2732 or the literal IPv6 address format defined in RFC 2373 is accepted. [http://docs.oracle.com/javase/6/docs/api/java/net/Inet6Address.html#scoped IPv6 scoped addresses] are also supported.
 
;<code>addressProperty="..."</code> (optional)
:The IP address of the host is determined and stored in the given property.
 
;<code>addressesProperty="..."</code> (optional)
:The IP addresses of the host are determined, based on the configured name service on the system, and stored in the given property, separated by commas.
 
;<code>hostName="..."</code> (optional)
:Performs a reverse name lookup, based on the system configured name lookup service, and the result is stored in the given property.
 
;<code>canonicalHostName="..."</code> (optional)
:Performs a reverse name lookup, based on the system configured name lookup service, and the result is stored in the given property.
 
;<code>failOnError="false"</code>
:Whether or not the execution of the current target should fail if the host name or address cannot resolved. The default is "true".
 
=== <code><setAuthenticator></code> ===
 
This task configures the authentication for all following [http://docs.oracle.com/javase/6/docs/api/java/net/HttpURLConnection.html <code>java.net.URLConnection</code>]s, e.g. those created by the [[#<urlConnection>|<code><urlConnection></code>]] task. It does this by matching a request against the configured <code><credentials></code> subelements and using password authentication as configured by the first matching <code><credentials></code> element.
 
===== '''Subelements''' =====
;<code><credentials requestingHost="localhost" requestingSite="127\.0\.0\.1" requestingPort="80" requestingProtocol="http" requestingPrompt="The Realm" requestingScheme="http" requestingUrl="<nowiki>http://acme\.com</nowiki>" requestorType="SERVER-or-PROXY" userName="..." password="..." /></code> (zero or more)
:If the request matches all the <code>requesting...</code> and <code>requestor...</code> attributes (all of which are regular expressions), then
* If both <code>userName="..."</code> and <code>password="..."</code> are given, then these determine the <code>PasswordAuthentication</code>
* If none of <code>userName="..."</code> and <code>password="..."</code> are given, then the user is prompted to enter the user name and password
* If only one of <code>userName="..."</code> and <code>password="..."</code> is given, then it is displayed to the user, and the user is prompted to enter the other
 
=== <code><setCookieHandler></code> ===
 
Enables or disables cookie handling for Java's [http://docs.oracle.com/javase/6/docs/api/java/net/HttpURLConnection.html <code>java.net.HttpURLConnection</code>], including the [[#<urlConnection>|<code><urlConnection></code>]] task.
 
===== '''Attributes''' =====
;<code>enable="false"</code>
:Whether to enable or disable cookie handling. The default is <code>true</code>. Initially, cookie handling is disabled.
 
=== <code><swingDialog></code> ===
 
Pops up a highly configurable dialog and invites the user to fill in form fields.
 
This task will fail iff the CANCEL button is pressed or the dialog is closed, except if <code><ifCancelTask></code>'s (or <code><ifClosedTask></code>'s, respectively) are configured.
 
[[File:swing-dialog.png]]
 
===== '''Attributes''' =====
;<code>title="..."</code> (optional): The text to be displayed in the title bar of the dialog.
;<code>optionType="..."</code> (optional): DEFAULT (an 'OK' button), YES_NO, YES_NO_CANCEL, OK_CANCEL (the default): Determines which buttons are displayed in the dialog.
;<code>messageType="..."</code> (optional): ERROR, INFORMATION, WARNING, QUESTION, PLAIN (the default): If not set to PLAIN, then a respective icon is displayed in the dialog.
;<code>property="..."</code> (optional): The named property will be set to YES, NO, CANCEL, OK or CLOSED when the task completes.
 
===== '''Subelements''' =====
;<code><label text="..." /></code> (zero or more)
: Displays the given text.
 
;<code><text property="..." defaultValue="..." /></code> (zero or more)
: A one-line text input field with an (optional) default value. On return, the named property is set to the text of the field. Iff <code>secure="true"</code> is given, then characters entered into the field are not echoed.
 
;<code><checkbox text="..." property="..." preselected="true" /></code> (zero or more)
: A checkbox with a label. On return, the named property is set to <code>true</code> iff the box is checked.
 
;<code><list selectionMode="SINGLE SINGLE_INTERVAL MULTIPLE_INTERVAL" values="..." defaultValues="..." delimiters="..." property="..." /></code> (zero or more)
:A list for selection of zero, one or more values as configured by <code>values="..."</code> and <code>delimiters="..."</code>. On completion, the named <code>property="..."</code> is set from the selected values, concatenated with the first of the <code>delimiter="..."</code> characters. The default delimiter is ",".
 
;<code><ifYes></code>, <code><ifNo></code>, <code><ifCancel></code>, <code><ifOk></code>, <code><ifClosed></code> (at most one of each)
:These can have task subelements, which are executed iff the respective dialog button is pressed (<code><ifYes></code>, <code><ifNo></code>, <code><ifCancel></code>, <code><ifOk></code>) or the dialog is closed (<code><ifClosed></code>).
 
=== <code><urlConnection></code> ===
 
Connects to a resource and writes data to it and/or reads data from it.
 
===== '''Attributes''' =====
;<code>url="..."</code>, <code>allowUserInteraction="..."</code>, <code>connectTimeout="..."</code>, <code>readTimeout="..."</code> <code>defaultUseCaches="..."</code>, <code>ifModifiedSince="..."</code>, <code>useCaches="..."</code> (all optional)
:The various parameters of the [http://docs.oracle.com/javase/6/docs/api/java/net/URLConnection.html <code>java.net.URLConnection</code>].
 
;<code>httpChunkLength="..."</code>, <code>httpContentLength="..."</code>, <code>httpFollowRedirects="true"</code>, <code>httpRequestMethod="..."</code> (all optional)
:Various pararmeters that apply iff the <code>URLConnection</code> is an [http://docs.oracle.com/javase/6/docs/api/java/net/HttpURLConnection.html <code>java.net.HttpURLConnection</code>].
 
;<code>httpFollowRedirects2="true"</code> (optional)
:Implements an enhanced redirect processing which, specifically, allows for redirection between different protocols, e.g. from HTTP to HTTPS and vice versa.
 
===== '''Subelements''' =====
;<code><url></code> (zero or one)
:An alternative to the <code>url="..."</code> attribute described above; configures the URL by its components.<br>'''Attributes'''<dl><dt><code>context="..."</code> (optional)<dd>The 'base URL' for a relative URL (an alternative for the <code><context></code> element described below).<dt><code>protocol="..."</code> (optional)<dd>The 'protocol' component of the URL; defaults to <code>http</code>.<dt><code>host="..."</code> (optional)<dd>The 'host' component of the URL; defaults to <code>localhost</code>.<dt><code>port="..."</code> (optional)<dd>The 'port' component of the URL.<dt><code>userInfo="..."</code> (optional)<dd>The 'userinfo' component of the URL, like <code>user [ ':' password ]</code>.<dt><code>path="..."</code> (optional)<dd>The 'path' component of the URL; defaults to <code>/</code>.<dt><code>query="..."</code> (optional)<dd>The 'query' component of the URL, is appended to the URL with '?'.<dt><code>ref="..."</code> (optional)<dd>The 'ref' component of the URL, is appended to the URL with '#'.</dl>'''Sub-subelements'''<dl><dt><code><formField name="..." value="..."></code> (zero or more)<dd>Are combined with the <code>query="..."</code> attribute to pose the URL's query string.<dt><code><context></code> (zero or one)<dd>The 'base URL' for a relative URL (an alternative for the <code>context="..."</code> attribute described above); attributes and subelements are identical with the <code><url></code> element.</dl>
 
;<code><requestProperty name="..." value="..." /></code> (zero or more)
:Adds one property to the request; for HTTP connections these are mapped to request headers.
 
;<code><output value="..." encoding="..." /></code> (zero or one)
:If given, then data is written to the resource. That data is obtained from the <code>value="..."</code> and <code>encoding="..."</code> attributes.
 
;<code><output file="..." /></code> (zero or one)
:If given, then data is written to the resource. That data is obtained from the named <code>file="..."</code>.
 
;<code><output><multipartFormData name="..." fileName="..." value="..." file="..." /></output></code> (zero or one)
:If given, then data is written to the resource. That data is obtained from one or more <code><multipartFormData></code> subelements.
 
;<code><output><applicationXWwwFormUrlencoded name="..." value="..." /></output></code> (zero or one)
:If given, then data is written to the resource. That data is obtained from one or more <code><applicationXWwwFormUrlencoded></code> subelements.
 
;<code><input file="..." /></code> (zero or one)
:If given, then data is read from the resource and written to the named <code>file="..."</code>.
 
;<code><input><jsonAsProperties name="..." /></input></code> (zero or one)
:If given, then data is read from the resource and parsed as a JSON document (see [[#<jsonProperty>|<code><jsonProperty></code>]]).
 
;<code><input /></code> (zero or one)
:If given, then data is read from the resource and written to STDOUT.
 
== Resource Collections ==
 
=== <code><resourceCollectionDelta></code> ===
 
Selects the subset of resources that was added, deleted or modified since the last check.
 
===== '''Attributes''' =====
;<code>stateFile="..."</code>
:Where to store state information. If this file is deleted, then all resources appear as 'added'. The default is '$HOME/.resource-collection.delta.properties'.
 
;<code>added="true"</code>
:Whether the files that were ADDED to the resource collection subelement since the last invocation should be returned.
 
;<code>deleted="true"</code>
:Whether the files that were DELETED from the resource collection subelement since the last invocation should be returned.
 
;<code>modified="true"</code>
:Whether the files in the resource collection subelement that were MODIFIED since the last invocation should be returned.
 
===== '''Subelements''' =====
;Resource collection (<code><fileset></code>, ...)
:The resources to monitor.
 
== Filter Readers ==
 
=== <code><progress></code> ===
Prints dots (".") to STDERR as data is read through it. This implements a kind of 'progress monitoring' for slow tasks that read some data.
 
===== '''Attributes''' =====
;<code>bytesPerTick="..."</code>
:That many bytes must be processed before another dot is printed. The default is '1024'.
 
;<code>exponential="false"</code>
:If true, then the initial dot printing frequency will degrade so that no more than 80 dots will ever be printed. The default is <code>true</code>.
 
== Download and installation ==
 
The JAR file can be downloaded from http://ant-contrib.unkrig.de/download/.
 
To make the contributions available in your ANT scripts, write
 
<taskdef resource="de/unkrig/antcontrib/ant.xml" classpath="lib/de.unkrig.ant-contrib.jar" />
 
, or, if you put the JAR file on ANT's default classpath, just
 
<taskdef resource="de/unkrig/antcontrib/ant.xml" />
 
== Source code ==
 
The source code is available in the SUBVERSION repository. The repository URL is
 
https://svn.code.sf.net/p/loggifier/code
 
== License ==
 
ANT-CONTRIB is published under the "[[New BSD License]]".

Latest revision as of 09:58, 17 November 2016

<meta name="keywords" content="apache, ant, antlib, library, extension, tasks, types, filters"></meta> <meta name="description" content="A library for APACHE ANT that contributes many useful, resource collections, and other types"></meta> This project was renamed to "Antology" to get rid of the constant confusion with the (related, but otherwise independent) "ant-contrib" project on SOURCEFORGE.

As a consequence, in all your ANT build scripts, you have to change

 <taskdef resource="de/unkrig/antcontrib/ant.xml" classpath="path/to/de.unkrig.ant-contrib.jar" />

to

 <taskdef resource="de/unkrig/antology/ant.xml" classpath="path/to/antology-x.y.z-jar-with-dependencies.jar" />

. That's all, folks!