Top Description Inners Fields Constructors Methods
org.apache.tools.ant.taskdefs.optional.script

public Class ScriptDef

extends DefBase
Class Inheritance
Imports
java.io.File, java.util.ArrayList, .HashMap, .HashSet, .LinkedHashMap, .List, .Locale, .Map, .Set, java.util.stream.Collectors, org.apache.tools.ant.AntTypeDefinition, .BuildException, .ComponentHelper, .MagicNames, .Project, .ProjectHelper, org.apache.tools.ant.taskdefs.DefBase, org.apache.tools.ant.types.ResourceCollection, org.apache.tools.ant.util.ClasspathUtils, .ScriptManager, .ScriptRunnerBase, .ScriptRunnerHelper

Defines a task using a script.
Since
Ant 1.6

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
ScriptDef.Attribute

Class representing an attribute definition

public static class
ScriptDef.NestedElement

Class to represent a nested element definition

Field Summary

Modifier and TypeField and Description
private List<ScriptDef.Attribute>
attributes

Attributes definitions of this script

private Set<String>
attributeSet

The attribute names as a set

private ScriptRunnerHelper
helper

script runner helper

private String
name

the name by which this script will be activated

private Map<String, ScriptDef.NestedElement>
nestedElementMap

The nested element definitions indexed by their names

private List<ScriptDef.NestedElement>
nestedElements

Nested Element definitions of this script

Constructor Summary

AccessConstructor and Description
public
ScriptDef()

Create a new ScriptDef.

Method Summary

Modifier and TypeMethod and Description
public void
add(ResourceCollection
source of script
resource
)

Adds any source resource.

public void
addAttribute(ScriptDef.Attribute
the attribute definition.
attribute
)

Adds an attribute definition to this script.

public void
addElement(ScriptDef.NestedElement
the nested element definition.
nestedElement
)

Adds a nested element definition.

public void
addText(String
a component of the script text to be added.
text
)

Sets the script text.

public Object

Returns:

object representing the element name.
createNestedElement
(String
the name of the nested element.
elementName
)

Creates a nested element to be configured.

public void
execute()

Overrides org.apache.tools.ant.Task.execute.

Defines the script.
public void
executeScript(Map<String, String>
collection of attributes
attributes
,
Map<String, List<Object>>
a list of nested element values.
elements
)

Deprecated since 1.7. Use executeScript(attribute, elements, instance) instead.
Executes the script.
public void
executeScript(Map<String, String>
collection of attributes
attributes
,
Map<String, List<Object>>
a list of nested element values.
elements
,
ScriptDefBase
the script instance; can be null
instance
)

Executes the script.

public boolean

Returns:

true if the attribute is supported by the script.
isAttributeSupported
(String
the name of the attribute.
attributeName
)

Indicates whether the task supports a given attribute name

private Map<String, ScriptDef>

Returns:

the current script repository registered as a reference.
lookupScriptRepository
()

Finds or creates the script repository - it is stored in the project.

public void
setCompiled(boolean
enables the script compilation if available.
compiled
)

Defines the compilation feature; optional.

public void
setEncoding(String
the encoding of the file containing the script source.
encoding
)

Sets the encoding of the script from an external file; optional.

public void
setLanguage(String
the scripting language name for the script.
language
)

Defines the language (required).

public void
setManager(String
the scripting manager.
manager
)

Deprecated
Defines the manager.
public void
setManager(ScriptManager manager)

Set the script manager.

public void
setName(String
the name of the script
name
)

Sets the name under which this script will be activated in a build file

public void
setProject(Project
the project that this definition belongs to.
project
)

Overrides org.apache.tools.ant.ProjectComponent.setProject.

Set the project.
public void
setSetBeans(boolean
the value to set.
setBeans
)

Set the setbeans attribute.

public void
setSrc(File
the file containing the script source.
file
)

Loads the script from an external file; optional.

private Map<String, String>
withDefault(Map<String, String> attributes)

