@@ -46,6 +46,14 @@ class LibraryFormatter extends AbstractUi5Formatter {
46
46
// TODO 2.0: Make copyright mandatory and just let the error throw
47
47
log . verbose ( err . message ) ;
48
48
}
49
+
50
+ if ( project . specVersion === "1.1a" ) {
51
+ try {
52
+ project . metadata . abapUri = await this . getAbapUri ( ) ;
53
+ } catch ( err ) {
54
+ log . warn ( err . message ) ;
55
+ }
56
+ }
49
57
}
50
58
51
59
/**
@@ -306,6 +314,48 @@ class LibraryFormatter extends AbstractUi5Formatter {
306
314
} ) ;
307
315
}
308
316
317
+ async getAbapUri ( ) {
318
+ let abapUri ;
319
+ // First try manifest.json
320
+ try {
321
+ const { content : manifest } = await this . getManifest ( ) ;
322
+ if ( manifest [ "sap.platform.abap" ] && manifest [ "sap.platform.abap" ] . uri ) {
323
+ abapUri = manifest [ "sap.platform.abap" ] . uri ;
324
+ } else {
325
+ throw new Error ( `No "sap.platform.abap".uri configuration found in ` +
326
+ `manifest.json of project ${ this . _project . metadata . name } ` ) ;
327
+ }
328
+ } catch ( err ) {
329
+ log . verbose ( `Failed to read ABAP URI configuration from manifest.json for project ` +
330
+ `${ this . _project . metadata . name } : ${ err . message } ` ) ;
331
+ log . verbose ( `Falling back to .library file...` ) ;
332
+ }
333
+
334
+
335
+ // Fallback to .library
336
+ try {
337
+ const { content : dotLibrary } = await this . getDotLibrary ( ) ;
338
+ if ( dotLibrary && dotLibrary . library && dotLibrary . library . appData && dotLibrary . library . appData . manifest &&
339
+ dotLibrary . library . appData . manifest [ "sap.platform.abap" ] &&
340
+ dotLibrary . library . appData . manifest [ "sap.platform.abap" ] . uri ) {
341
+ abapUri = dotLibrary . library . appData . manifest [ "sap.platform.abap" ] . uri ;
342
+ } else {
343
+ throw new Error ( `No library.appData.manifest."sap.platform.abap".uri configuration found in ` +
344
+ `.library of project ${ this . _project . metadata . name } ` ) ;
345
+ }
346
+ } catch ( err ) {
347
+ log . verbose ( `Failed to read ABAP URI configuration from .library for project ` +
348
+ `${ this . _project . metadata . name } : ${ err . message } ` ) ;
349
+ }
350
+
351
+ if ( ! abapUri ) {
352
+ throw new Error ( `Failed to resolve ABAP URI configuration for ` +
353
+ `project ${ this . _project . metadata . name } . Check verbose log for details.` ) ;
354
+ }
355
+ log . verbose ( `ABAP URI of project ${ this . _project . metadata . name } is: ${ abapUri } ` ) ;
356
+ return abapUri ;
357
+ }
358
+
309
359
/**
310
360
* Validates the project
311
361
*
0 commit comments