cuba-labs / polymer-cordova

4 stars 1 forks source link
cordova cuba-platform gradle polymer

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.

Requirements

Android SDK and Node.js should be installed on your machine.

Building Android Application

./gradlew buildCordova

Step-by-step Guide

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.

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