复制不适用于grunt

时间:2016-01-02 09:16:08

标签: javascript gruntjs grunt-contrib-copy

Warning: undefined is not a function Use --force to continue.

我正在学习咕噜声,我在复制时面临着下面的问题。 public class MyAyncTask extends AsyncTask<String,Void,InputStream>{ @Override protected InputStream doInBackground(String... parameters) { String name=""+etname.getText().toString(); String age=""+etage.getText().toString(); String email=""+etemail.getText().toString(); List<Pair<String, String>> params = new ArrayList<>(); params.add(new Pair<>("name", name)); params.add(new Pair<>("age", age)); params.add(new Pair<>("email", email)); try { URL url = new URL(parameters[0]); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setDoInput(true); conn.setDoOutput(true); urlConnection.connect(); InputStream in = new BufferedInputStream(urlConnection.getInputStream()); in=urlConnection.getInputStream(); } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return null; } @Override protected void onPostExecute(InputStream inputStream) { // You will get inputStream respose here . Use it to manipulate your UI. } 和文件没有从src复制到目的地

2 个答案:

答案 0 :(得分:0)

这不是解决问题的方法。但对于复制或删除等内容,我总是直接使用cli-commands:https://github.com/sindresorhus/grunt-shell

答案 1 :(得分:0)

grunt-contrib-copy是一项多目标任务,这意味着您必须提供一个名称&#34; (称为目标)到每个配置 - 这样您就可以定义和调用多个复制操作(参见http://gruntjs.com/configuring-tasks#task-configuration-and-targets)。

通过在&#34; copy&#34;之间插入名称来实现这一点。及其参数。下面是我调用目标&#34; main&#34;:

的示例
module.exports = function(grunt) {
  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    copy: {
      main: {
        files: [
          {expand: true,cwd:"js/" ,src: ['libs/*'], dest: '../test/js/libs/'},
          {expand: true,cwd:"js/" , src: ['models/*'], dest: '../test/js/models/'}
        ]
      }
    }
  });
  grunt.loadNpmTasks('grunt-contrib-copy');
  grunt.registerTask("testcopy",["copy:main"] );
};