科尔多瓦/ PhoneGap的插件开发流程为Android [英] Cordova/PhoneGap Plugin Development Workflow for Android

查看:314
本文介绍了科尔多瓦/ PhoneGap的插件开发流程为Android的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开发了一套科尔多瓦插件。最初的实现将只机器人,所以现在我很感兴趣,能够使用ADT在Eclipse的插件开发。我读过了的文件,并能够得到完成了第一个插件,但工作流程是一个有点疼痛。我找不到科尔多瓦任何文档或工具,专门支持插件的开发工作流程。我不知道如果我使其更难比它需要?下面是我在做什么。

I am developing a set of Cordova plugins. The initial implementation will be Android only, so for now I am interested in being able to use ADT in Eclipse for plugin development. I've read over the documentation and have been able to get the first plugin completed, but the workflow is a bit of a pain. I couldn't find any docs or tools in Cordova that specifically support plugin development workflow. I wonder if I am making it harder than it needs to be? Here is what I am doing.

插件设置根据科尔多瓦插件规范。我开始通过设置目录结构和编辑崇高的文件,所以我有这样的:

The plugin is set up according to the cordova plugin spec. I started by setting up the directory structure and editing the files in Sublime, so I have something like:

  • $ PLUGIN_ROOT
    • 在SRC
      • 安卓
        • Plugin.java
        • $PLUGIN_ROOT
          • src
            • android
              • Plugin.java
              • plugin.js

              我把所有这一切与样板和初步实施。 然后开始测试,我创建了一个科尔多瓦项目,增加了android平台,加入我的插件和内置:

              I set all of that up with boilerplate and an initial implementation. Then to start testing, I created a cordova project, added the android platform, added my plugin and built:

              cordova create testProject
              cd testProject
              cordova platform add android
              cordova plugin add $PLUGIN_ROOT
              cordova build
              cordova run
              

              做的一切后,我导入TestProject的/平台/成的android ADT并开始编辑Plugin.java和plugin.js,以及资产/ WWW增加一个测试工具。

              After doing all that, I import testProject/platforms/android into ADT and start editing Plugin.java and plugin.js, as well as assets/www to add a test harness.

              现在,让一切工作,我希望它以后的路,我必须手动复制所有修改过的文件(加上我已经添加的所有文件)的回在$ PLUGIN_ROOT的适当位置。我也想preserve我的测试工具,大概在$ PLUGIN_ROOT /测试。这已经不是第一次太糟糕了,但反复几次后,这一切都变得有点笨拙。它似乎也很容易出错的手工做,但我真的不能使用合并工具来做到这一点对我来说,因为该目录结构是不同的。我可以写一个剧本,但我会增加更多的维护开销。话虽这么说,我目前正在计划编写脚本来做到这一点的每一个,我会写的插件。

              Now, after getting everything working the way I want it to, I have to manually copy all of the changed files (plus any files I've added) back into the appropriate place under $PLUGIN_ROOT. I also want to preserve my test harness, probably in $PLUGIN_ROOT/test. This isn't too bad the first time, but after several iterations it's all getting a little unwieldy. It also seems very error-prone to do it manually, but I can't really use a merge tool to do it for me, because the directory structure is different. I could write a script, but then I'll be adding more maintenance overhead. That being said, I'm currently planning on writing scripts to do this for each of the plugins that I am going to write.

              有没有更好的办法?我真的很想听到科尔多瓦插件开发人员如何管理这一点。谢谢你。

              Is there a better way? I'd really like to hear how the cordova plugin developers manage this. Thanks.

              推荐答案

              您需要一个自动构建工具,如咕噜的< A HREF =htt​​ps://github.com/gruntjs/grunt-contrib-watch相对=nofollow>显示器你的插件文件夹(如$ PLUGIN_ROOT)和的运行适当科尔多瓦的命令,只要属于插件更改的文件。

              You need an automated build tool like grunt that monitors your plugin folder (e.g. $PLUGIN_ROOT) and runs the appropriate cordova commands whenever a file belonging to the plugin changes.

              这篇关于科尔多瓦/ PhoneGap的插件开发流程为Android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