Skip to content

@ui5/project/build/ProjectBuilder

@ui5/project/build/ProjectBuilder

new @ui5/project/build/ProjectBuilder(parameters)

Description: Executes a project build, including all necessary or requested dependencies

Source: project/lib/build/ProjectBuilder.js, line 15

Parameters:
NameTypeDescription
parametersobject
Properties:
NameTypeAttributesDescription
graph@ui5/project/graph/ProjectGraphProject graph
buildConfig@ui5/project/build/ProjectBuilder~BuildConfigurationoptionalBuild configuration
taskRepository@ui5/builder/tasks/taskRepositoryTask Repository module to use
ui5DataDirstringoptionalExplicit UI5 data directory to use for the build cache, overriding the
UI5_DATA_DIR environment variable, the UI5 configuration file,
and the default of ~/.ui5.

Methods

(async) build(parameters, projectBuiltCallbackopt) → {Promise<Array<string>>}

Description: Build projects without writing to a target directory.

Intended for long-running consumers (such as the BuildServer) that access build results through readers rather than the file system. Multiple sequential calls are supported and reuse the same build cache.

The caller is responsible for releasing the underlying build cache database by invoking #closeCacheManager once the builder is no longer needed. Failing to do so leaks the SQLite connection and its memory mapping, which on Windows also blocks deletion of the cache directory by subsequent processes.

Source: project/lib/build/ProjectBuilder.js, line 183

Parameters:
NameTypeAttributesDescription
parametersobjectParameters
Properties:
NameTypeAttributesDefaultDescription
includeRootProjectbooleanoptionaltrueWhether to include the root project
includedDependenciesArray<(string | RegExp)>optional[]List of dependencies to include
excludedDependenciesArray<(string | RegExp)>optional[]List of dependencies to exclude
signalAbortSignaloptionalSignal to abort the build
projectBuiltCallbackfunctionoptionalCallback invoked after each project is built
Returns:

Promise resolving with array of processed project names

Type: Promise<Array<string>>

(async) buildToTarget(parameters) → {Promise}

Description: Executes a project build, including all necessary or requested dependencies, and writes the result to the given target directory.

Closes the build cache database before returning, so #closeCacheManager does not need to be called by the consumer. After this method returns, the builder must not be used for further builds. For repeated builds against the same builder instance — e.g. in a long-running BuildServer — use #build instead and close the CacheManager explicitly when done.

Source: project/lib/build/ProjectBuilder.js, line 254

Parameters:
NameTypeDescription
parametersobjectParameters
Properties:
NameTypeAttributesDefaultDescription
destPathstringTarget path
cleanDestbooleanoptionalfalseDecides whether project should clean the target path before build
includedDependenciesArray<(string | RegExp)>optional[]List of names of projects to include in the build result
If the wildcard '*' is provided, all dependencies will be included in the build result.
excludedDependenciesArray<(string | RegExp)>optional[]List of names of projects to exclude from the build result.
dependencyIncludes@ui5/project/build/ProjectBuilder~DependencyIncludesoptionalAlternative to the includedDependencies and excludedDependencies parameters.
Allows for a more sophisticated configuration for defining which dependencies should be
part of the build result. If this is provided, the other mentioned parameters are ignored.
Returns:

Promise resolving once the build has finished

Type: Promise

closeCacheManager()

Description: Releases the build cache database connection and any underlying storage resources.

Must be called by consumers of #build once they are done with this builder (e.g. when shutting down a long-running BuildServer). #buildToTarget closes the CacheManager automatically and does not require this call.

Safe to call multiple times; subsequent calls are no-ops. After this method returns, the builder must not be used for further builds.

Source: project/lib/build/ProjectBuilder.js, line 157

resourcesChanged(changes) → {Set<string>}

Description: Propagate resource changes through the build context

Source: project/lib/build/ProjectBuilder.js, line 138

Parameters:
NameTypeDescription
changesArrayArray of resource changes to propagate
Throws:

If a build is currently running

Type: Error

Returns:

Names of projects potentially affected by the resource changes

Type: Set<string>

(async) validateCaches(parameters, projectValidatedCallbackopt) → {Promise<Array<string>>}

Description: Validate the build cache for a set of projects without actually building any of them.

Intended to be used by long-running consumers (such as the BuildServer) to proactively determine whether a cached build result can be reused for a project. Walks the dependency graph in the same order as #build, so dependencies are validated before their dependents and resource changes propagate correctly.

For each requested project, the given callback is invoked with the validation result once that project has been validated. The result indicates whether a cached build result is available and can be used (true) or whether a build would be required (false).

Like #build, this method is mutually exclusive with itself and with other build operations on the same builder instance. Source change propagation via #resourcesChanged is blocked while validation is running.

Source: project/lib/build/ProjectBuilder.js, line 225

