Skip to content

Latest commit

 

History

History
118 lines (76 loc) · 3.85 KB

README.md

File metadata and controls

118 lines (76 loc) · 3.85 KB

grunt-phonegap

Local build tasks for Phonegap applications

grunt-phonegap integrates Phonegap development with Grunt-based workflows by wrapping the Phonegap 3.0 command line interface.

Rather than polluting the top-level of your project, grunt-phonegap copies your files into a subdirectory containing the Phonegap project, which gets regenerated every build.

Getting Started

This plugin requires Grunt ~0.4.1

If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:

npm install grunt-phonegap --save-dev

Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:

grunt.loadNpmTasks('grunt-phonegap');

Overview

In your project's Gruntfile, add a section named phonegap to the data object passed into grunt.initConfig().

Point phonegap.config.root to the output of your other build steps. At the very least, it should contain your config.xml and index.html files.

phonegap.config.cordova should be the .cordova directory that is generated by phonegap create. It must contain a config.json file or your app cannot be built.

Options

grunt.initConfig({
  phonegap: {
    config: {
      root: 'www',
      config: 'www/config.xml',
      cordova: '.cordova',
      path: 'phonegap',
      plugins: ['/local/path/to/plugin', 'http://example.com/path/to/plugin.git'],
      platforms: ['android'],
      verbose: false
    }
  }
})

Tasks

phonegap:build

Running phonegap:build with no arguments will...

  • Purge your phonegap.config.path
  • Copy your phonegap.config.cordova and phonegap.config.root files into it
  • Add any plugins listed in phonegap.config.plugins
  • ..and then generate a Phonegap build for all platforms listed in phonegap.config.platforms

phonegap:run[:platform][:device]

After a build is complete, the phonegap:run grunt task can be used to launch your app on an emulator or hardware device. It accepts two optional arguments, platform and device.

Example: grunt phonegap:run:android:emulator

If you are using the Android platform, you can see the list of connected devices by running adb devices.

The platform argument will default to the first platform listed in phonegap.config.platforms.

The device argument will default to "device", the default name for the first Android device connected to your machine.

What's next

  • Creating signed releases (phonegap:release)

Running the test suite

git clone https://github.com/logankoester/grunt-phonegap.git
cd grunt-phonegap
npm install
git submodule update
grunt

Contributing

Fork the repo on Github and open a pull request. Note that the files in tasks/ and test/ are the output of CoffeeScript files in src/, and will be overwritten if edited by hand.

Before running the included test suite, you must first run git submodule update on your local clone (see above).

Release History

0.3.0

  • Fixes issue #2 "Test not completing" (thanks @skarjalainen and @jrvidal)
  • Removed default 'device' flag (thanks @robwalch)

0.2.0

  • Adds 'config' option for specifying a custom path to 'config.xml'.

0.1.0

  • Initial release

License

Copyright (c) 2013 Logan Koester. Released under the MIT license. See LICENSE-MIT for details.

Bitdeli Badge