@@ -54,6 +54,14 @@ class LibraryFormatter extends AbstractUi5Formatter {
54
54
// TODO 2.0: Make copyright mandatory and just let the error throw
55
55
log . verbose ( err . message ) ;
56
56
}
57
+
58
+ if ( project . specVersion === "1.1a" ) {
59
+ try {
60
+ project . metadata . abapUri = await this . getAbapUri ( ) ;
61
+ } catch ( err ) {
62
+ log . warn ( err . message ) ;
63
+ }
64
+ }
57
65
}
58
66
59
67
/**
@@ -394,6 +402,48 @@ class LibraryFormatter extends AbstractUi5Formatter {
394
402
} ) ;
395
403
}
396
404
405
+ async getAbapUri ( ) {
406
+ let abapUri ;
407
+ // First try manifest.json
408
+ try {
409
+ const { content : manifest } = await this . getManifest ( ) ;
410
+ if ( manifest [ "sap.platform.abap" ] && manifest [ "sap.platform.abap" ] . uri ) {
411
+ abapUri = manifest [ "sap.platform.abap" ] . uri ;
412
+ } else {
413
+ throw new Error ( `No "sap.platform.abap".uri configuration found in ` +
414
+ `manifest.json of project ${ this . _project . metadata . name } ` ) ;
415
+ }
416
+ } catch ( err ) {
417
+ log . verbose ( `Failed to read ABAP URI configuration from manifest.json for project ` +
418
+ `${ this . _project . metadata . name } : ${ err . message } ` ) ;
419
+ log . verbose ( `Falling back to .library file...` ) ;
420
+ }
421
+
422
+
423
+ // Fallback to .library
424
+ try {
425
+ const { content : dotLibrary } = await this . getDotLibrary ( ) ;
426
+ if ( dotLibrary && dotLibrary . library && dotLibrary . library . appData && dotLibrary . library . appData . manifest &&
427
+ dotLibrary . library . appData . manifest [ "sap.platform.abap" ] &&
428
+ dotLibrary . library . appData . manifest [ "sap.platform.abap" ] . uri ) {
429
+ abapUri = dotLibrary . library . appData . manifest [ "sap.platform.abap" ] . uri ;
430
+ } else {
431
+ throw new Error ( `No library.appData.manifest."sap.platform.abap".uri configuration found in ` +
432
+ `.library of project ${ this . _project . metadata . name } ` ) ;
433
+ }
434
+ } catch ( err ) {
435
+ log . verbose ( `Failed to read ABAP URI configuration from .library for project ` +
436
+ `${ this . _project . metadata . name } : ${ err . message } ` ) ;
437
+ }
438
+
439
+ if ( ! abapUri ) {
440
+ throw new Error ( `Failed to resolve ABAP URI configuration for ` +
441
+ `project ${ this . _project . metadata . name } . Check verbose log for details.` ) ;
442
+ }
443
+ log . verbose ( `ABAP URI of project ${ this . _project . metadata . name } is: ${ abapUri } ` ) ;
444
+ return abapUri ;
445
+ }
446
+
397
447
/**
398
448
* Validates the project
399
449
*
0 commit comments