@ui5/project/resources/ProjectResources
@ui5/project/resources/ProjectResources
Manages resource access and stages for a project.
Constructor
new @ui5/project/resources/ProjectResources(options)
Source: project/lib/resources/ProjectResources.js, line 16
Parameters:
| Name | Type | Description | |||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options | object | Configuration options Properties:
|
Methods
getReader(optionsopt) → {@ui5/fs/ReaderCollection}
Description: Get a ReaderCollection for accessing all resources of the project in the specified "style":
- buildtime: Resource paths are always prefixed with
/resources/or/test-resources/followed by the project's namespace. Any configured build-excludes are applied - dist: Resource paths always match with what the UI5 runtime expects. This means that paths generally depend on the project type. Applications for example use a "flat"-like structure, while libraries use a "buildtime"-like structure. Any configured build-excludes are applied
- runtime: Resource paths always match with what the UI5 runtime expects. This means that paths generally depend on the project type. Applications for example use a "flat"-like structure, while libraries use a "buildtime"-like structure. This style is typically used for serving resources directly. Therefore, build-excludes are not applied
- flat: Resource paths are never prefixed and namespaces are omitted if possible. Note that project types like "theme-library", which can have multiple namespaces, can't omit them. Any configured build-excludes are applied
If project resources have been changed through the means of a workspace, those changes are reflected in the provided reader too.
Resource readers always use POSIX-style paths.
Source: project/lib/resources/ProjectResources.js, line 103
Parameters:
| Name | Type | Attributes | Description | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options | object | optional | Properties:
|
Returns:
A reader collection instance
Type: @ui5/fs/ReaderCollection
getSourceReader(styleopt) → {@ui5/fs/ReaderCollection}
Description: Get the source reader for the project.
Source: project/lib/resources/ProjectResources.js, line 165
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
style | string | optional | buildtime | Path style to access resources |
Returns:
A reader collection instance
Type: @ui5/fs/ReaderCollection
getStage() → {Stage|null}
Description: Get the current stage.
Source: project/lib/resources/ProjectResources.js, line 305
Returns:
The current stage or null if in result stage
Type: Stage | null
getWorkspace() → {@ui5/fs/DuplexCollection}
Description: Get a DuplexCollection for accessing and modifying a project's resources. This is always of style buildtime.
Once a project has finished building, this method will throw to prevent further modifications since those would have no effect. Use the getReader method to access the project's (modified) resources
Source: project/lib/resources/ProjectResources.js, line 194
Returns:
DuplexCollection
Type: @ui5/fs/DuplexCollection
initStages(stageIds)
Description: Initialize stages for the build process.
Source: project/lib/resources/ProjectResources.js, line 273
Parameters:
| Name | Type | Description |
|---|---|---|
stageIds | Array<string> | Array of stage IDs to initialize |
reopenStage(stageId)
Description: Reopen a stage with a fresh, empty live writer, discarding any cached read-only stage a prior #setStage installed for it.
Used when a step-based task's stage was a full cache hit that must be re-run after all (a consumed producer needs return changed): the fast-path restore had swapped in a read-only cached stage via #setStage, so the stage has no writer, and re-running its invocations needs a writable one. The reopened stage reads all previous stages exactly as #useStage does; the re-run's output goes into the fresh writer.
Source: project/lib/resources/ProjectResources.js, line 403
Parameters:
| Name | Type | Description |
|---|---|---|
stageId | string | The ID of the stage to reopen |
Throws:
If the stage does not exist
Type: Error
reset()
Description: Discards all stage state and returns the instance to its constructor-equivalent baseline: a single initial stage, no frozen source reader, and empty tag collections.
Used to recover from a build that threw mid-execution. Such a build leaves the current stage pointed at the failing task's writer (holding partial output) and the tag collections populated. After this call the next #getStage reports the initial stage, so the build cache re-initializes stages and re-imports cached results.
Source: project/lib/resources/ProjectResources.js, line 295
setFrozenSourceReader(reader)
Description: Sets a CAS-backed frozen source reader that provides immutable snapshots of untransformed source files. This reader is inserted into the reader chain between stage readers and the filesystem source reader, so that downstream dependency consumers read from CAS instead of the live filesystem.
Source: project/lib/resources/ProjectResources.js, line 178
Parameters:
| Name | Type | Description |
|---|---|---|
reader | @ui5/fs/AbstractReader | CAS-backed reader for frozen source files |
setStage(stageId, stageOrCachedWriter, projectTagOperations, buildTagOperations) → {boolean}
Description: Set or replace a stage.
Source: project/lib/resources/ProjectResources.js, line 352
Parameters:
| Name | Type | Description |
|---|---|---|
stageId | string | The ID of the stage to set |
stageOrCachedWriter | Stage | object | A Stage instance or a cached writer/reader |
projectTagOperations | Map<string, Map<string, *>> | |
buildTagOperations | Map<string, Map<string, *>> |
Throws:
If the stage does not exist or invalid parameters are provided
Type: Error
Returns:
True if the stored stage has changed, false otherwise
Type: boolean
useResultStage()
Description: Seal the workspace of the project, preventing further modifications. This is typically called once the project has finished building. Resources from all stages will be used.
A project can be unsealed by calling useStage() again.
Source: project/lib/resources/ProjectResources.js, line 226
useStage(stageId)
Description: Switch to a specific stage.
Source: project/lib/resources/ProjectResources.js, line 316
Parameters:
| Name | Type | Description |
|---|---|---|
stageId | string | The ID of the stage to use |
Throws:
If the stage does not exist
Type: Error

