Package org.eclipse.ant.core
Class AntRunner
java.lang.Object
org.eclipse.ant.core.AntRunner
- All Implemented Interfaces:
IApplication
Entry point for running Ant builds inside Eclipse (within the same JRE). Clients may instantiate this class; it is not intended to be subclassed.
Usage note:
Clients may use the
Clients may use the
addBuildListener, addBuildLogger and setInputHandler methods to configure classes that
will be invoked during the build. When using these methods, it is necessary to package the classes in a jar that is not on the client plugin's
classpath. The jar must be added to the Ant classpath. One way to add the jar to the Ant classpath is to use the
org.eclipse.ant.core.extraClasspathEntries extension.
Refer to the "Platform Ant Support" chapter of the Programmer's Guide section in the Platform Plug-in Developer Guide for complete details.
- Restriction:
- This class is not intended to be subclassed by clients.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Stringprotected String[]protected Stringprotected Stringprotected URL[]protected Stringprotected intprotected String[]protected String[]Fields inherited from interface org.eclipse.equinox.app.IApplication
EXIT_OK, EXIT_RELAUNCH, EXIT_RESTART -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddBuildListener(String className) Adds a build listener.voidaddBuildLogger(String className) Sets the build logger.voidaddUserProperties(Map<String, String> properties) Adds user-defined properties.Returns the buildfile target information.protected voidhandleInvocationTargetException(Object runner, Class<?> classInternalAntRunner, InvocationTargetException e) static booleanReturns whether an Ant build is already in progress Only one Ant build can occur at any given time.protected voidvoidrun()Runs the build file.Invokes the building of a project object and executes a build using either a given target or the default target.voidrun(IProgressMonitor monitor) Runs the build file.voidsetAntHome(String antHome) Sets the Ant home to use for this buildvoidsetArguments(String arguments) Sets the arguments to be passed to the build (e.g.voidsetArguments(String[] arguments) Sets the arguments to be passed to the build (e.g.voidsetBuildFileLocation(String buildFileLocation) Sets the build file location on the file system.voidsetCustomClasspath(URL[] customClasspath) Sets the custom classpath to use for this buildvoidsetExecutionTargets(String[] executionTargets) Sets the targets and execution order.voidsetInputHandler(String className) Sets the input handler.voidsetMessageOutputLevel(int level) Set the message output level.voidsetPropertyFiles(String[] propertyFiles) Sets the user specified property files.start(IApplicationContext context) Invokes the building of a project object and executes a build using either a given target or the default target.voidstop()Forces this running application to exit.
-
Field Details
-
buildFileLocation
-
buildListeners
-
targets
-
userProperties
-
messageOutputLevel
protected int messageOutputLevel -
buildLoggerClassName
-
inputHandlerClassName
-
arguments
-
propertyFiles
-
customClasspath
-
antHome
-
-
Constructor Details
-
AntRunner
public AntRunner()
-
-
Method Details
-
setBuildFileLocation
Sets the build file location on the file system.- Parameters:
buildFileLocation- the file system location of the build file
-
setMessageOutputLevel
public void setMessageOutputLevel(int level) Set the message output level.Valid values are:
org.apache.tools.ant.Project.ERR,org.apache.tools.ant.Project.WARN,org.apache.tools.ant.Project.INFO,org.apache.tools.ant.Project.VERBOSEororg.apache.tools.ant.Project.DEBUG
- Parameters:
level- the message output level
-
setArguments
Sets the arguments to be passed to the build (e.g. -Dos=win32 -Dws=win32 - verbose).- Parameters:
arguments- the arguments to be passed to the build
-
setArguments
Sets the arguments to be passed to the build (e.g. -Dos=win32 -Dws=win32 -verbose).- Parameters:
arguments- the arguments to be passed to the build- Since:
- 2.1
-
setExecutionTargets
Sets the targets and execution order.- Parameters:
executionTargets- which targets should be run and in which order
-
addBuildListener
Adds a build listener. The parameterclassNameis the class name of anorg.apache.tools.ant.BuildListenerimplementation. The class will be instantiated at runtime and the listener will be called on build events (org.apache.tools.ant.BuildEvent).Refer to
Usage Notefor implementation details.- Parameters:
className- a build listener class name
-
addBuildLogger
Sets the build logger. The parameterclassNameis the class name of anorg.apache.tools.ant.BuildLoggerimplementation. The class will be instantiated at runtime and the logger will be called on build events (org.apache.tools.ant.BuildEvent). Only one build logger is permitted for any build.Refer to
Usage Notefor implementation details.- Parameters:
className- a build logger class name
-
addUserProperties
Adds user-defined properties. Keys and values must be String objects.- Parameters:
properties- a Map of user-defined properties
-
getAvailableTargets
Returns the buildfile target information.- Returns:
- an array containing the target information
- Throws:
CoreException- Thrown if problem is encountered determining the targets- Since:
- 2.1
- See Also:
-
run
Runs the build file. If a progress monitor is specified it will be available during the script execution as a reference in the Ant Project (org.apache.tools.ant.Project.getReferences()). A long- running task could, for example, get the monitor during its execution and check for cancellation. The key value to retrieve the progress monitor instance isAntCorePlugin.ECLIPSE_PROGRESS_MONITOR. Only one build can occur at any given time. Sets the current threads context class loader to the AntClassLoader for the duration of the build.- Parameters:
monitor- a progress monitor, ornullif progress reporting and cancellation are not desired- Throws:
CoreException- Thrown if a build is already occurring or if an exception occurs during the build
-
handleInvocationTargetException
protected void handleInvocationTargetException(Object runner, Class<?> classInternalAntRunner, InvocationTargetException e) throws CoreException - Throws:
CoreException
-
problemLoadingClass
- Throws:
CoreException
-
run
Runs the build file.- Throws:
CoreException- Thrown if a build is already occurring or if an exception occurs during the build
-
run
Invokes the building of a project object and executes a build using either a given target or the default target. This method is called when running Eclipse headless and specifyingorg.eclipse.ant.core.antRunneras the application. Sets the current threads context class loader to the AntClassLoader for the duration of the build.- Parameters:
argArray- the command line arguments- Returns:
- an exit object (
EXIT_OK) indicating normal termination if no exception occurs - Throws:
Exception- if a problem occurred during the buildfile execution
-
setInputHandler
Sets the input handler. The parameterclassNameis the class name of anorg.apache.tools.ant.input.InputHandlerimplementation. The class will be instantiated at runtime and the input handler will be used to respond to <input> requests Only one input handler is permitted for any build.Refer to
Usage Notefor implementation details.- Parameters:
className- an input handler class name- Since:
- 2.1
-
setPropertyFiles
Sets the user specified property files.- Parameters:
propertyFiles- array of property file paths- Since:
- 2.1
-
setCustomClasspath
Sets the custom classpath to use for this build- Parameters:
customClasspath- array of URLs that define the custom classpath
-
setAntHome
Sets the Ant home to use for this build- Parameters:
antHome- String specifying the Ant home to use- Since:
- 2.1
-
isBuildRunning
public static boolean isBuildRunning()Returns whether an Ant build is already in progress Only one Ant build can occur at any given time.- Returns:
- boolean
- Since:
- 2.1
-
start
Invokes the building of a project object and executes a build using either a given target or the default target. This method is called when running Eclipse headless and specifyingorg.eclipse.ant.core.antRunneras the application. Sets the current threads context class loader to theAntClassLoaderfor the duration of the build.- Specified by:
startin interfaceIApplication- Parameters:
context- the context used to start the application- Returns:
- an exit object (
EXIT_OK) indicating normal termination if no exception occurs - Throws:
Exception- if a problem occurred during the buildfile execution- See Also:
-
stop
public void stop()Description copied from interface:IApplicationForces this running application to exit. This method should wait until the running application is ready to exit. TheIApplication.start(IApplicationContext)should already have exited or should exit very soon after this method exitsThis method is only called to force an application to exit. This method will not be called if an application exits normally from the
IApplication.start(IApplicationContext)method.Note: This method is called by the platform; it is not intended to be called directly by clients.
- Specified by:
stopin interfaceIApplication
-