Inherited from org.apache.tools.ant.taskdefs.DefBase:
createClasspathcreateLoadergetClasspathgetClasspathIdgetLoaderIdhasCpDelegateinitisReverseLoadersetClasspathsetClasspathRefsetLoaderRefsetReverseLoader

Field Detail

attributesback to summary
private List<ScriptDef.Attribute> attributes

Attributes definitions of this script

attributeSetback to summary
private Set<String> attributeSet

The attribute names as a set

helperback to summary
private ScriptRunnerHelper helper

script runner helper

nameback to summary
private String name

the name by which this script will be activated

nestedElementMapback to summary
private Map<String, ScriptDef.NestedElement> nestedElementMap

The nested element definitions indexed by their names

nestedElementsback to summary
private List<ScriptDef.NestedElement> nestedElements

Nested Element definitions of this script

Constructor Detail

ScriptDefback to summary
public ScriptDef()

Create a new ScriptDef.

Method Detail

addback to summary
public void add(ResourceCollection resource)

Adds any source resource.

Parameters
resource:ResourceCollection

source of script

Since
Ant 1.7.1
addAttributeback to summary
public void addAttribute(ScriptDef.Attribute attribute)

Adds an attribute definition to this script.

Parameters
attribute:ScriptDef.Attribute

the attribute definition.

addElementback to summary
public void addElement(ScriptDef.NestedElement nestedElement)

Adds a nested element definition.

Parameters
nestedElement:ScriptDef.NestedElement

the nested element definition.

addTextback to summary
public void addText(String text)

Sets the script text.

Parameters
text:String

a component of the script text to be added.

createNestedElementback to summary
public Object createNestedElement(String elementName)

Creates a nested element to be configured.

Parameters
elementName:String

the name of the nested element.

Returns:Object

object representing the element name.

executeback to summary
public void execute()

Overrides org.apache.tools.ant.Task.execute.

Defines the script.

Annotations
@Override
executeScriptback to summary
public void executeScript(Map<String, String> attributes, Map<String, List<Object>> elements)

Deprecated

since 1.7. Use executeScript(attribute, elements, instance) instead.

Executes the script.

Parameters
attributes:Map<String, String>

collection of attributes

elements:Map<String, List<Object>>

a list of nested element values.

Annotations
@Deprecated
executeScriptback to summary
public void executeScript(Map<String, String> attributes, Map<String, List<Object>> elements, ScriptDefBase instance)

Executes the script. This is called by the script instance to execute the script for this definition.

Parameters
attributes:Map<String, String>

collection of attributes

elements:Map<String, List<Object>>

a list of nested element values.

instance:ScriptDefBase

the script instance; can be null

isAttributeSupportedback to summary
public boolean isAttributeSupported(String attributeName)

Indicates whether the task supports a given attribute name

Parameters
attributeName:String

the name of the attribute.

Returns:boolean

true if the attribute is supported by the script.

lookupScriptRepositoryback to summary
private Map<String, ScriptDef> lookupScriptRepository()

Finds or creates the script repository - it is stored in the project. This method is synchronized on the project under MagicNames#SCRIPT_REPOSITORY

Returns:Map<String, ScriptDef>

the current script repository registered as a reference.

setCompiledback to summary
public void setCompiled(boolean compiled)

Defines the compilation feature; optional.

Parameters
compiled:boolean

enables the script compilation if available.

Since
Ant 1.10.2
setEncodingback to summary
public void setEncoding(String encoding)

Sets the encoding of the script from an external file; optional.

Parameters
encoding:String

the encoding of the file containing the script source.

Since
Ant 1.10.2
setLanguageback to summary
public void setLanguage(String language)

Defines the language (required).

Parameters
language:String

the scripting language name for the script.

setManagerback to summary
public void setManager(String manager)

Deprecated

Defines the manager.

Parameters
manager:String

the scripting manager.

Annotations
@Deprecated
setManagerback to summary
public void setManager(ScriptManager manager)

Set the script manager.

setNameback to summary
public void setName(String name)

Sets the name under which this script will be activated in a build file

Parameters
name:String

the name of the script

