saker.build Documentation TaskDoc JavaDoc Packages
public final class BuildTrace
This is the client API class for reporting build trace information.

Clients can use the static methods in this class to report build trace related events and related information during the build execution. These methods will record the events and handle them accordingly in an internal manner.

If the build execution is not set up to produce a build trace, the methods will return instantly. The methods will attempt to return as fast as possible to avoid delaying the build itself. This may result in the build trace events being cached, buffered, or otherwise reported in an implementation dependent manner.

The methods of this class will never throw any exceptions.

Note: Functions in this class (unless stated otherwise) rely on internal inheritable thread locals to appropriately record the build trace information. If you spawn new threads that don't inherit these thread locals then some information may not be properly recorded in the build trace.
Note: This mechanism is planned to be changed in a future release to not require inheritable thread locals.

saker.build 0.8.6
Fields
public static final int
The artifact should be always embedded in the build trace.
public static final int
The default embed value for output artifacts.
public static final int
Embed flag for build artifacts signaling that the artifact contents should be considered confidental.
public static final int
The artifact should be never embedded in the build trace.
public static final String
Classification representing a configuration task.
public static final String
Classification representing an external task.
public static final String
Classification representing a frontend task.
public static final String
Classification representing a meta task.
public static final String
Classification representing a task that performs transformation operations.
public static final String
Classification representing a worker task.
public static final String
Custom value category for tasks or inner tasks.
public static final String
Custom value category for tasks or inner tasks.
Methods
public static void
addValues(Map<?, ?> values, String category)
Adds custom values for the specified category.
public static void
classifyTask(String classification)
Classifies the current task to be a given semantic type.
public static void
Reports an ignored exception for the build trace.
public static void
Reports an ignored exception for the build trace.
public static boolean
Gets if any build trace information is being recorded.
public static void
Marks the caller inner task to be omitted from the build trace.
public static void
reportOutputArtifact(SakerPath path, int embedflags)
Reports an output artifact of the build.
public static void
Runs a given operation if a build trace is being recorded.
public static void
setDisplayInformation(String timelinelabel, String title)
Sets the display information of the currently running task or inner task.
public static void
setValues(Map<?, ?> values, String category)
Sets custom values for the specified category.
public static final int ARTIFACT_EMBED_ALWAYS = 2
The artifact should be always embedded in the build trace.

This constant is a value for embed flags when reporting output build artifacts.

This value causes the artifact to be always written in the build trace. It overrides the user preference of artifact embedding. Generally, this value should be rarely used, only if the user explicitly specifies it for the build task.

saker.build 0.8.7
public static final int ARTIFACT_EMBED_DEFAULT = 0
The default embed value for output artifacts.

The associated artifact will be embedded in the build trace if the user configures the build trace to embed artifacts. (-trace-artifacts-embed command line parameter)

saker.build 0.8.7
public static final int ARTIFACT_EMBED_FLAG_CONFIDENTAL = 32768
Embed flag for build artifacts signaling that the artifact contents should be considered confidental.

This value can be combined with any other ARTIFACT_EMBED_* constant.

Specifying this flag will cause the build trace to encrypt the contents of the output artifact with an user specified password.

If the user haven't specified a password for the build trace, the contents of the artifact are not written in the build trace at all, and instead a note is persisted telling them to specify a password.

saker.build 0.8.7
public static final int ARTIFACT_EMBED_NEVER = 1
The artifact should be never embedded in the build trace.

This constant is a value for embed flags when reporting output build artifacts.

saker.build 0.8.7
public static final String CLASSIFICATION_CONFIGURATION = "configuration"
Classification representing a configuration task.

Configuration tasks don't perform long running or complex build operations, but only retrieve some configuration object based on the input parameters. These configuration objects are usually inputs to other tasks to configure their behaviour.

Configuration tasks are may be omitted in the build trace viewer.

public static final String CLASSIFICATION_EXTERNAL = "external"
Classification representing an external task.

External tasks are tasks that generally perform no other operation but directly invoke another task. That is, calling Task.run(TaskContext), and not starting them through TaskContext.

Generally, external tasks are only reported by the build system or script language implementation when they bootstrap the actually invoked tasks. Under normal circumstances, you don't classify your build tasks as being external.

The build trace viewer may decide to omit external tasks from the view in some cases.

public static final String CLASSIFICATION_FRONTEND = "frontend"
Classification representing a frontend task.

Frontend tasks are responsible for parsing the input parameters of a given task and starting a worker task that performs the actual build operation.

