@@ -16,13 +16,14 @@ class TaskRunner {
1616 * @param {object } parameters.graph
1717 * @param {object } parameters.project
1818 * @param {@ui5/logger/loggers/ProjectBuild } parameters.log Logger to use
19+ * @param {@ui5/project/build/cache/ProjectBuildCache } parameters.buildCache Build cache instance
1920 * @param {@ui5/project/build/helpers/TaskUtil } parameters.taskUtil TaskUtil instance
2021 * @param {@ui5/builder/tasks/taskRepository } parameters.taskRepository Task repository
2122 * @param {@ui5/project/build/ProjectBuilder~BuildConfiguration } parameters.buildConfig
2223 * Build configuration
2324 */
24- constructor ( { graph, project, log, cache , taskUtil, taskRepository, buildConfig} ) {
25- if ( ! graph || ! project || ! log || ! cache || ! taskUtil || ! taskRepository || ! buildConfig ) {
25+ constructor ( { graph, project, log, buildCache , taskUtil, taskRepository, buildConfig} ) {
26+ if ( ! graph || ! project || ! log || ! buildCache || ! taskUtil || ! taskRepository || ! buildConfig ) {
2627 throw new Error ( "TaskRunner: One or more mandatory parameters not provided" ) ;
2728 }
2829 this . _project = project ;
@@ -31,7 +32,7 @@ class TaskRunner {
3132 this . _taskRepository = taskRepository ;
3233 this . _buildConfig = buildConfig ;
3334 this . _log = log ;
34- this . _cache = cache ;
35+ this . _buildCache = buildCache ;
3536
3637 this . _directDependencies = new Set ( this . _taskUtil . getDependencies ( ) ) ;
3738 }
@@ -192,38 +193,35 @@ class TaskRunner {
192193 options . projectNamespace = this . _project . getNamespace ( ) ;
193194
194195 // TODO: Apply cache and stage handling for custom tasks as well
195- this . _project . useStage ( taskName ) ;
196-
197- // Check whether any of the relevant resources have changed
198- if ( this . _cache . hasCacheForTask ( taskName ) ) {
199- await this . _cache . validateChangedProjectResources (
200- taskName , this . _project . getReader ( ) , this . _allDependenciesReader ) ;
201- if ( this . _cache . hasValidCacheForTask ( taskName ) ) {
202- this . _log . skipTask ( taskName ) ;
203- return ;
204- }
196+ const requiresRun = await this . _buildCache . prepareTaskExecution ( taskName , this . _allDependenciesReader ) ;
197+ if ( ! requiresRun ) {
198+ this . _log . skipTask ( taskName ) ;
199+ return ;
205200 }
201+
202+ const expectedOutput = new Set ( ) ; // TODO: Determine expected output properly
203+
206204 this . _log . info (
207205 `Executing task ${ taskName } for project ${ this . _project . getName ( ) } ` ) ;
208206 const workspace = createTracker ( this . _project . getWorkspace ( ) ) ;
209207 const params = {
210208 workspace,
211209 taskUtil : this . _taskUtil ,
212- options,
213- buildCache : {
210+ cacheUtil : {
214211 // TODO: Create a proper interface for this
215212 hasCache : ( ) => {
216- return this . _cache . hasCacheForTask ( taskName ) ;
213+ return this . _buildCache . hasTaskCache ( taskName ) ;
217214 } ,
218215 getChangedProjectResourcePaths : ( ) => {
219- return this . _cache . getChangedProjectResourcePaths ( taskName ) ;
216+ return this . _buildCache . getChangedProjectResourcePaths ( taskName ) ;
220217 } ,
221218 getChangedDependencyResourcePaths : ( ) => {
222- return this . _cache . getChangedDependencyResourcePaths ( taskName ) ;
219+ return this . _buildCache . getChangedDependencyResourcePaths ( taskName ) ;
223220 } ,
224- }
221+ } ,
222+ options,
225223 } ;
226- // const invalidatedResources = this._cache .getDepsOfInvalidatedResourcesForTask(taskName);
224+ // const invalidatedResources = this._buildCache .getDepsOfInvalidatedResourcesForTask(taskName);
227225 // if (invalidatedResources) {
228226 // params.invalidatedResources = invalidatedResources;
229227 // }
@@ -246,7 +244,7 @@ class TaskRunner {
246244 `Task ${ taskName } finished in ${ Math . round ( ( performance . now ( ) - this . _taskStart ) ) } ms` ) ;
247245 }
248246 this . _log . endTask ( taskName ) ;
249- await this . _cache . updateTaskResult ( taskName , workspace , dependencies ) ;
247+ await this . _buildCache . recordTaskResult ( taskName , expectedOutput , workspace , dependencies ) ;
250248 } ;
251249 }
252250 this . _tasks [ taskName ] = {
@@ -319,6 +317,8 @@ class TaskRunner {
319317
320318 // Tasks can provide an optional callback to tell build process which dependencies they require
321319 const requiredDependenciesCallback = await task . getRequiredDependenciesCallback ( ) ;
320+ const getBuildSignatureCallback = await task . getBuildSignatureCallback ( ) ;
321+ const getExpectedOutputCallback = await task . getExpectedOutputCallback ( ) ;
322322 const specVersion = task . getSpecVersion ( ) ;
323323 let requiredDependencies ;
324324
@@ -390,6 +390,8 @@ class TaskRunner {
390390 taskName : newTaskName ,
391391 taskConfiguration : taskDef . configuration ,
392392 provideDependenciesReader,
393+ getBuildSignatureCallback,
394+ getExpectedOutputCallback,
393395 getDependenciesReader : ( ) => {
394396 // Create the dependencies reader on-demand
395397 return this . _createDependenciesReader ( requiredDependencies ) ;
@@ -488,7 +490,7 @@ class TaskRunner {
488490 * @returns {Promise } Resolves when task has finished
489491 */
490492 async _executeTask ( taskName , taskFunction , taskParams ) {
491- if ( this . _cache . hasValidCacheForTask ( taskName ) ) {
493+ if ( this . _buildCache . isTaskCacheValid ( taskName ) ) {
492494 // Immediately skip task if cache is valid
493495 // Continue if cache is (potentially) invalid, in which case taskFunction will
494496 // validate the cache thoroughly
0 commit comments