Java Doc for ExecTask.java in  » Build » ANT » org » apache » tools » ant » taskdefs » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Build » ANT » org.apache.tools.ant.taskdefs 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


org.apache.tools.ant.Task
   org.apache.tools.ant.taskdefs.ExecTask

All known Subclasses:   org.apache.tools.ant.taskdefs.ExecuteOn,
ExecTask
public class ExecTask extends Task (Code)
Executes a given command if the os platform is appropriate.
since:
   Ant 1.2


Field Summary
protected  Commandlinecmdl
    
protected  booleanfailOnError
    
protected  booleannewEnvironment
    
protected  Redirectorredirector
    
protected  RedirectorElementredirectorElement
    

Constructor Summary
public  ExecTask()
     Create an instance.
public  ExecTask(Task owner)
     create an instance that is helping another task.

Method Summary
public  voidaddConfiguredRedirector(RedirectorElement redirectorElement)
     Add a RedirectorElement to this task.
public  voidaddEnv(Environment.Variable var)
     Add an environment variable to the launched process.
protected  voidcheckConfiguration()
    
public  Commandline.ArgumentcreateArg()
     Adds a command-line argument.
protected  ExecuteStreamHandlercreateHandler()
     Create the StreamHandler to use with our Execute instance.
protected  ExecuteWatchdogcreateWatchdog()
     Create the Watchdog to kill a runaway process.
public  voidexecute()
     Do the work.
public  booleangetResolveExecutable()
     Indicates whether to attempt to resolve the executable to a file.
protected  booleanisValidOs()
    
protected  voidlogFlush()
     Flush the output stream - if there is one.
protected  voidmaybeSetResultPropertyValue(int result)
     Helper method to set result property to the passed in value if appropriate.
protected  ExecuteprepareExec()
     Create an Execute instance with the correct working directory set.
protected  StringresolveExecutable(String exec, boolean mustSearchPath)
     The method attempts to figure out where the executable is so that we can feed the full path.
protected  voidrunExec(Execute exe)
     Run the command using the given Execute instance.
final protected  voidrunExecute(Execute exe)
     A Utility method for this classes and subclasses to run an Execute instance (an external command).
public  voidsetAppend(boolean append)
     Set whether output should be appended to or overwrite an existing file.
public  voidsetCommand(Commandline cmdl)
     Sets a command line.
public  voidsetDir(File d)
     Set the working directory of the process.
public  voidsetError(File error)
     Set the File to which the error stream of the process should be redirected.
public  voidsetErrorProperty(String errorProperty)
     Sets the name of the property whose value should be set to the error of the process.
public  voidsetExecutable(String value)
     Set the name of the executable program.
public  voidsetFailIfExecutionFails(boolean flag)
     Set whether to stop the build if program cannot be started.
public  voidsetFailonerror(boolean fail)
     Fail if the command exits with a non-zero return code.
public  voidsetInput(File input)
     Set the input file to use for the task.
public  voidsetInputString(String inputString)
     Set the string to use as input.
public  voidsetLogError(boolean logError)
     Controls whether error output of exec is logged.
public  voidsetNewenvironment(boolean newenv)
     Do not propagate old environment when new environment variables are specified.
public  voidsetOs(String os)
     List of operating systems on which the command may be executed.
public  voidsetOsFamily(String osFamily)
    
public  voidsetOutput(File out)
     File the output of the process is redirected to.
public  voidsetOutputproperty(String outputProp)
     Sets the property name whose value should be set to the output of the process.
public  voidsetResolveExecutable(boolean resolveExecutable)
     Set whether to attempt to resolve the executable to a file.
public  voidsetResultProperty(String resultProperty)
     Sets the name of a property in which the return code of the command should be stored.
public  voidsetSearchPath(boolean searchPath)
     Set whether to search nested, then system PATH environment variables for the executable.
public  voidsetSpawn(boolean spawn)
     Set whether or not you want the process to be spawned.
public  voidsetTimeout(Long value)
     Set the timeout in milliseconds after which the process will be killed.
public  voidsetTimeout(Integer value)
     Set the timeout in milliseconds after which the process will be killed.
public  voidsetVMLauncher(boolean vmLauncher)
     Set whether to launch new process with VM, otherwise use the OS's shell.
protected  voidsetupRedirector()
     Set up properties on the redirector that we needed to store locally.

Field Detail
cmdl
protected Commandline cmdl(Code)



failOnError
protected boolean failOnError(Code)



newEnvironment
protected boolean newEnvironment(Code)



redirector
protected Redirector redirector(Code)



redirectorElement
protected RedirectorElement redirectorElement(Code)




Constructor Detail
ExecTask
public ExecTask()(Code)
Create an instance. Needs to be configured by binding to a project.



ExecTask
public ExecTask(Task owner)(Code)
create an instance that is helping another task. Project, OwningTarget, TaskName and description are all pulled out
Parameters:
  owner - task that we belong to