This classification is similar to meta, but may be differentiated by the build trace if necessary.

Frontent tasks are generally omitted in the build trace viewer.

public static final String CLASSIFICATION_META = "meta"
Classification representing a meta task.

Meta tasks are considered to contribute little or nothing to the build results and serve only as a configuration or control flow task for the build execution.

Generally, meta tasks spend most of their time as waiting for other tasks, or performing other task management related operations.

Meta tasks are generally omitted in the build trace viewer.

public static final String CLASSIFICATION_TRANSFORMATION = "transformation"
Classification representing a task that performs transformation operations.

The tasks which are classified as transformation tasks serve the purpose of transforming various information in other form. In general, they are similar to configuration tasks, but they can perform longer running operations in cases where they need to.

Some examples for transformation tasks are:

  • Tasks which extract some files from an archive.
  • Task that constructs a file tree in the required format based on some inputs.
  • Tasks that convert files or other information to a different encoding or format. (E.g. convert JSON to XML)
In general transformation tasks don't perform compilations, or overall data validations, but rather change the representation of the data to a format that can be consumed in a specific way.

Transformation tasks are usually not displayed in the build trace, unless they throw exceptions or emit warnings.

Note that tasks that derive resources based on their inputs, or perform meaningful operations on them are recommended to be classified as worker tasks. E.g. a task that creates a ZIP archive based on its inputs should be classfied as worker task. However, if the ZIP is created for the sole purpose of consuming by another task, then it should be a transformation task.

saker.build 0.8.10
public static final String CLASSIFICATION_WORKER = "worker"
Classification representing a worker task.

Worker tasks are the ones that perform long running build operations. They are usually computationally heavy, and contribute to the actual build outputs.

E.g. compiling sources, downloading files, or other longer operations.

Generally, worker tasks provide meaningful performance information for the developer.

public static final String VALUE_CATEGORY_ENVIRONMENT = "environment"
Custom value category for tasks or inner tasks.

This constant can be used with custom value setting functions such as setValues(Map<?, ?>, String).

The values associated with this category are displayed alongside other build environment related information.

When values are set for this category, the values will be associated with the build environment of the caller. If the values are set on a build cluster, then they will be associated with that build environment instead of the coordinator environment.

In general values that are independent from the current build should be set with this category.

Note that you should not set values when the environment properties are being computed (see getCurrentValue). As they can be cached by the build environment, subsequent builds may not record these values.
To set build trace values related to environment properties, implement the TraceContributorEnvironmentProperty interface in your EnvironmentProperty. The contributeBuildTraceInformation method will be automatically called for the property to contribute its values.

saker.build 0.8.9
public static final String VALUE_CATEGORY_TASK = "task"
Custom value category for tasks or inner tasks.

This constant can be used with custom value setting functions such as setValues(Map<?, ?>, String).

The values associated with this category are be displayed alongside the task informations in the build trace. This includes the views where task details can be examined by the user.

If the values are set from an inner task, the values will be displayed for the calling inner task rather than the enclosing task.

saker.build 0.8.9
public static void addValues(Map<?, ?> values, String category)
Adds custom values for the specified category.

This method works similarly to setValues(Map<?, ?>, String), however it doesn't replace already existing values but merges them.

The merging is done based on the type of the already existing, and the currently added value. If there's no existing value, it is simply set. The following table demonstrates the merging action for the added value based on the types.

Existing\Added types Collection Map Primitive
Collection addAll ignore add
Map ignore putAll ignore
Primitive asCollection ignore asCollection
The addAll action will cause the resulting value to be a collection with the existing element(s) first. If both the existing and new values are instance of Set, then the resulting collection will be a Set as well.
The add action will append the element to the existing collection.
The putAll action will add all map entries to the existing collection. The map values are merged recursively.
The asCollection action will cause the existing and added values to be converted to a collection.
The ignore action will cause the existing value to be unmodified.
valuesThe values to add. If any value in the map is null, it will be ignored.
categoryThe associated category for the values. See the VALUE_CATEGORY_* constants. If null, VALUE_CATEGORY_TASK is assumed.
saker.build 0.8.9
public static void classifyTask(String classification)
Classifies the current task to be a given semantic type.

Classified tasks can be interpreted differently by the build trace viewer, and display more appropriate information to the user based on them.

classificationThe task classification. See the CLASSIFICATION_* constants in this class. Pass null to clear it.
public static void ignoredException(Throwable e)
Reports an ignored exception for the build trace.

