This project is a demonstration on how to wrap CUBA Platform's Polymer Client into the hybrid mobile application using Apache Cordova.
The video recording of the corresponding webinar is available here.
Android SDK and Node.js should be installed on your machine.
./gradlew buildCordova
npm install -g cordova
cordova create
command:
cd <project dir>/modules/polymer-client/
cordova create cordova com.example.demo Demo
Cordova cli will generate required directory structure in the cordova
directory. Skeletal web application will be
generated in the www
sub-directory. In our approach we will replace it by assembled Polymer client in a build time.
Clear www
directory
rm -rf cordova/www/*
Add www
directory to .gitignore
:
echo www/* > cordova/.gitignore
Add Android Platform to our Cordova project:
cd cordova
cordova platform add android
Add new build config to polymer.json
:
"builds": [
...
{
"name": "cordova",
"preset": "es5-bundled",
"addServiceWorker": false
}
...
]
Remove <base>
tag from index.html
. For other build targets it will be added by polymer tooling automatically
according to the basePath
config option.
Add Cordova cli as a devDependency in polymer-client/package.json
:
...
"devDependencies": {
...
"cordova": "^7.1.0"
}
...
Now it's time to tweak polymerClientModule
in our main build.gradle
:
The following task installs cordova tooling:
task installCordovaPackages(type: NpmTask) {
args = ['install']
execOverrides {
it.workingDir = 'cordova'
}
}
The following tasks copies assembled Polymer client into the cordova/www
folder:
task prepareCordova(type: Copy, dependsOn: [assemble]) {
from file('build/cordova')
into "cordova/www"
}
The following task runs cordova cli in order to build mobile app:
task buildCordova(type: NodeTask, dependsOn: [prepareCordova, installCordovaPackages]) {
script = file('node_modules/cordova/bin/cordova')
args = ['build']
workingDir 'cordova'
}
Now you should be able to build mobile app using gradle:
./gradlew buildCordova