Method Detail
addConfiguredRedirector
public void addConfiguredRedirector(RedirectorElement redirectorElement)(Code)
Add a RedirectorElement to this task.
Parameters:
  redirectorElement - RedirectorElement.
since:
   Ant 1.6.2



addEnv
public void addEnv(Environment.Variable var)(Code)
Add an environment variable to the launched process.
Parameters:
  var - new environment variable.



checkConfiguration
protected void checkConfiguration() throws BuildException(Code)
Has the user set all necessary attributes?
throws:
  BuildException - if there are missing required parameters.



createArg
public Commandline.Argument createArg()(Code)
Adds a command-line argument. new command line argument created.



createHandler
protected ExecuteStreamHandler createHandler() throws BuildException(Code)
Create the StreamHandler to use with our Execute instance. instance of ExecuteStreamHandler.
throws:
  BuildException - under unknown circumstances.



createWatchdog
protected ExecuteWatchdog createWatchdog() throws BuildException(Code)
Create the Watchdog to kill a runaway process. instance of ExecuteWatchdog.
throws:
  BuildException - under unknown circumstances.



execute
public void execute() throws BuildException(Code)
Do the work.
throws:
  BuildException - in a number of circumstances:
  • if failIfExecFails is set to true and the process cannot be started
  • the java13command launcher can send build exceptions
  • this list is not exhaustive or limitative



getResolveExecutable
public boolean getResolveExecutable()(Code)
Indicates whether to attempt to resolve the executable to a file. the resolveExecutable flag
since:
   Ant 1.6



isValidOs
protected boolean isValidOs()(Code)
Is this the OS the user wanted? boolean.
  • true if the os and osfamily attributes are null.
  • true if osfamily is set, and the os family and must matchthat of the current OS, according to the logic ofOs.isOs(StringStringStringString), and the result of theos attribute must also evaluate true.
  • true if os is set, and the system.property os.nameis found in the os attribute,
  • false otherwise.



logFlush
protected void logFlush()(Code)
Flush the output stream - if there is one.



maybeSetResultPropertyValue
protected void maybeSetResultPropertyValue(int result)(Code)
Helper method to set result property to the passed in value if appropriate.
Parameters:
  result - value desired for the result property value.



prepareExec
protected Execute prepareExec() throws BuildException(Code)
Create an Execute instance with the correct working directory set. an instance of the Execute class.
throws:
  BuildException - under unknown circumstances.



resolveExecutable
protected String resolveExecutable(String exec, boolean mustSearchPath)(Code)
The method attempts to figure out where the executable is so that we can feed the full path. We first try basedir, then the exec dir, and then fallback to the straight executable name (i.e. on the path).
Parameters:
  exec - the name of the executable.
Parameters:
  mustSearchPath - if true, the executable will be looked up inthe PATH environment and the absolute path is returned. the executable as a full path if it can be determined.
since:
   Ant 1.6



runExec
protected void runExec(Execute exe) throws BuildException(Code)
Run the command using the given Execute instance. This may be overridden by subclasses.
Parameters:
  exe - instance of Execute to run.
throws:
  BuildException - if the new process could not be startedonly if failIfExecFails is set to true (the default).



runExecute
final protected void runExecute(Execute exe) throws IOException(Code)
A Utility method for this classes and subclasses to run an Execute instance (an external command).
Parameters:
  exe - instance of the execute class.
throws:
  IOException - in case of problem to attach to the stdin/stdout/stderrstreams of the process.



setAppend
public void setAppend(boolean append)(Code)
Set whether output should be appended to or overwrite an existing file. Defaults to false.
Parameters:
  append - if true append is desired.
since:
   1.30, Ant 1.5



setCommand
public void setCommand(Commandline cmdl)(Code)
Sets a command line.
Parameters:
  cmdl - command line.



setDir
public void setDir(File d)(Code)
Set the working directory of the process.
Parameters:
  d - the working directory of the process.



setError
public void setError(File error)(Code)
Set the File to which the error stream of the process should be redirected.
Parameters:
  error - a file to which stderr should be sent.
since:
   Ant 1.6



setErrorProperty
public void setErrorProperty(String errorProperty)(Code)
Sets the name of the property whose value should be set to the error of the process.
Parameters:
  errorProperty - name of property.
since:
   Ant 1.6



setExecutable
public void setExecutable(String value)(Code)
Set the name of the executable program.
Parameters:
  value - the name of the executable program.



setFailIfExecutionFails
public void setFailIfExecutionFails(boolean flag)(Code)
Set whether to stop the build if program cannot be started. Defaults to true.
Parameters:
  flag - stop the build if program cannot be started.
since:
   Ant 1.5



setFailonerror
public void setFailonerror(boolean fail)(Code)
Fail if the command exits with a non-zero return code.
Parameters:
  fail - if true fail the command on non-zero return code.