Parameters:
NameTypeAttributesDescription
parametersobjectParameters
Properties:
NameTypeAttributesDescription
projectsArray<string>Names of projects to validate
signalAbortSignaloptionalSignal to abort the validation
willValidatefunctionoptionalHook invoked synchronously just before each project's validateCache
call. Receives (projectName). Return value is ignored. Use this to
claim the project state in the caller (e.g. transition to a "validating"
lifecycle state).
projectValidatedCallbackfunctionoptionalCallback invoked after each requested project has been validated.
Receives (projectName, project, projectBuildContext, usesCache).
Returns:

Promise resolving with the names of all processed projects

Type: Promise<Array<string>>

Type Definitions

BuildConfiguration

Description: Build Configuration

Source: project/lib/build/ProjectBuilder.js, line 19

Properties:
NameTypeAttributesDefaultDescription
selfContainedbooleanoptionalfalseFlag to activate self contained build
cssVariablesbooleanoptionalfalseFlag to activate CSS variables generation
jsdocbooleanoptionalfalseFlag to activate JSDoc build
createBuildManifestbooleanoptionalfalseWhether to create a build manifest file for the root project.
This is currently only supported for projects of type 'library' and 'theme-library'
No other dependencies can be included in the build result.
outputStylemodule:@ui5/project/build/ProjectBuilderOutputStyleoptionalDefaultProcesses build results into a specific directory structure.
includedTasksArray<string>optional[]List of tasks to be included
excludedTasksArray<string>optional[]List of tasks to be excluded.
If the wildcard '*' is provided, only the included tasks will be executed.
cachemodule:@ui5/project/build/cache/CacheoptionalCache.DefaultCache mode to use for building UI5 projects

Build Configuration

Type:
  • object

DependencyIncludes

Description: As an alternative to providing plain lists of names of dependencies to include and exclude, you can provide a more complex "Dependency Includes" object to define which dependencies should be part of the build result.
This information is then used to compile lists of includedDependencies and excludedDependencies, which are applied during the build process.

Regular expression-parameters are directly applied to a list of all project dependencies so that they don't need to be evaluated in later processing steps.

Generally, includes are handled with a higher priority than excludes. Additionally, operations for processing transitive dependencies are handled with a lower priority than explicitly mentioned dependencies. The "default" dependency-includes are appended at the end.

The priority of the various dependency lists is applied in the following order. Note that a later exclude can't overrule an earlier include.

  1. includeDependency, includeDependencyRegExp
  2. excludeDependency, excludeDependencyRegExp
  3. includeDependencyTree
  4. excludeDependencyTree
  5. defaultIncludeDependency, defaultIncludeDependencyRegExp, defaultIncludeDependencyTree

Source: project/lib/build/ProjectBuilder.js, line 40

Properties:
NameTypeDescription
includeAllDependenciesbooleanWhether all dependencies should be part of the build result
This parameter has the lowest priority and basically includes all remaining (not excluded) projects as include
includeDependencyArray<string>The dependencies to be considered in includedDependencies; the
* character can be used as wildcard for all dependencies and
is an alias for the CLI option --all
includeDependencyRegExpArray<string>Strings which are interpreted as regular expressions
to describe the selection of dependencies to be considered in includedDependencies
includeDependencyTreeArray<string>The dependencies to be considered in includedDependencies;
transitive dependencies are also appended
excludeDependencyArray<string>The dependencies to be considered in excludedDependencies
excludeDependencyRegExpArray<string>Strings which are interpreted as regular expressions
to describe the selection of dependencies to be considered in excludedDependencies
excludeDependencyTreeArray<string>The dependencies to be considered in excludedDependencies;
transitive dependencies are also appended
defaultIncludeDependencyArray<string>Same as includeDependency parameter;
typically used in project build settings
defaultIncludeDependencyRegExpArray<string>Same as includeDependencyRegExp parameter;
typically used in project build settings
defaultIncludeDependencyTreeArray<string>Same as includeDependencyTree parameter;
typically used in project build settings

As an alternative to providing plain lists of names of dependencies to include and exclude, you can provide a more complex "Dependency Includes" object to define which dependencies should be part of the build result.
This information is then used to compile lists of includedDependencies and excludedDependencies, which are applied during the build process.

Regular expression-parameters are directly applied to a list of all project dependencies so that they don't need to be evaluated in later processing steps.

Generally, includes are handled with a higher priority than excludes. Additionally, operations for processing transitive dependencies are handled with a lower priority than explicitly mentioned dependencies. The "default" dependency-includes are appended at the end.

The priority of the various dependency lists is applied in the following order. Note that a later exclude can't overrule an earlier include.

  1. includeDependency, includeDependencyRegExp
  2. excludeDependency, excludeDependencyRegExp
  3. includeDependencyTree
  4. excludeDependencyTree
  5. defaultIncludeDependency, defaultIncludeDependencyRegExp, defaultIncludeDependencyTree
Type:
  • object