You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: rfcs/0017-incremental-build.md
+30-8Lines changed: 30 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -102,20 +102,43 @@ Stages have an explicit order, based on the order they have been created/used. S
102
102
103
103
The `Task Runner` shall be enhanced to:
104
104
105
-
1. Consult the `Project Build Cache` before executing each task to determine whether the task needs to be executed or can be skipped based on the cache information.
106
-
2. After a task has been executed, update the `Project Build Cache` with information about the resources read and written during the task's execution.
105
+
1. Request the build signature of any tasks implementing the `determineBuildSignature` method at the beginning of the build process. These signatures are then incorporated into the overall build signature of the project (see [Cache Creation](#cache-creation)).
106
+
2. Consult the `Project Build Cache` before executing each task to determine whether the task needs to be executed or can be skipped based on the cache information.
107
+
3. Before executing a task, call the `determineOutputResources` method if provided. This allows the task to specify which resources it expects to write during its execution. The `Project Build Cache` can then use this information to detect and remove stale output resources that were produced in a previous execution of the task, but are no longer produced in the current execution.
108
+
2. After a task has been executed, update the `Project Build Cache` with information about the resources read and written during the task's execution, as well as the set of resources expected to be written (as provided by the `determineOutputResources` method).
107
109
* This can be achieved by providing the task with instances of the `workspace`-reader/writer and `dependencies`-reader that have been wrapped in `Tracker` instances. These trackers will monitor which resources are being accessed during the task's execution.
108
110
* The `Project Build Cache` will then:
109
111
* Update the metadata in the respective `Build Task Cache`
110
112
* Validate which resources have actually changed
113
+
* Delete or tag resources that have become stale
111
114
* Based on that, check which downstream tasks need to be potentially invalidated (see [Cache Invalidation](#cache-invalidation))
112
115
3. Provide the build task with a `buildCache` parameter, allowing it to access cache-related information during its execution. This can be used by tasks to optimize their processing based on which resources have changed since their last execution.
113
116
114
-
Build tasks shall be provided with the following new helper functions:
117
+
##### Build Task Cache API
115
118
116
-
*`hasCache`: Checks whether the project's build cache has an entry for the given task
117
-
*`getChangedProjectPaths`: Returns the set of changed project resource paths for the given task
118
-
*`getChangedDependencyPaths`: Returns the set of changed dependency resource paths for the given task
119
+
Build tasks shall be provided with the following new helper functions as part of a new `cacheUtil` helper class (similar to the existing [`taskUtil` helper class](https://ui5.github.io/cli/stable/pages/extensibility/CustomTasks/#helper-class-taskutil)):
120
+
121
+
***hasCache()**: Checks whether the project's build cache has an entry for the given task, i.e. whether the task has been executed in a previous build and its result has been cached
122
+
***getChangedProjectPaths()**: Returns a set of paths of resources that have changed in the project since the last execution of the given task
123
+
***getChangedDependencyPaths()**: Returns a set of paths of resources that have changed in the dependencies since the last execution of the given task
124
+
125
+
In addition, tasks may also implement the following new methods:
* `options`: Same as for the main task function. `{projectName, projectNamespace, configuration, taskName}`
130
+
* Returns: `undefined` or an arbitrary string representing the build signature for the task. This can be used to incorporate task-specific configuration files (e.g. tsconfig.json for a TypeScript compilation task) into the build signature of the project, causing the cache to be invalidated if those files change. The string shouldn't be a hash value (the build signature hash is calculated later on). If `undefined` is returned, or if the method is not implemented, it is assumed that the task's cache remains valid until relevant input-resources change.
131
+
* This method is called once at the beginning of every build. The return value used to calculate a unique signature for the task based on its configuration. This signature is then incorporated into the overall build signature of the project (see [Cache Creation](#cache-creation) below).
* `workspace`: Reader to access resources of the project's workspace (read only)
134
+
* `dependencies`: Reader to access resources of the project's dependencies
135
+
* `cacheUtil`: Same as above
136
+
* `log`: A logger instance scoped to the task
137
+
* `options`: Same as for the main task function. `{projectName, projectNamespace, configuration, taskName}`
138
+
* Returns: A set of resource paths which the task anticipates to write (output) in a clean run. That is, without cache. In case the task ends up writing resources outside of this set, an error will be produced.
139
+
* This method is called right before the task is being executed. It is used to detect stale output resources that were produced in a previous execution of the task, but are no longer produced in the current execution. Such stale resources must be removed from the build output to avoid inconsistencies.
140
+
141
+
These methods took some inspiration from to the existing [`determineRequiredDependencies` method](https://github.com/UI5/cli/blob/main/rfcs/0012-UI5-Tooling-Extension-API-3.md#new-api-2) ([docs](https://ui5.github.io/cli/stable/pages/extensibility/CustomTasks/#required-dependencies)).
119
142
120
143
#### Tracker
121
144
@@ -442,7 +465,7 @@ An alternative to using the incremental build in the UI5 CLI server would be to
442
465
443
466
## Unresolved Questions and Bikeshedding
444
467
445
-
* How to distinguish projects with build cache from pre-built projects (with project manifest)
468
+
*✅ How to distinguish projects with build cache from pre-built projects (with project manifest)
446
469
* Check presence of "sourceMetadata" attribute. Only with "sourceMetadata", the cache can be used for incremental (re-)builds the project. Otherwise it is "only" a build *result* that can be used for building dependent projects.
447
470
* Cache related topics
448
471
* Allow tasks to store additional information in the cache
@@ -451,4 +474,3 @@ An alternative to using the incremental build in the UI5 CLI server would be to
451
474
* What if a task ceases to create a resource because of a change in another resource? The previously created version of the resource would still be used from the cache
452
475
* Measure performance in BAS. Find out whether this approach results in acceptable performance.
453
476
* Test with selected (community) custom tasks
454
-
* Stale Cache Artifacts: Address scenarios where a task ceases to generate a resource that it created in a previous run. Because the old output is stored in a cached writer stage (v1), that stale file would be incorrectly included in the final build result.
0 commit comments