setInput
public void setInput(File input)(Code)
Set the input file to use for the task.
Parameters:
  input - name of a file from which to get input.



setInputString
public void setInputString(String inputString)(Code)
Set the string to use as input.
Parameters:
  inputString - the string which is used as the input source.



setLogError
public void setLogError(boolean logError)(Code)
Controls whether error output of exec is logged. This is only useful when output is being redirected and error output is desired in the Ant log.
Parameters:
  logError - set to true to log error output in the normal ant log.



setNewenvironment
public void setNewenvironment(boolean newenv)(Code)
Do not propagate old environment when new environment variables are specified.
Parameters:
  newenv - if true, do not propagate old environmentwhen new environment variables are specified.



setOs
public void setOs(String os)(Code)
List of operating systems on which the command may be executed.
Parameters:
  os - list of operating systems on which the command may be executed.



setOsFamily
public void setOsFamily(String osFamily)(Code)
Restrict this execution to a single OS Family
Parameters:
  osFamily - the family to restrict to.



setOutput
public void setOutput(File out)(Code)
File the output of the process is redirected to. If error is not redirected, it too will appear in the output.
Parameters:
  out - name of a file to which output should be sent.



setOutputproperty
public void setOutputproperty(String outputProp)(Code)
Sets the property name whose value should be set to the output of the process.
Parameters:
  outputProp - name of property.



setResolveExecutable
public void setResolveExecutable(boolean resolveExecutable)(Code)
Set whether to attempt to resolve the executable to a file.
Parameters:
  resolveExecutable - if true, attempt to resolve thepath of the executable.



setResultProperty
public void setResultProperty(String resultProperty)(Code)
Sets the name of a property in which the return code of the command should be stored. Only of interest if failonerror=false.
since:
   Ant 1.5
Parameters:
  resultProperty - name of property.



setSearchPath
public void setSearchPath(boolean searchPath)(Code)
Set whether to search nested, then system PATH environment variables for the executable.
Parameters:
  searchPath - if true, search PATHs.



setSpawn
public void setSpawn(boolean spawn)(Code)
Set whether or not you want the process to be spawned. Default is false.
Parameters:
  spawn - if true you do not want Ant to wait for the end of the process.
since:
   Ant 1.6



setTimeout
public void setTimeout(Long value)(Code)
Set the timeout in milliseconds after which the process will be killed.
Parameters:
  value - timeout in milliseconds.
since:
   Ant 1.5



setTimeout
public void setTimeout(Integer value)(Code)
Set the timeout in milliseconds after which the process will be killed.
Parameters:
  value - timeout in milliseconds.



setVMLauncher
public void setVMLauncher(boolean vmLauncher)(Code)
Set whether to launch new process with VM, otherwise use the OS's shell. Default value is true.
Parameters:
  vmLauncher - true if we want to launch new process with VM,false if we want to use the OS's shell.



setupRedirector
protected void setupRedirector()(Code)
Set up properties on the redirector that we needed to store locally.



Fields inherited from org.apache.tools.ant.Task
protected Target target(Code)(Java Doc)
protected String taskName(Code)(Java Doc)
protected String taskType(Code)(Java Doc)
protected RuntimeConfigurable wrapper(Code)(Java Doc)

Methods inherited from org.apache.tools.ant.Task
final public void bindToOwner(Task owner)(Code)(Java Doc)
public void execute() throws BuildException(Code)(Java Doc)
public Target getOwningTarget()(Code)(Java Doc)
public RuntimeConfigurable getRuntimeConfigurableWrapper()(Code)(Java Doc)
public String getTaskName()(Code)(Java Doc)
public String getTaskType()(Code)(Java Doc)
protected RuntimeConfigurable getWrapper()(Code)(Java Doc)
protected void handleErrorFlush(String output)(Code)(Java Doc)
protected void handleErrorOutput(String output)(Code)(Java Doc)
protected void handleFlush(String output)(Code)(Java Doc)
protected int handleInput(byte[] buffer, int offset, int length) throws IOException(Code)(Java Doc)
protected void handleOutput(String output)(Code)(Java Doc)
public void init() throws BuildException(Code)(Java Doc)
final protected boolean isInvalid()(Code)(Java Doc)
public void log(String msg)(Code)(Java Doc)
public void log(String msg, int msgLevel)(Code)(Java Doc)
public void log(Throwable t, int msgLevel)(Code)(Java Doc)
public void log(String msg, Throwable t, int msgLevel)(Code)(Java Doc)
public void maybeConfigure() throws BuildException(Code)(Java Doc)
final public void perform()(Code)(Java Doc)
public void reconfigure()(Code)(Java Doc)
public void setOwningTarget(Target target)(Code)(Java Doc)
public void setRuntimeConfigurableWrapper(RuntimeConfigurable wrapper)(Code)(Java Doc)
public void setTaskName(String name)(Code)(Java Doc)
public void setTaskType(String type)(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.