Ignored exceptions are ones that don't cause the build to fail but can provide meaningful information about why the build run as it did. E.g. if a given SDK was not found at a specified location, but was found elsewhere, an ignored exception can be reported that tells the reasons why it was not found at the first location.

Tasks should call TaskContext.reportIgnoredException(ExceptionView) instead. This function is for reporting ignored exceptions that are not directly associated with a given task execution.

eThe exception that was ignored.
saker.build 0.8.14
public static void ignoredException(ExceptionView e)
Reports an ignored exception for the build trace.

Ignored exceptions are ones that don't cause the build to fail but can provide meaningful information about why the build run as it did. E.g. if a given SDK was not found at a specified location, but was found elsewhere, an ignored exception can be reported that tells the reasons why it was not found at the first location.

Tasks should call TaskContext.reportIgnoredException(ExceptionView) instead. This function is for reporting ignored exceptions that are not directly associated with a given task execution.

eThe exception that was ignored.
saker.build 0.8.14
public static boolean isRecordsBuildTrace()
Gets if any build trace information is being recorded.

If this method returns false, then calling other methods of this interface is a no-op.

true if a build trace is being recorded.
saker.build 0.8.9
public static void omitInnerTask()
Marks the caller inner task to be omitted from the build trace.

This method applies only to inner tasks. Calling it will cause the build trace to not contain the caller inner task in it.

This can be useful when an inner task performs no operations as there's none left. This can happen if an inner task gets duplicated to a build cluster, and gets executed, but there's no more work to be done as others already performed it concurrently.

In this case the inner task doesn't need to be part of the build trace as it's considered a no-op.

saker.build 0.8.14
public static void reportOutputArtifact(SakerPath path, int embedflags)
Reports an output artifact of the build.

The build trace will record an output file (artifact) that is considered to be part of the result of the build execution. The reported artifacts may be embedded in the build trace file, and they may be downloaded later when viewed.

The embedflags parameter control the manner how the artifact should be embedded.

pathThe path to the output build artifact.
embedflagsThe embedding flags for the artifact. See the ARTIFACT_EMBED_* constants in this class. May be 0 which is the same as ARTIFACT_EMBED_DEFAULT.
saker.build 0.8.7
public static void runWithBuildTrace(ThrowingRunnable run)
Runs a given operation if a build trace is being recorded.

The method will check if a build trace is being recorded, and if so, will call the argument runnable.

The method can be used to perform some more performance expensive information reporting if the build tracing is enabled. If no build trace is being recorded, this method quickly returns.

If any exception is thrown by the runnable, it will be ignored.

runThe runnable to run.
saker.build 0.8.9
public static void setDisplayInformation(String timelinelabel, String title)
Sets the display information of the currently running task or inner task.

The method will set the label that is displayed in the timeline view of the build trace, and the title that is displayed in other locations.

It is generally recommended that tht timeline label is short to be able to fit in a timeline block. The title may be longer, but should not be used to convey all information related to the task.

The titles should be unique enough for the user to differentiate different tasks of a kind, but not too long to avoid crowding the UI.

If the current task is an inner task, the display informations will be set for that instead of the enclosing task.

Use null parameters to clear the display information.

timelinelabelThe label for the timeline view or null.
titleThe title of the task or null.
public static void setValues(Map<?, ?> values, String category)
Sets custom values for the specified category.

Custom values are arbitrary string-object pairs that are associated with a given operation or build trace category. These values are displayed in the build trace at appropriate places.

The value objects may be ones that are recognized by the build trace recorder. The values should have a plain structure, and should not include circular references. The values can be nested in each other. The recognized types are the following:

The objects should be provided in a human-readable format as they may be displayed in the build trace viewer as is.

When this method is called, the specified values are normalized to an internal representation so any modification after this method returns won't affect the recorded values.

The specified category determines where the given values are displayed in the build trace. See the VALUE_CATEGORY_* constants for their placement.

String keys serving as names in the rendered build trace may contain the \t character in which case they are displayed in two separate columns when appropriate.

Note: Although this method takes a map with wildcard key type as its argument, only String keys are supported. It is wildcard for compatibility as we may support non-string keys in the future.

valuesThe values to set. If any value in the map is null, the recorded value with the given name will be removed.
categoryThe associated category for the values. See the VALUE_CATEGORY_* constants. If null, VALUE_CATEGORY_TASK is assumed.
saker.build 0.8.9