I try to develop a utility project in SAP WebIDE to share useful utility classes with other developers. Let's call this a BaseProject. In my CustomProject I want to use a reference to this BaseProject and use e.g. the formatter.
Therefore I created a UI5 Application project in WebIDE called
com.company.base
and a custom project
my.custom.app
In the com.company.base project I have the following folder structure:
com.company.base
+--- webapp/
+--- formatter/
Formatter.js
Component.js
library.js
manifest.json
neo-app-json
The library.js looks like this:
sap.ui.define(["jquery.sap.global", "sap/ui/core/library"
], function(jQuery) {
"use strict";
sap.ui.getCore().initLibrary({
name: "com.company.base",
version: "1.0.0",
dependencies: ["sap.ui.core"],
types: [],
interfaces: [],
controls: [
"com.company.base.formatter.Formatter"
],
elements: []
});
return com.company.base;
}, /* bExport= */ false);
I deployed the base project to hcp as
comcompanybase
In my custom application I added the following route to the neo-app.json
{
"path": "/comcompanybase",
"target": {
"type": "application",
"name": "comcompanybase"
},
"description": "Base Project"
},
and did the registration inside of the init-Method of component.js like this:
jQuery.sap.registerModulePath("com.company.base", "/comcompanybase/webapp");
jQuery.sap.require("com.company.base.Component");
Finally, I'm able to use the formatter inside of a controller of the custom app like this:
sap.ui.define([
"my/custom/app/controller/BaseController",
"com/company/base/formatter/Formatter"
], function(BaseController, Formatter) {
"use strict";
return BaseController.extend("my.custom.app.controller.Master", {
formatter: Formatter,
onInit: function() {
//some coding
}
});
});
Every time I start the application for the first time the reference is not found. The second time everthing works.
Also I have to deploy the application to hcp after every change. Is there a way to use the lokal workspace of WebIDE for a reference? I tried to navigate upwards with ../../ but this does not worked for me.