I have a custom library com.foo.library I would like to include as a dependency of a Fiori-like app I have built.
SAP Fiori Launchpad for Developers -> Best Practices for Launchpad Apps
Declare configuration information, like the location of icons, and library dependencies in the component.js configuration file
makes sense, adding my library as a dependency would look like
dependencies: {
libs: ["sap.m", "sap.ui.layout", "com.foo.library"],
components: []
},
with Fiori you have the constraint that you must use relative paths.
eg for my dependency to work it must be found at
/resources/com/foo/library
What are the steps for uploading a custom library into the ABAP SAPUI5 Repository and having it served with a relative path?
EDIT:
Currently i have the library loaded on Component.init using
sap.ui.getCore().loadLibrary("com.foo.library", "absolute path to library");
it works, however I want to set the library as a dependency
ComponentMetadata.prototype._loadDependencies = function() {
..
if (aLibraries) {
jQuery.each(aLibraries, function(i, sLib) {
jQuery.sap.log.info("Component \"" + that.getName() +
sap.ui.getCore().loadLibrary(sLib);
});
}
from code above I can see there is no option to pass in a url when the component loads the library dependencies, so i am assuming that the library has to be found relative to the resources
In your Fiori App:
Put your dependencie into the app descriptor (manifest.json) (or if no app descriptor used into the config inside the Component.js)
dependencies: { libs: ["sap.m", "sap.ui.layout", "com.foo.library"], components: [com.foo.component] }
Let sap.ui.core know where to search for the namespace of your library.(Top of your Component.js)
jQuery.sap.registerModulePath("com.foo", "/Path/on/the/server/");
And now you can use your dependencies. And here is why:
Before a module is loaded, the longest registered prefix of its module name is searched for and the associated URL prefix is used as a prefix for the request URL. The remainder of the module name is attached to the request URL by replacing dots ('.') with slashes ('/').
The registration and search operates on full name segments only.
来源:https://stackoverflow.com/questions/28016642/adding-a-custom-library-as-a-dependency-in-sap-fiori