如何使用grunt-cordova-cli在发布模式下构建应用程序?

时间:2016-09-01 10:11:51

标签: javascript android cordova gruntjs

现在我正在使用cordova开发一个webview应用程序,在我的项目中,我想用 grunt-cordova-cli 运行cordova命令来执行一些自动任务,这是我的Gruntfile.js:< / p>

module.exports = function (grunt) {

grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    clean: {
        build: ['./platforms/*/build'],
    },
    cordova_cli: {
        options: {
            projectRoot: 'app',
            cmd: 'build',
            platforms: ['ios', 'android'],
            release:true
        },
        build_ios: {
            cmd: 'build',
            platforms: ['ios']
        },
        build_android: {
            cmd: 'build',
            options:['release'],
            platforms: ['android']
        }
    }
});

grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-cordova-cli');
grunt.registerTask('cordova', ['cordova_cli']);

grunt.registerTask('test', function(){
    grunt.file.setBase('./');
    grunt.task.run([ 'clean:build','cordova_cli:build_android']);
});}

当我在命令行中运行grunt test时,grunt工作正常,但似乎cordova build android命令在调试模式下工作,因为我看到了由android-debug.apk创建的cordova build文件在构建目录中{{1}}。我的问题是如何使用grunt-cordova-cli在发布模式下构建我的Android应用程序?

0 个答案:

没有答案