setProjectback to summary
public void setProject(Project project)

Overrides org.apache.tools.ant.ProjectComponent.setProject.

Set the project.

Parameters
project:Project

the project that this definition belongs to.

Annotations
@Override
setSetBeansback to summary
public void setSetBeans(boolean setBeans)

Set the setbeans attribute. If this is true, <script> will create variables in the script instance for all properties, targets and references of the current project. It this is false, only the project and self variables will be set. The default is true.

Parameters
setBeans:boolean

the value to set.

setSrcback to summary
public void setSrc(File file)

Loads the script from an external file; optional.

Parameters
file:File

the file containing the script source.

withDefaultback to summary
private Map<String, String> withDefault(Map<String, String> attributes)
org.apache.tools.ant.taskdefs.optional.script back to summary

public Class ScriptDef.Attribute

extends Object
Class Inheritance
  • java.lang.Object
  • org.apache.tools.ant.taskdefs.optional.script.ScriptDef.Attribute

Class representing an attribute definition

Field Summary

Modifier and TypeField and Description
private String
defaultValue

The attribute's default value

private String
name

The attribute name

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
pack-priv String

Returns:

String
getDefault
()

Get the default value of this Attribute, null if unset.

pack-priv String

Returns:

String
getName
()

Get the name of this Attribute.

pack-priv boolean

Returns:

boolean
hasDefault
()

Learn whether this Attribute has a default value set.

public void
setDefault(String defaultValue)

Set the default value of this Attribute.

public void
setName(String
the attribute name
name
)

Sets the attribute name.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

defaultValueback to summary
private String defaultValue

The attribute's default value

nameback to summary
private String name

The attribute name

Constructor Detail

Attributeback to summary
public Attribute()

Method Detail

getDefaultback to summary
pack-priv String getDefault()

Get the default value of this Attribute, null if unset.

Returns:String

String

Since
Ant 1.10.13
getNameback to summary
pack-priv String getName()

Get the name of this Attribute.

Returns:String

String

hasDefaultback to summary
pack-priv boolean hasDefault()

Learn whether this Attribute has a default value set.

Returns:boolean

boolean

setDefaultback to summary
public void setDefault(String defaultValue)

Set the default value of this Attribute.

Parameters
defaultValue:String

String

Since
Ant 1.10.13
setNameback to summary
public void setName(String name)

Sets the attribute name.

Parameters
name:String

the attribute name

org.apache.tools.ant.taskdefs.optional.script back to summary

public Class ScriptDef.NestedElement

extends Object
Class Inheritance
  • java.lang.Object
  • org.apache.tools.ant.taskdefs.optional.script.ScriptDef.NestedElement

Class to represent a nested element definition

Field Summary

Modifier and TypeField and Description
private String
className

The class to be created for this nested element

private String
name

The name of the nested element

private String
type

The Ant type to which this nested element corresponds.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
setClassName(String
the name of the class to use for this nested element.
className
)

Sets the classname of the class to be used for the nested element.

public void
setName(String
the name of this nested element
name
)

Sets the tag name for this nested element

public void
setType(String
the name of an Ant type, or task, to use for this nested element.
type
)

Sets the type of this element.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

classNameback to summary
private String className

The class to be created for this nested element

nameback to summary
private String name

The name of the nested element

typeback to summary
private String type

The Ant type to which this nested element corresponds.

Constructor Detail

NestedElementback to summary
public NestedElement()

Method Detail

setClassNameback to summary
public void setClassName(String className)

Sets the classname of the class to be used for the nested element. This specifies the class directly and is an alternative to specifying the Ant type name.

Parameters
className:String

the name of the class to use for this nested element.

setNameback to summary
public void setName(String name)

Sets the tag name for this nested element

Parameters
name:String

the name of this nested element

setTypeback to summary
public void setType(String type)

Sets the type of this element. This is the name of an Ant task or type which is to be used when this element is to be created. This is an alternative to specifying the class name directly

Parameters
type:String

the name of an Ant type, or task, to use for this nested element.