在开发过程中rebar自带模板建立项目,或多或少不能满足自己的开发需求。本人又是那种懒人,所以就要想办法偷懒。查看了priv模板 打造适合自己的项目模板。下面我简单的介绍整个模板的打造过程。

准备过程

 1.创建对应的template 目录

 2.ctrl+h 查看当前用户目录下是否有一个 .rebar 的文件目录 或者 shell 查看 

thinkpad@thinkpad:~$ ll -ps | grep .rebar
   4 drwxr-xr-x 10 thinkpad thinkpad    4096  6月 24 22:18 rebar/
   4 drwxrwxr-x  3 thinkpad thinkpad    4096  6月 24 22:22 .rebar/

  文中 . rebar 就是rebar 存放自定义template 文件的地方

 3 .在.reabr 文件中有一个template的文件夹,如果没有没有请创建一个

 4.进入template文件夹中创建一个 simple_game 文件夹 和一个simple_game.template的文件

 到此为止,创建rebar tempalte 的准备工作我们就做完了。

模板文功能

  1.创建一个完成的otp项目

  2.开发启动,调试脚本

  3.代码更新,编译后自动重新加载。方便调试 这也是erlang热更新的一个特性

  4.发布项目,打包镜像

制作模板文件

  1.准备模板文件 下面是我准备好的模板文件

 1 -rw-rw-r-- 1 thinkpad thinkpad  350  7月  3 12:01 app.config
 2 -rw-rw-r-- 1 thinkpad thinkpad 1120 12月  5  2013 erl.script
 3 -rw-rw-r-- 1 thinkpad thinkpad  371  7月  3 11:43 game_app.erl
 4 -rw-rw-r-- 1 thinkpad thinkpad  230  7月  3 11:41 game.app.src
 5 -rw-rw-r-- 1 thinkpad thinkpad 1564  7月  3 11:43 game.erl
 6 -rw-rw-r-- 1 thinkpad thinkpad 1439  7月  3 11:43 game_server.erl
 7 -rw-rw-r-- 1 thinkpad thinkpad  773  7月  3 11:44 game_sup.erl
 8 -rw-rw-r-- 1 thinkpad thinkpad   63 12月  5  2013 gitignore
 9 -rw-rw-r-- 1 thinkpad thinkpad  271 12月  5  2013 Makefile
10 -rw-rw-r-- 1 thinkpad thinkpad 4819 12月  5  2013 nodetool
11 -rw-rw-r-- 1 thinkpad thinkpad  249  6月 16 11:11 README.md
12 -rw-rw-r-- 1 thinkpad thinkpad  830  7月  3 11:51 rebar.config
13 -rw-rw-r-- 1 thinkpad thinkpad 4829  6月 14 18:57 reloader.erl
14 -rw-rw-r-- 1 thinkpad thinkpad 1185  6月 30 16:33 reltool.config
15 -rwxrwxr-x 1 thinkpad thinkpad 4371 12月  5  2013 runner*
16 -rwxrw-r-- 1 thinkpad thinkpad  142  7月  3 11:55 start-dev.sh*
17 -rw-rw-r-- 1 thinkpad thinkpad  431 12月  5  2013 vm.args
View Code

相关文章: