1- const ProjectResource = require ( "@ui5/fs" ) . ProjectResource ;
2-
31/**
42 * Convenience functions for UI5 Builder tasks.
53 * An instance of this class is passed to every standard UI5 Builder task that requires it.
@@ -37,11 +35,20 @@ class TaskUtil {
3735 constructor ( { projectBuildContext} ) {
3836 this . _projectBuildContext = projectBuildContext ;
3937
38+ this . GLOBAL_TAGS = Object . freeze ( {
39+ IsDebugVariant : "ui5:IsDebugVariant" ,
40+ HasDebugVariant : "ui5:HasDebugVariant"
41+ } ) ;
42+
4043 /**
4144 * @member {module:@ui5/builder.tasks.TaskUtil~StandardBuildTags }
4245 * @public
4346 */
44- this . STANDARD_TAGS = this . _projectBuildContext . STANDARD_TAGS ;
47+ this . STANDARD_TAGS = Object . freeze ( {
48+ OmitFromBuildResult : "ui5:OmitFromBuildResult" ,
49+ IsBundle : "ui5:IsBundle" ,
50+ ...this . GLOBAL_TAGS
51+ } ) ;
4552 }
4653
4754 /**
@@ -53,26 +60,20 @@ class TaskUtil {
5360 * This method is only available to custom task extensions defining
5461 * <b>Specification Version 2.2 and above</b>.
5562 *
56- * @param {module:@ui5/fs.ProjectResource } resource Resource-instance the tag should be stored for
63+ * @param {module:@ui5/fs.Resource } resource Resource-instance the tag should be stored for
5764 * @param {string } tag Name of the tag.
5865 * Currently only the [STANDARD_TAGS]{@link module:@ui5/builder.tasks.TaskUtil#STANDARD_TAGS} are allowed
5966 * @param {string|boolean|integer } [value=true] Tag value. Must be primitive
6067 * @public
6168 */
6269 setTag ( resource , tag , value ) {
6370 if ( typeof resource === "string" ) {
64- throw new Error ( "TODO 3.0: Deprecated" ) ;
65- }
66- if ( ! ( resource instanceof ProjectResource ) ) {
67- throw new Error ( "Resource must be an instance of ProjectResource" ) ;
71+ throw new Error ( "Deprecated parameter: " +
72+ "Since UI5 Tooling 3.0, setTag requires a resource instance. Strings are no longer accepted" ) ;
6873 }
69- const project = resource . getProject ( ) ;
70- if ( project !== this . _projectBuildContext . getProject ( ) ) {
71- throw new Error (
72- `Unable to set tag for project ${ project . getName ( ) } ` +
73- `while building project ${ this . _projectBuildContext . getProject ( ) . getName ( ) } ` ) ;
74- }
75- return project . setTag ( resource . getPath ( ) , tag , value ) ;
74+
75+ const collection = this . _projectBuildContext . getResourceTagCollection ( resource , tag ) ;
76+ return collection . setTag ( resource . getPath ( ) , tag , value ) ;
7677 }
7778
7879 /**
@@ -82,20 +83,19 @@ class TaskUtil {
8283 * This method is only available to custom task extensions defining
8384 * <b>Specification Version 2.2 and above</b>.
8485 *
85- * @param {module:@ui5/fs.ProjectResource } resource Resource-instance the tag should be retrieved for
86+ * @param {module:@ui5/fs.Resource } resource Resource-instance the tag should be retrieved for
8687 * @param {string } tag Name of the tag
8788 * @returns {string|boolean|integer|undefined } Tag value for the given resource.
8889 * <code>undefined</code> if no value is available
8990 * @public
9091 */
9192 getTag ( resource , tag ) {
9293 if ( typeof resource === "string" ) {
93- throw new Error ( "TODO 3.0: Deprecated" ) ;
94- }
95- if ( ! ( resource instanceof ProjectResource ) ) {
96- throw new Error ( "Resource must be an instance of ProjectResource" ) ;
94+ throw new Error ( "Deprecated parameter: " +
95+ "Since UI5 Tooling 3.0, getTag requires a resource instance. Strings are no longer accepted" ) ;
9796 }
98- return resource . getProject ( ) . getTag ( resource . getPath ( ) , tag ) ;
97+ const collection = this . _projectBuildContext . getResourceTagCollection ( resource , tag ) ;
98+ return collection . getTag ( resource . getPath ( ) , tag ) ;
9999 }
100100
101101 /**
@@ -106,18 +106,17 @@ class TaskUtil {
106106 * This method is only available to custom task extensions defining
107107 * <b>Specification Version 2.2 and above</b>.
108108 *
109- * @param {module:@ui5/fs.ProjectResource } resource Resource-instance the tag should be cleared for
109+ * @param {module:@ui5/fs.Resource } resource Resource-instance the tag should be cleared for
110110 * @param {string } tag Tag
111111 * @public
112112 */
113113 clearTag ( resource , tag ) {
114114 if ( typeof resource === "string" ) {
115- throw new Error ( "TODO 3.0: Deprecated" ) ;
115+ throw new Error ( "Deprecated parameter: " +
116+ "Since UI5 Tooling 3.0, clearTag requires a resource instance. Strings are no longer accepted" ) ;
116117 }
117- if ( ! ( resource instanceof ProjectResource ) ) {
118- throw new Error ( "Resource must be an instance of ProjectResource" ) ;
119- }
120- return resource . getProject ( ) . clearTag ( resource . getPath ( ) , tag ) ;
118+ const collection = this . _projectBuildContext . getResourceTagCollection ( resource , tag ) ;
119+ return collection . clearTag ( resource . getPath ( ) , tag ) ;
121120 }
122121
123122 /**
@@ -174,6 +173,18 @@ class TaskUtil {
174173 return this . _projectBuildContext . getProject ( projectName ) ;
175174 }
176175
176+ createResource ( parameters ) {
177+ if ( ! parameters . project ) {
178+ parameters . project = this . getProject ( ) ;
179+ }
180+ const Resource = require ( "@ui5/fs" ) . Resource ;
181+ return new Resource ( parameters ) ;
182+ }
183+
184+ getCreateResourceFn ( ) {
185+ return this . createResource . bind ( this ) ;
186+ }
187+
177188 /**
178189 * Get an interface to an instance of this class that only provides those functions
179190 * that are supported by the given custom task extension specification version.
0 commit comments