8

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

David Dhuyveter
  • 1,416
  • 9
  • 17
  • 1
    With "it can't be done?" I'm still looking for guidance on this question. – David Dhuyveter Mar 14 '14 at 13:22
  • 1
    Ok. This is not on the radar of the development team right now as far as I know. If you have actual customers who request this, then this will help by opening an RFE, otherwise I don't see it happening any time soon (a tool or a blog post at the least, but you seem to have exeprience with that by now? maybe you should write one. :) – Idan Adar Mar 14 '14 at 13:25
  • @IdanAdar Is this issue still the same with WL 7.0, I couldn't find any guide about importing existing cordova plugins (in my case cordova-googlemaps-plugin) – JuniorDev May 08 '15 at 13:38
  • Correct, no change in 7.0. – Idan Adar May 08 '15 at 13:39

2 Answers2

0

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.

Idan Adar
  • 44,156
  • 13
  • 50
  • 89
-1

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

nijin
  • 556
  • 2
  • 16