Clients may extend this class. New methods may and will be added in the future.
protected final TaskContext | The concrete TaskContext. |
protected final TaskExecutionUtilities | The concrete TaskExecutionUtilities. |
public | ForwardingTaskContext( Creates a new instance initialized with the task context which to forward the calls. |
public void | abortExecution( Signals an error during the execution of this task to the build runtime. |
public void | Acquires the execution-wide lock for accessing the standard I/O. |
public SakerFile | addFile( Adds a file to the specified directory. |
public SakerFile | addFileIfAbsent( Add a file to the specified directory only if there is no file present yet with the same name. |
public SakerFile | addFileOverwriteIfNotDirectory( Add a file to the specified directory only if there is no directory present with the same name. |
public void | addSynchronizeInvalidatedProviderPathFileToDirectory( Add and synchronizes a SakerFile to the specified directory with the given name that has its contents
backed by the given path key. |
public NavigableMap< | collectFiles( Collects the files for the given file collection strategy. |
public NavigableMap< | collectFilesReportAdditionDependency( Bulk method for calling collectFilesReportAdditionDependency( |
public NavigableMap< | collectFilesReportAdditionDependency( Collects the files for the given addition dependency, and reports it. |
public NavigableMap< | collectFilesReportInputFileAndAdditionDependency( Bulk method for calling
collectFilesReportInputFileAndAdditionDependency( |
public NavigableMap< | collectFilesReportInputFileAndAdditionDependency( Collects the files for the given file addition dependency, and reports it and the files as dependencies. |
public < | computeFileContentData( Computes some data based on a contents of a file. |
public SakerFile | createProviderPathFile( Creates a SakerFile instance which has its contents backed by the specified file system file at the given
path. |
public SakerFile | createProviderPathFile( Creates a SakerFile instance which has its contents backed by the specified file system file at the given
path, and associates the argument content descriptor with the current contents. |
public SakerFile | Creates a SakerFile instance which has its contents backed by the specified file system file at the given
path. |
public SakerFile | createProviderPathFileWithPosixFilePermissions( Creates a SakerFile instance which has its contents backed by the specified file system file at the given
path, and associates the argument content descriptor and posix file permissions with the current contents. |
public ByteArrayRegion | Gets the raw contents of the file as a byte array. |
public NavigableMap< | Gets the content descriptors of the children of the specified directory. |
public String | getContent( Gets the contents of the file as a String. |
public ExecutionContext | Gets the execution context which is used to run this task. |
public TaskFileDeltas | Gets a file delta collection for all possible file delta types. |
public TaskFileDeltas | getFileDeltas( Gets a file delta collection for the given delta type. |
public Set< | Gets the set of deltas which contain no file deltas. |
public NavigableMap< | Gets the current state of collected files for a previously reported file addition dependency. |
public NavigableMap< | Gets the current state of previously reported file input dependencies for a given tag. |
public NavigableMap< | Gets the current state of previously reported file output dependencies for a given tag. |
public < | getPreviousTaskOutput( Gets the output of the task from the previous run. |
public < | getPreviousTaskOutput( Gets the previously set task output for the given tag. |
public TaskProgressMonitor | Gets the progress monitor for this task. |
public < | getReportEnvironmentDependency( Gets the current value of the specified environment property and reports it as a dependency. |
public < | getReportExecutionDependency( Gets the current value of the specified execution property and reports it as a dependency. |
public SecretInputReader | Gets the input reader that can be used to read secret input from the user. |
public ByteSink | Gets the standard error for this task. |
public ByteSource | Gets the standard input for this task. |
public ByteSink | Gets the standard output for this task. |
public SakerDirectory | Gets the build directory for the currently executing task or null if not available. |
public SakerPath | Gets the path of the build directory for the associated task. |
public TaskContext | Gets the task context which this utilities belong to. |
public TaskDependencyFuture< | Gets a dependency future handle for the specified task. |
public TaskFuture< | getTaskFuture( Gets a future handle for the specified task. |
public TaskIdentifier | Gets the task identifier which was used to start this task. |
public Object | getTaskResult( Gets the task result for the given task identifier. |
public TaskResultDependencyHandle | Gets a task result dependency handle for the given task identifier. |
public TaskExecutionUtilities | Gets the utility class for this task context. |
public SakerDirectory | Gets the working directory for the currently executing task. |
public SakerPath | Gets the path of the working directory for the associated task. |
public void | invalidate( Bulk method for TaskContext.invalidate( |
public void | invalidate( Notifies the build system that a file at the given path was externally modified. |
public ContentDescriptor | Notifies the build system that a file at the given path was externally modified and retrieves the content
descriptor for the path. |
public void | Invalidates the specified file and also associates the current posix file permissions of the file in the build
system. |
public Path | Mirrors a file with all children, recursively if the file is a directory. |
public Path | mirror( Mirrors a file to the local file system. |
public Path | mirrorDirectoryAtPath( Executes the mirroring for a directory at the given execution path. |
public Path | mirrorFileAtPath( Executes the mirroring for a file at the given execution path. |
public MirroredFileContents | Executes the mirroring for a file at the given execution path and gets the file content descriptor. |
public ByteSource | openByteSource( Opens a byte source to the contents of the file. |
public InputStream | openInputStream( Opens an input stream to the contents of the file. |
protected Object | Presents an opportunity to subclasses to override a given input file tag. |
protected Object | Presents an opportunity to subclasses to override a given output file tag. |
protected Object | Presents an opportunity to subclasses to override a given task output tag. |
public void | Prints a line of string to the standard output of this task. |
public void | Releases the previously acquired execution-wide lock for accessing the standard I/O. |
public void | replayPrintln( Stores a line of string to be replayed for the task if it is not re-run due to no incremental changes. |
public < | reportEnvironmentDependency( Reports an environment dependency for this task to the build runtime. |
public < | reportExecutionDependency( Reports an execution property dependency for this task to the build runtime. |
public void | reportIDEConfiguration( Reports an IDE configuration for this task. |
public void | Reports an unhandled exception that occurred during the execution of the task for informational purposes. |
public void | Reports an unhandled exception that occurred during the execution of the task for informational purposes. |
public void | reportInputFileAdditionDependency( Reports a file addition dependency for this task to the build runtime. |
public void | reportInputFileDependency( Bulk method for reportInputFileDependency( |
public void | reportInputFileDependency( |
public void | reportInputFileDependency( Reports an input file dependency for the path of the file and its contents. |
public void | reportInputFileDependency( Reports a file input content dependency for this task to the build runtime. |
public void | reportOutputFileDependency( Bulk method for reportOutputFileDependency( |
public void | reportOutputFileDependency( |
public void | reportOutputFileDependency( Reports an output file dependency for the path of the file and its contents. |
public void | reportOutputFileDependency( Reports a file output content dependency for this task to the build runtime. |
public void | reportSelfTaskOutputChangeDetector( Sets the task output change detector for this task. |
public SakerFile | Resolves a file or directory using the given absolute path. |
public SakerFile | resolveAtPath( Same as resolveAtPath( |
public SakerFile | resolveAtPath( Resolves a file or directory at the given path. |
public SakerFile | resolveAtRelativePath( Resolves a file or directory using the given relative path against a base directory. |
public SakerFile | resolveAtRelativePathNames( Resolves a file or directory with the given path names against a base directory. |
public SakerDirectory | Resolves a directory using the given absolute path. |
public SakerDirectory | Resolves a directory using the given absolute path, creating it if necessary, overwriting already existing files. |
public SakerDirectory | Resolves a directory using the given absolute path, creating it if possible. |
public SakerDirectory | resolveDirectoryAtPath( Same as resolveDirectoryAtPath( |
public SakerDirectory | Resolves a directory at a given path. |
public SakerDirectory | resolveDirectoryAtPathCreate( Same as resolveDirectoryAtPathCreate( |
public SakerDirectory | Resolves a directory at a given path, creating it if necessary, overwriting already existing files. |
public SakerDirectory | resolveDirectoryAtPathCreateIfAbsent( Same as resolveDirectoryAtPathCreateIfAbsent( |
public SakerDirectory | Resolves a directory at a given path, creating it if possible. |
public SakerDirectory | resolveDirectoryAtRelativePath( Resolves a directory using the given relative path against a base directory. |
public SakerDirectory | resolveDirectoryAtRelativePathCreate( Resolves a directory using the given relative path against a base directory, creating it if necessary,
overwriting already existing files. |
public SakerDirectory | resolveDirectoryAtRelativePathCreateIfAbsent( Resolves a directory using the given relative path against a base directory, creating it if possible. |
public SakerDirectory | resolveDirectoryAtRelativePathNames( Resolves a directory with the given path names against a base directory. |
public SakerDirectory | resolveDirectoryAtRelativePathNamesCreate( Resolves a directory with the given path names against a base directory, creating it if necessary, overwriting
already existing files. |
public SakerDirectory | resolveDirectoryAtRelativePathNamesCreateIfAbsent( Resolves a directory with the given path names against a base directory, creating it if possible. |
public SakerFile | Resolves a file but not a directory using the given absolute path. |
public SakerFile | resolveFileAtPath( Same as resolveFileAtPath( |
public SakerFile | resolveFileAtPath( Resolves a file but not a directory at the given path. |
public SakerFile | resolveFileAtRelativePath( Resolves a file but not a directory using the given relative path against a base directory. |
public SakerFile | resolveFileAtRelativePathNames( Resolves a file but not a directory with the given path names against a base directory. |
public void | runTask( Same as runTask( |
public void | runTask( Same as runTaskFuture( null
execution parameters, but returns void . |
public void | runTask( Same as runTaskFuture( void . |
public < | runTaskFuture( Same as runTaskFuture( |
public < | runTaskFuture( Convenience function to call runTaskFuture( |
public < | runTaskFuture( Starts a task and waits for its execution to complete. |
public < | runTaskResult( Same as runTaskResult( |
public < | runTaskResult( Convenience function to call runTaskResult( |
public < | runTaskResult( Starts a task and waits for its execution to complete. |
public void | setMetaData( Sets an arbitrary meta-data as a result of this task. |
public void | setStandardOutDisplayIdentifier( Sets the line display identifier for this task. |
public void | setTaskOutput( Sets the output of the task for a given tag. |
public < | startInnerTask( Starts an inner task to execute in the context of this task. |
public void | startTask( Convenience function to call TaskContext.startTask( |
public void | startTask( Convenience function to call TaskContext.startTask( |
public < | startTask( Starts a task for execution. |
public < | startTaskFuture( Convenience function to call TaskContext.startTask( |
public < | startTaskFuture( Convenience function to call TaskContext.startTask( |
public void | startTasks( Batch function for starting tasks specified by the launch arguments. |
public void | startTasks( Batch function for starting multiple tasks. |
public void | startTasks( Batch function for starting multiple tasks with the specified execution parameters. |
public List< | startTasksFuture( Batch function for starting tasks with the specified launch arguments and retrieving the futures for them. |
public ContentDescriptor | synchronize( Executes synchronization of files from the given source path to the specified target path. |
public NavigableMap< | toPathContentMap( Converts the given files to a map with their retrieved paths as keys and content
descriptors as values. |
public NavigableMap< | toPathFileMap( Converts the given files to a map with their retrieved paths as keys. |
public void | writeTo( Writes the contents of the file to the specified output stream. |
public void | Writes the contents of the file to the specified byte sink. |
The field just caches the value of TaskContext.getTaskUtilities() retrieved in the constructor.
null
.Calling this function will set a pending cause exception for the task result. Tasks which retrieve the result of this task will receive this exception.
The execution of this task will continue, and the task may still return an object from the
Task.run(
For inner tasks, calling this function will return this exception via the InnerTaskResultHolder.getExceptionIfAny(), and the inner task may also return an object as a result, which is available via InnerTaskResultHolder.getResult().
Aborting excecution using this functions is preferable to throwing an exception directly when the task is able to handle previously thrown exceptions in the next run.
If the task uses this function to abort, then any results produced by the current run will be visible in the next one. The base for delta calculation will be the current run instead of the last previously successfully finished run.
It is useful to use this function when the task actually finishes its calculations successfully, but it is required to abort due to a semantic build error.
This method may be called multiple times. The first exception that is used to call this method will be the cause of the task execution exception, and any further exceptions will be added as suppressed exceptions.
null
.Acquiring the lock will prevent any access to the standard I/O streams of the execution by other tasks. This means that the locker will have exclusive access to the input and output of the execution. Any output that is produced by concurrent tasks will be written out when this task releases the lock.
The lock is task execution based and not thread based. This means that the lock can be acquired on one thread and can be released on an other thread. Trying to acquire the lock multiple times will result in an exception.
It is recommended to acquire this lock when the task wants to display information that is necessary to be grouped together. Without locking, the lines printed to the output streams might be interlaced with the output of concurrent tasks.
It is required to acquire the lock to access the standard input. If the task wants to read input from the standard input stream and the lock is not acquired, then an exception will be thrown. This is to prevent misalignment of typed data from the user by concurrent output writing, and due to the fact that the standard input is one single shared stream of input for all concurrent tasks.
This method works the same way as SakerDirectory.add(
This method can be called from both remote and non-remote executed tasks.
null
.
This method works the same way as SakerDirectory.addIfAbsent(
This method can be called from both remote and non-remote executed tasks.
null
if there is already a file with the same
name. If non-null
, it is the same as the parameter if called from non-remote executed
tasks.null
.
This method works the same way as SakerDirectory.addOverwriteIfNotDirectory(
This method can be called from both remote and non-remote executed tasks.
null
if there is a directory present with the
same name. If non-null
, it is the same as the parameter if called from non-remote
executed tasks.null
.This method can be used to perform multiple operations in a single call. The method will invalidate the contents at the given path key and create a provider path file for the given path key. The created SakerFile is the added to the argument directory, and then syncronized.
Calling this method can be useful to batch the above operations in a single call. It is usually useful when you invoke an external process that produces a result file and want to add it to the build system file hierarchy.
null
.This method doesn't report the argument as dependency.
Important: Calling this method will trigger the computation of file deltas as it uses
TaskContext.getPreviousFileAdditionDependency(
This method is the same as:
collectionstrategy.collectFiles(taskcontext);
When designing tasks for remote execution, it is recommended to call this method instead invoking
FileCollectionStrategy.collectFiles(
For correct incremental operation tasks should not forget to report the dependencies as well. Consider calling
TaskExecutionUtilities.collectFilesReportInputFileAndAdditionDependency(
null
.This method collects the files for all the addition dependencies, and aggregates them into a single result map.
null
.This method doesn't report input file dependency to the collected files.
Important: Calling this method will trigger the computation of file deltas as it uses
TaskContext.getPreviousFileAdditionDependency(
null
.This method collects the files for all the addition dependencies, and aggregates them into a single result map.
null
.This method collects the files for the specified addition dependency, reports the addition dependency, and reports the input dependencies for the collected files with their respective content descriptors.
Important: Calling this method will trigger the computation of file deltas as it uses
TaskContext.getPreviousFileAdditionDependency(
null
.The execution context will ensure that a given data for a file and a computer is only computed once during an execution.
The computed datas will be cached during the execution. The cache uses the content descriptor, path of the file, and the computer as a key to the cached datas. Files which are not attached to any parents will not have their computed datas cached.
Multiple concurrent computation can run for a given file, but only one computation will run at the same time for file data computers that equal.
null
or the computer computes null
value.This method can be used to include files from a given file system in the build. The resulting file needs to be added to a SakerDirectory to be included in the in-memory hierarchy.
If the file at the given path is a directory, a SakerDirectory instance will be returned that contains all the files which are present in the given directory. (The directory may be lazily populated.)
Note that we recommend using TaskExecutionUtilities.createProviderPathFile(
null
.The file represented with the given path must be a file, not a directory.
The argument content descriptor will be associated with the current contents of the file system at the given path. This means that unless some other agent modifies the contents at the given path, calling SakerFile.getContentDescriptor() will return the passed argument for the returned file.
This method can be used to include files from a given file system in the build. The resulting file needs to be added to a SakerDirectory to be included in the in-memory hierarchy.
null
.The name of the file is the same as the name of the argument path.
This method is the same as:
createProviderPathFile(pathkey.getPath().getFileName(), pathkey)
null
.
The method works the same way as
TaskExecutionUtilities.createProviderPathFile(
The result file will return the argument posix file permissions from its SakerFile.getPosixFilePermissions() method.
It is not required for the underlying filesystem to support posix file permissions.
Note that the argument content descriptor should reflect the specified posix file permissions as well. It is recommended to use PosixFilePermissionsDelegateContentDescriptor.
null
.null
.Calling this method might implicitly synchronize the file to its real location, or to some other cache location when remote execution is used.
null
.The resulting map is mapped by the file names of the children.
null
.Calling this method might implicitly synchronize the file to its real location, or to some other cache location when remote execution is used.
null
.The returned container will include all file deltas regardless of DeltaType.
Important: Calling this method will trigger the computation of file deltas. Any input dependency tasks should be waited for before calling this method. By waiting for tasks after file delta computation, you risk the file deltas being incorrectly reported which can result in incorrect incremental builds. See TaskContext documentation for more info.
The resulting container will only include deltas which type matches the given parameter.
If the parameter is not a file change related DeltaType then an empty container will be returned.
Important: Calling this method will trigger the computation of file deltas. Any input dependency tasks should be waited for before calling this method. By waiting for tasks after file delta computation, you risk the file deltas being incorrectly reported which can result in incorrect incremental builds. See TaskContext documentation for more info.
null
.The resulting map will have the same entries as if the dependency was used to collect the files themselves. The resulting map was used to compute the deltas for the task.
Calling this method instead of collecting the files manually can result in performance increase as it can avoid duplicate computations.
If the file addition dependency was not reported in the previous run, null
will be returned.
Important: Calling this method will trigger the computation of file deltas. Any input dependency tasks should be waited for before calling this method. By waiting for tasks after file delta computation, you risk the file deltas being incorrectly reported which can result in incorrect incremental builds. See TaskContext documentation for more info.
null
if the dependency was not reported previously.null
.The resulting map will have one entry for every input file reported previously. The resulting map contains the files which were used to compute deltas for the task.
It is recommended to get the files using this method if there are no deltas for the given tag, as it can avoid unnecessary computations by the task.
Important: Calling this method will trigger the computation of file deltas. Any input dependency tasks should be waited for before calling this method. By waiting for tasks after file delta computation, you risk the file deltas being incorrectly reported which can result in incorrect incremental builds. See TaskContext documentation for more info.
null
values mean the file
doesn't exist at a given path.The resulting map will have one entry for every output file reported previously. The resulting map contains the files which were used to compute deltas for the task.
Important: Calling this method will trigger the computation of file deltas. Any input dependency tasks should be waited for before calling this method. By waiting for tasks after file delta computation, you risk the file deltas being incorrectly reported which can result in incorrect incremental builds. See TaskContext documentation for more info.
null
values mean the file
doesn't exist at a given path.null
if the task was not run before this execution, it
returned null
, or it is not an instance of the specified type.null
.null
if the task was not run before
this execution, the value was not found, or it is not an instance of the specified type.null
.The progress monitor can be used to check if the execution has been cancelled externally.
null
.)null
.null
.The returned reader can be used to prompt the user to enter data in a secret way. This usually means that the characters the user enters will not be directly displayed on the computer screen, but will be hidden. (E.g. the console doesn't echo back the characters, or using a password text box.)
Reading functions on the returned result may lock the standard IO lock before reading the secret input, but may not based on the implementation.
Callers must handle the case if the secret reader is not available. This usually means that the build execution was configured in a way that direct input reading is not possible. (E.g. during a CI (continuous integration) build.)
null
if not available.The standard error is private to the currently executed task. It is buffered, but unlike the standard out, will not be flushed during the execution of the task, only after it has finished. It will be flushed as a block of bytes and will not be interlaced with concurrently executing tasks.
The display identifier is not prepended to the lines of this output. The contents written to standard err will not be replayed when the task is not rerun due to no deltas.
The returned sink is not thread-safe, the caller must ensure proper synchronization, otherwise bytes written to the sink may be lost, or scrambled.
The standard input is shared by all concurrently running tasks in the same build environment. The current task must lock on the standard I/O lock via TaskContext.acquireStandardIOLock() before calling any reading functions on the returned stream. Not locking will result in a TaskStandardIOLockIllegalStateException when calling reading functions.
The standard input and output can be both used when the lock is acquired to provide an interactive interface to the user.
The standard output is private to the currently executed task. It is buffered, and is flushed when the execution sees it as a best opportunity. The buffering occurs on a per-line basis, no partially finished lines will be printed, unless the execution-wide standard I/O lock is acquired.
The bytes written to this stream is examined and every line is prepended with the currently set display
identifier. (See TaskContext.setStandardOutDisplayIdentifier(
The bytes written to this stream is not replayed to the user if the task is not rerun due to no deltas. To print
information which are replayed use TaskContext.println(
When buffered lines are flushed from this stream they might be interlaced with output lines of concurrently executing tasks. They might be interlaced, but they will not be mangled.
null
if not available. The build directory is based on the execution-wide base build directory and the task execution parameters specified for the task.
It is strongly recommended that unless explicitly specified by the user, all tasks produce outputs under the directory returned by this method.
To avoid checking null
result of this method consider using
SakerPathFiles.requireBuildDirectory(
null
if not available.
The returned path is the absolute execution path to the build directory of the task. This is affected by the
task execution parameters. The result may be null
, if there's
no build directory configured for the task or build execution.
The path is the same as TaskDirectoryContext.getTaskBuildDirectory().getSakerPath() would return.
null
if none.The task is not required to be started, or exist in the build runtime as of the calling of this function. Futures can be obtained to not yet started tasks as well.
Same as:
getTaskFuture(taskid).getAsDependencyFuture();
null
.The task is not required to be started, or exist in the build runtime as of the calling of this function. Futures can be obtained to not yet started tasks as well.
null
.This method waits for the specified task if needed, and works the same way as TaskFuture.get().
If this method throws a TaskExecutionFailedException, it is considered to be a valid return scenario. A dependency on the the associated task will be installed as if a return value was returned.
Callers should handle the possiblity of tasks returning StructuredTaskResult instances.
null
if the task returned null
as a
result.null
.The retrieval of the handle is implementation dependent. The TaskResultDependencyHandle.get() method may return structured task results.
null
.The utility instance provides bulk operations, utility functions, and extensions for working with task context.
Usage of this is especially recommended when designing remote executable tasks.
The task utilities exist for the purpose of keeping the TaskContext interface clean and functions which could bloat the interface are implemented in the utilities instance.
The working directory is based on the execution-wide base working directory and the task execution parameters specified for the task.
Any relative paths used by this task should be resolved against this directory.
Note: In some cases this method may return null
. This might be for example when the build
system is detecting the deltas for a given task, and the working directory path did not resolve to an actual
path. Callers in FileCollectionStrategy.collectFiles(null
. If this method is called during
task execution (I.e. inside Task.run(null
.)
The returned path is the absolute execution path to the working directory of the task. This is affected by the task execution parameters.
The path is the same as TaskDirectoryContext.getTaskWorkingDirectory().getSakerPath() would return.
It can be used to resolve relative user arguments against it without actually querying the SakerDirectory instance.
null
.
This method needs to be called when tasks decides to externally modify files which are referenced by the build
system.
External modifications include:
- Modifying a file using an external process. (E.g. spawning an external compiler process)
- Using direct Java I/O APIs to modify files. E.g. File, Path and related classes.
- Directly modifying files using file providers.
- Other file modifications that aren't done through the SakerFile API.
If task implementations forget to call this method, the synchronization of the files might not work as expected. Synchronizations might be skipped, while the file contents won't be the same as expected.
Generally if task implementations do not overwrite files multiple times, and keep intermediate files separate, they don't need to expect failures. Tasks should aim to mainly use the SakerFile API or if they really need to, only work with the local file system.
If task implementations only use SakerFile.synchronize() and related functions, they don't need to call this.
Calling this method will not modify the SakerFile in-memory hierarchy in any way.
Internal implementation note: This function invalidates the specified handle for the content database. As the content database can cache file disk contents, this method needs to be called so the cached data is invalidated. If this method is not called, then the content database might not re-check the disk contents before synchronization. In that case the synchronization will be skipped, even though it should happen.
When remote execution (via clusters) are used, this method will invalidate the local cache content database and the main content database as well. In some cases it can happen that the content database on the actual file system where the file resides will not be invalidated. This can happen when a task on cluster A modifies a file on cluster B. It is a very insignificant edge-case and it it strongly discouraged to configure an execution where such a scenario can happen.
null
.
This method works the same way as TaskContext.invalidate(
null
if the file doesn't exist.null
.
The method works like TaskContext.invalidate(
This method works only if the argument file resides on a filesystem that supports posix file permissions.
Otherwise this method works the same way as TaskContext.invalidate(
null
.Same as calling:
mirror(file, DirectoryVisitPredicate.everything());
null
.If the file is a directory, then the parameter predicate will be used to select the files to mirror.
See TaskContext documentation for more information about mirroring.
null
,
DirectoryVisitPredicate.everything() will be used.null
.The method will resolve the specified path to a directory and execute the mirroring.
If the file doesn't exist, or not a directory, an exception is thrown.
null
,
DirectoryVisitPredicate.everything() will be used.The method will resolve the specified path to a file and execute the mirroring.
If the file doesn't exist, or is a directory, an exception is thrown.
null
.
The method works the same way as TaskExecutionUtilities.mirrorFileAtPath(
null
.Calling this method might implicitly synchronize the file to its real location, or to some other cache location when remote execution is used.
null
.Calling this method might implicitly synchronize the file to its real location, or to some other cache location when remote execution is used.
null
.This method is called for each file tag that is passed to any of the file dependency management methods.
The default implementation directly returns the argument.
null
.This method is called for each file tag that is passed to any of the file dependency management methods.
The default implementation directly returns the argument.
null
.This method is called for each task output tag that is passed to any of the task output management methods.
The default implementation directly returns the argument.
null
.The lines printed using this function will be replayed if the task is not executed again due to no incremental changes.
The line is automatically prepended by the display identifier if set.
To display uniformly formatted data, we recommend using SakerLog logging functions.
The argument line will be automatically appended with a line ending character(s).
When the lock is released all partially finished lines of TaskContext.getStandardOut() will be ended.
This method works the same way as TaskContext.println(
null
This method records the dependency value for the given property for the execution runtime. When the task is executed next time in an incremental manner, the current value for the property will be compared to the expected value. If it changed, an appropriate delta will be triggered and the task will be rerun.
null
.This method records the dependency value for the given property for the execution runtime. When the task is executed next time in an incremental manner, the current value for the property will be compared to the expected value. If it changed, an appropriate delta will be triggered and the task will be rerun.
null
.IDE configurations can be considered as meta-data from the tasks which can be used to properly configure an editor for IDE related features.
Tasks are not required to always report IDE configurations, it can be toggled by the user using execution parameters. If a task decides to adhere these configuration changes, make sure to report an execution dependency, so the task is rerun when the parameter changes. (See IDEConfigurationRequiredExecutionProperty)
null
.
This method works the same way as TaskContext.reportIgnoredException(
Unhandled exceptions do not modify the operation of the task or the build execution. The build system may present these to the user to debug or analyze possible inconsistent build output.
Ignoring an exception should not modify the output of a task in any way.
One good example for an ignored exception is one thrown during verbose logging to the standard output. When the task tries to write some verbose information about the execution output, but it fails with an exception, then the task might choose to ignore the thrown exception, as it doesn't modify the result of the task in any way, but only the displayed information to the user.
The build system may handle the ignored exceptions in an implementation dependent way.
If the parameter is null
, a NullPointerException will be ignored.
The build executor will collect the files for the dependency next time the task is incrementally run. If it detects any added files, then an appropriate delta will be triggered, and the task will be rerun.
Important: The task needs to report any used files as input dependencies via
TaskContext.reportInputFileDependency(
Example:
The task reports a file addition dependency, and reports the file A as input.
The user adds file B as a new file. Next time the task is incrementally run, the build executor collects
the files, and will report file B as an addition with the appropriate delta and rerun the task.
If the task didn't report file A, then the build executor would report file A as an addition, even
though it is not newly added. It is important to report the files the task uses as input dependency.
A file addition dependency can be reported multiple times, with different tags as well.
null
.null
.
See TaskContext.reportInputFileDependency(
null
.The build executor will check if the contents of the file at the given path have changed next time the task is incrementally run. If it detects changes, then an appropriate delta will be triggered, and the task will be rerun.
When an input dependency is reported multiple times with the same path and tag, then the actually recorded contents is chosen in an implementation dependent manner, and no exception is thrown.
See TaskContext.getTaskUtilities() for reporting bulk file dependencies, or working with file instances directly.
null
is treated as if the file is expected to not
exist.null
.null
.
See TaskContext.reportOutputFileDependency(
null
.The build executor will check if the contents of the file at the given path have changed next time the task is incrementally run. If it detects changes, then an appropriate delta will be triggered, and the task wil be rerun.
When an output dependency is reported multiple times with the same path and tag, then the actually recorded contents is chosen in an implementation dependent manner, and no exception is thrown
It is recommended that all output files are under the build directory, unless explicitly specified by the user.
The reported output files are not automatically synchronized by the build runtime. (See SakerFile.synchronize())
See TaskContext.getTaskUtilities() for reporting bulk file dependencies, or working with file instances directly.
null
is treated as if the file is expected to not
exist.null
.
Setting an output change detector for the self task can result in skipping rerunning the tasks which depend on
this task. The set detector should report the output unchanged if the object returned from
Task.run(
The task can report themselves as unchanged, if output files of the task changed, but the information held in the output object remained the same. Usually EqualityTaskOutputChangeDetector is used with this method instantiated with the returned output object.
A very simple example for this:
A task calculates the sum of two input integers. In the first run it calculates 1 + 3. The input integers change
for the next build, and the task will now calculate 2 + 2.
As the outputs of the task is the same, setting a self change detector can result in not rerunning any other
tasks which depend on this.
null
.null
if not found.null
.null
if not found.null
, or path is relative and base directory is null
.If the path is relative, it will be resolved against the current task working directory.
If it is absolute, the execution root directories will be used as a base of resolution.
null
if not found.null
.null
if not found.null
.The path names are interpreted as if they were relative compared to the base directory.
null
if not found.null
.null
if a directory was not found at the path.null
.null
.This method doesn't overwrite the already existing file at the path if it's not a directory.
null
if it cannot be created.null
.null
if a directory was not found at the path.null
, or path is relative and base directory is null
.If the path is relative, it will be resolved against the current task working directory.
If it is absolute, the execution root directories will be used as a base of resolution.
null
if a directory was not found at the path.null
.null
, or path is relative and base directory is null
.If the path is relative, it will be resolved against the current task working directory.
If it is absolute, the execution root directories will be used as a base of resolution.
null
.null
if it cannot be created.null
, or path is relative and base directory is null
.This method doesn't overwrite the already existing file at the path if it's not a directory.
If the path is relative, it will be resolved against the current task working directory.
If it is absolute, the execution root directories will be used as a base of resolution.
null
if it cannot be created.null
.null
if a directory was not found at the path.null
.null
.This method doesn't overwrite the already existing file at the path if it's not a directory.
null
if it cannot be created.null
.The path names are interpreted as if they were relative compared to the base directory.
null
if a directory was not found at the path.null
.The path names are interpreted as if they were relative compared to the base directory.
null
.This method doesn't overwrite the already existing file at the path if it's not a directory.
The path names are interpreted as if they were relative compared to the base directory.
null
if it cannot be created.null
.null
if not found or it's a directory.null
.null
if not found or it's a directory.null
, or path is relative and base directory is null
.If the path is relative, it will be resolved against the current task working directory.
If it is absolute, the execution root directories will be used as a base of resolution.
null
if not found or it's a directory.null
.null
if not found.null
.The path names are interpreted as if they were relative compared to the base directory.
null
if not found or it's a directory.null
.null
.null
execution parameters, but returns void
.null
.void
.null
to use the defaults.null
.null
.null
.
This method is similar to TaskExecutionUtilities.runTaskResult(
null
to use the defaults.null
.null
.null
.
A task dependency will be added for the started task with the same rules as in
TaskContext.getTaskResult(
null
to use the defaults.null
.Meta-datas can be used by the executing environment (e.g. IDEs, custom launchers) to extract information from the executed tasks.
null
.
The line display identifier is prepended to each line printed to the standard output during the execution. The
identifier format is surrounded by brackets. (E.g. [<identifier>]
)
The display identifier is not printed to the standard error output.
null
to disable it.Arbitrary tag-value pairs can be set as a task output which can be retrieved in a later execution when the task is incrementally invoked.
The tags and values should be preferrably Externalizable, but at least Serializable.
The build system does not handle these tags and values in a special way. They only serve a purpose of storing arbitrary data between incremental executions of the same task.
The tags should implement Object.equals(
null
.This method will start an inner task execution using the given task factory and parameters.
Inner tasks are handled in a completely different way as plain tasks. The are ought to be treated as a simple
function that runs in the same task context as this task. When you start an inner task, the build system will
instantiate a task object from the task factory, and run it with the same task context as this
for
its parameter. Any depedencies, and operations that the inner task executes will behave the same way if the
caller task executed it.
Inner tasks don't have a task identifier. They are not tracked by the build system, and they are not automatically rerun when incremental changes are detected. The build system will not store the inner tasks between executions, and will not emit deltas if the associated task factories are changed.
As they don't have a task identifier, they are allowed to execute multiple times. As they are only valid in the context of the enclosing task, they are allowed to share state between them in regards to the enclosing task context.
The main reason of using inner tasks is to fine-grain the performance of a composite task. As inner tasks can share state, it may be beneficial for a task to split up its work into smaller inner tasks while possibly dispatching the work to remote clusters or balancing the load with computation tokens.
The build system will handle the additional methods of TaskFactory which specify where and how the task can be invoked. The capabilities of the tasks are taken into account when invoking inner tasks.
Inner tasks cannot be cacheable. As they are not explicitly tracked by the build system, caching them is not allowed. If you need to cache inner tasks, consider using normal subtasks instead.
If the inner task reports computation tokens, then the enclosing task must report the TaskFactory.CAPABILITY_INNER_TASKS_COMPUTATIONAL capability to ensure proper operation. This is in order to ensure that the enclosing task complies with the restrictions that computation token usage imposes.
Inner tasks may be declared to be short, in which case they behave the same way normal tasks would work. They are invoked a single time and are not duplicated (see below). Generally, using short inner tasks have limited use-cases, as the work the inner task does can be executed directly in the enclosing task.
Inner tasks can select their execution environment the same way as normal tasks do. See
TaskFactory.getExecutionEnvironmentSelector(). The execution environment selector will be used to find
only one suitable environment. When duplication is used, any further execution environments will be chosen
automatically based on the reported qualifier properties. If all of the qualifier properties match on a candidate
environment, it will be added to the duplicateable environments without checking the suitability again with the
environment selector.
Note: The qualifier environment properties will not be automatically added as a dependency for the
task.
The inner task is being run based on the above mentioned capabilities and the execution parameters of this function. When specified so using the parameters, the inner tasks can be duplicated to other build clusters used by the current build execution. In this case the build system will dispatch the tasks to the appropriate clusters and execute them possibly multiple times on each one. This process is called duplication.
Inner task duplication occurrs with respect to the selected suitable execution environments and reported computation tokens. Duplication is useful when the enclosing task can divide its work up in a way that one execution unit will correspond to one inner task, but doesn't care about where the task is being executed. In this case the task can use as much computational resources that is available to it, therefore maximizing the build performance.
The result of this function is an object that provides access to the results of the inner tasks. The returned object can have zero, single, or multiple results of the inner tasks. As the number of times the task is invoked dependends on the specified execution parameters, it cannot be determined how many times the inner task will actually be duplicated. The returned object can be thought as an iterator on the results of the inner tasks.
The enclosing tasks are not required to wait for the completions of the inner tasks. If the
Task.run(
Inner task factories are not required to implement any serialization related functionality, only of there is remote execution involved. In that case the caller should make sure to properly transfer the task factory and any shared states over RMI.
null
to use the defaults.null
.This method returns no result.
null
.This method returns no result.
null
.Calling this method will post the specified task for execution to the build runtime. The time of execution is unspecified, can be run instantly, delayed to a later time, or started concurrently.
This method will raise a TaskIdentifierConflictException if the task with the same identifier was already started previously (by this or an other task) and the specified task factories does not equal. Important: It will not raise an exception if a task was already started previously but the execution parameters are different. If one needs to execute some task that relies on specific execution parameters, then the relevant parts of the execution parameters should be included in the task identifier as well.
For more convenient methods to start tasks, see TaskContext.getTaskUtilities().
null
to use the defaults.null
.null
.null
.This function starts every task with the parameters specified by each launch arguments.
This function works the same way as if TaskExecutionUtilities.startTask(
This function returns void
, to retrieve the futures for the started tasks as well, use
TaskExecutionUtilities.startTasksFuture(
null
.The started tasks will use the default execution parameters.
This function works the same way as TaskExecutionUtilities.startTasks(null
execution parameters.
null
.
The passed execution parameters will be used for each started task. If null
, the default parameters
will be used.
null
.
This function works the same way as if TaskExecutionUtilities.startTaskFuture(
The returned list of task futures will have the same order as the argument iterable.
null
.This method synchronizes the contents of the source path file to the target path.
If the source file is a file, its contents will be updated to the target path. If a file already exists at the target path, it will be overwritten. Parent directories will be created at the target path if necessary. Specifying the flag TaskExecutionUtilities.SYNCHRONIZE_FLAG_NO_OVERWRITE_DIRECTORY will cause the synchronization to throw an exception if a non-empty directory already exists at the target. Empty directories at the target path will be deleted and overwritten with the byte contents of the source file.
If the source file is a directory, then a directory will be created at the target path. Children of the source directory are not synchronized. If a file already exists at the target path, it will be deleted and a directory is created instead. If a directory already exists at the target path, no operations are done. Parent directories are created appropriately.
SYNCHRONIZE_FLAG_*
constants in the class.null
.The implementation doesn't examine the nature of the retrieved paths. If there are conflicting paths, then the resulting map may be smaller in size than the passed input. E.g. If multiple files have no parent, but same file name, only one will be in the result map with its name.
When calling this during remote execution, it is recommended that the files reside on the coordinator machine.
null
.The implementation doesn't examine the nature of the retrieved paths. If there are conflicting paths, then the resulting map may be smaller in size than the passed input. E.g. If multiple files have no parent, but same file name, only one will be in the result map with its name.
When calling this during remote execution, it is recommended that the files reside on the coordinator machine.
null
.Calling this method might implicitly synchronize the file to its real location, or to some other cache location when remote execution is used.
null
.Calling this method might implicitly synchronize the file to its real location, or to some other cache location when remote execution is used.
null
.