@@ -157,7 +157,9 @@ class LibraryBundle {
157157/*
158158 * Creates the library manifest.json file for a UILibrary.
159159 */
160- async function createManifest ( libraryResource , libBundle , descriptorVersion , _include3rdParty , omitMinVersions ) {
160+ async function createManifest (
161+ libraryResource , libBundle , descriptorVersion , _include3rdParty , omitMinVersions , getProjectVersion
162+ ) {
161163 // create a Library wrapper around the .library XML
162164 const library = await Library . from ( libraryResource ) ;
163165
@@ -223,13 +225,6 @@ async function createManifest(libraryResource, libBundle, descriptorVersion, _in
223225 return version && version !== "@version@" && version !== "${version}" ;
224226 }
225227
226- function getProjectVersion ( ) {
227- const project = libraryResource . _project ;
228- if ( project ) {
229- return project . version ;
230- }
231- }
232-
233228 function getLibraryTitle ( ) {
234229 if ( library . getTitle ( ) ) {
235230 return library . getTitle ( ) ;
@@ -321,7 +316,7 @@ async function createManifest(libraryResource, libBundle, descriptorVersion, _in
321316 embeds : findEmbeddedComponents ( ) ,
322317 i18n,
323318 applicationVersion : {
324- version : isValid ( library . getVersion ( ) ) ? library . getVersion ( ) : getProjectVersion ( )
319+ version : isValid ( library . getVersion ( ) ) ? library . getVersion ( ) : getProjectVersion ( library . getName ( ) )
325320 } ,
326321 title : getLibraryTitle ( ) ,
327322 description : library . getDocumentation ( ) ,
@@ -398,7 +393,7 @@ async function createManifest(libraryResource, libBundle, descriptorVersion, _in
398393 _ : "sap.ui.core"
399394 } ]
400395 } ) ;
401- return normalizeVersion ( getVersion ( dummy ) ) ;
396+ return normalizeVersion ( getProjectVersion ( dummy . getLibraryName ( ) ) ) ;
402397 }
403398
404399 function dependencies ( ) {
@@ -410,7 +405,7 @@ async function createManifest(libraryResource, libBundle, descriptorVersion, _in
410405 if ( library . getDependencies ( ) != null ) {
411406 for ( const dep of library . getDependencies ( ) ) {
412407 dependencies . libs [ dep . getLibraryName ( ) ] = {
413- minVersion : omitMinVersions ? "" : getVersion ( dep ) ,
408+ minVersion : omitMinVersions ? "" : getProjectVersion ( dep . getLibraryName ( ) ) ,
414409 lazy : dep . isLazy ( ) || undefined // suppress default (false)
415410 } ;
416411 }
@@ -619,33 +614,6 @@ async function createManifest(libraryResource, libBundle, descriptorVersion, _in
619614 return v . major + "." + v . minor ;
620615 }
621616
622- function getVersion ( dependency ) {
623- const version = dependency . getVersion ( ) ;
624- if ( version != null ) {
625- return version ;
626- }
627-
628- function hasName ( entity ) {
629- return entity . metadata && entity . metadata . name === dependency . getLibraryName ( ) ;
630- }
631-
632- const project = libraryResource . _project ;
633- if ( project ) {
634- if ( Array . isArray ( project . dependencies ) ) {
635- const lib = project . dependencies . find ( hasName ) ;
636- if ( lib ) {
637- return lib . version ;
638- }
639- }
640- if ( hasName ( project ) ) {
641- return project . version ;
642- }
643- }
644-
645- throw new Error (
646- `Couldn't find version for library '${ dependency . getLibraryName ( ) } ', project dependency missing?` ) ;
647- }
648-
649617 return {
650618 "_version" : descriptorVersion . toString ( ) ,
651619 "sap.app" : createSapApp ( ) ,
@@ -657,7 +625,7 @@ async function createManifest(libraryResource, libBundle, descriptorVersion, _in
657625 } ;
658626}
659627
660- module . exports = function ( { libraryResource, resources, options} ) {
628+ module . exports = function ( { libraryResource, resources, getProjectVersion , options} ) {
661629 // merge options with defaults
662630 options = Object . assign ( {
663631 descriptorVersion : APP_DESCRIPTOR_V22 , // TODO 3.0: change this to type string instead of a semver object
@@ -677,7 +645,7 @@ module.exports = function({libraryResource, resources, options}) {
677645 }
678646
679647 return createManifest ( libraryResource , libBundle , options . descriptorVersion , options . include3rdParty ,
680- options . omitMinVersions )
648+ options . omitMinVersions , getProjectVersion )
681649 . then ( ( manifest ) => {
682650 return new EvoResource ( {
683651 path : resourcePathPrefix + "manifest.json" ,
0 commit comments