csantanapr / grunt-cordovacli

Wraps web app with Cordova CLI using GruntJS
Apache License 2.0
60 stars 31 forks source link

config.xml #25

Closed dwploc closed 9 years ago

dwploc commented 9 years ago

When building the --release apk, the grunt command does not use the config.xml in the root of the project directory. If I directly access "cordova build android --release" it works fine.

Relevant sections:

cordovacli: {
    options: {
        path: '<%= yeoman.root %>', //'myHybridAppFolder',
        cli: 'cordova'  // cca or cordova
    },
    cordova: {
        options: {
            command: ['create','platform','plugin','build'],
            platforms: ['ios','android'],
            plugins: ['device','dialogs'],
            path: '<%= yeoman.root %>', //'myHybridAppFolder',
            id: 'org.livingwordumc',
            name: 'livingwordumc'
        }

    build_android_release: {
        options: {
            command: 'build',
            platforms: ['android'],
            args: ['--release']
        }
    },

xmlpoke: {
  updateAnAttribute: {
    options: {
      replacements: [ {
        xpath: '/widget/@version',
        value: '<%= pkg.version %>'            
      },
      {
        xpath: '/widget/@android-versionCode',
        value: function (node) {
          var v = node.value*1;
          v = v+1;
          return v.toString(); 
        }
      }]
    },
    files: {
      'config.xml' : 'config.xml'
    },
  }
} 

grunt.registerTask('postbuild', function(){ grunt.file.copy('/home/dwploc/lwapp/platforms/android/ant-build/lwmobile-release.apk', '/home/dwploc/Downloads/lwmobile-release.apk'); grunt.log.write('APK saved in Downloads'); grunt.task.run('notify:mobile');

});

grunt.registerTask('buildmobile', function(){ grunt.task.run(['xmlpoke','cordovacli:build_android_release', 'postbuild']); });

Running "cordovacli:build_android_release" (cordovacli) task Verifying property cordovacli.build_android_release exists in config...OK File: [no files] Options: path="./", name="HelloCordova", id="io.cordova.hellocordova", args=["--release"], cli="cordova", command="build", platforms=["android"] Using cordova CLI version (3.4.1-0.1.0) Setting Current Working Directory (CWD) to ./ Running:/home/dwploc/lwapp/node_modules/cordova/bin/cordova build android --release Running command: /home/dwploc/lwapp/platforms/android/cordova/build --release Buildfile: /home/dwploc/lwapp/platforms/android/build.xml

shahu-nc commented 9 years ago

Had a similar problem

csantanapr commented 9 years ago

Can't reproduce, you are using a very old version of cordova cli 3.4.1, try upgrading to 5.1.1

I try to reproduce with both 5.1.1 and 3.4.1-0.1.0 I try to reproduce specifying a directory and using ./ Do you have your Gruntfile in the same directory of config.xml ? Are you running grunt command from the same directory of config.xml of a directory inside platforms?

Here is the output when I try it, if I use 3.4.1, default android at that time frame uses ant, if you use 5.1.1 default android platform (i.e. 4.x) uses gradle.

With Both I don't see any errors. What errors do you see?

Here is my output http://pastebin.com/qZE5XdmA