问题
Worklight 6.1 uses Cordova 3.1. The documentation shows how to author your own Cordova plugin but I can't find any information on how to install existing Cordova 3 style plugins into a Worklight project.
I tried installing the JavaScript and native components, and editing config.xml similar to what I did with Worklight 6.0, and that works in some cases.
But I find that Cordova 3 style plugins are typically authored with the Cordova plugin management utility in mind and can't necessarily be just added to a project as is.
The particular problem I hit was with the use of require() (expecting cordova.require()) in plugin code added to a dojo project. require() was resolving to AMD require() which promptly failed to load "cordova/exec"
When the Cordova plugin management tools are used to add the plugin to a Cordova project, they automatically wrap the plugin's javascript in a cordova.define() function that passes require() (and some other functions) as a parameter. So the standard for Cordova 3 plugins is to use require() without qualification.
I know I can resolve this issue manually each time I use a third party plugin, but was wondering if there were any guides, or tools, or practices around adding existing Cordova 3 style plugins into a Worklight project
回答1:
Unfortunately at this time there are no guides, practices or tools for what you are asking in Worklight 6.1.0. But perhaps something should be written about it at the very least.
回答2:
In WL6.1 there are steps to create and add application components (see IBM WL6.1 Application Components)
The above docs suggest ways to add additional hooks including Cordova Plugins
来源:https://stackoverflow.com/questions/21003350/is-there-a-tool-to-install-an-existing-cordova-3-plugin-into-a-worklight-6-1-app