Compiling and building a project with rebar
2012-05-08 15:21
295 查看
转载:http://wiki.erlang-web.org/Rebar
To do so be sure to have all dependencies, erlang (base or hype) erlang-inets, yaws and the erlang tools, on most packaged distributions they are usually a set of different packages. Most of compiling errors are because of missing erlang
packages.
You should run that command every time you change something in your project.
In reltool.config.sample it is assumed that you store all your dependencies in deps directory, if it's name is different you will have to change appropriet paths
Erlang Web framework supports now the two main servers implemented in Erlang: INETS and Yaws. By default it uses inets. To change that switch inets to yaws in reltool.config.
And an app tuple
It will build the project in rel directory. Option force=1 makes rebar ignore the fact that the @rel@ directory exists, and lets you upgrade your project.
creates the mandatory directories for the Erlang Web framework, including:
bin
config
docroot
lib
log
pipes
releases
templates
copies the binary executables:
heart
run_erl
to_erl
erts directory
copy start scripts for both: interactive and embedded mode
creates start_erl.data configuration file
prepare sample framework configuration files (or copy project specific ones):
dispatch.conf
errors.conf
project.conf
builds simple welcome, 404 and 501 error pages
copies the required autocomplete wpart files
creates .rel and sys.config files
generates boot file
It puts a template structure for the new application in apps directory
Warning: Rebar looks for template add through all of project dependencies, and returns an error, bacause it doesn't find it. To solve it comment deps and sub_dirs sections
in rebar.config
or
Getting Erlang Web
Before you start, you have to prepare the project directory, and get Erlang Web framework as a dependency.
1. Add a dependency to Erlang Web in rebar.config file in your project directory.
{lib_dirs,["deps"]}. {deps, [ {'erlang-web', ".*", {git, "git://github.com/esl/erlang-web.git", "rebar"}} ]}.
2. Get project dependencies
./rebar get-deps
Compiling
Before you will be ready to use the framework for the first time, you should compile it.To do so be sure to have all dependencies, erlang (base or hype) erlang-inets, yaws and the erlang tools, on most packaged distributions they are usually a set of different packages. Most of compiling errors are because of missing erlang
packages.
1. Add all additional applications to the section sub_dirs in rebar.config file
{sub_dirs,[ "apps/myapp" ]}.
2. Compile the project
./rebar compile
You should run that command every time you change something in your project.
Building
1. Copy the reltool.config.sample script from erlang-web directory in deps to the main directory as reltool.config
In reltool.config.sample it is assumed that you store all your dependencies in deps directory, if it's name is different you will have to change appropriet pathsErlang Web framework supports now the two main servers implemented in Erlang: INETS and Yaws. By default it uses inets. To change that switch inets to yaws in reltool.config.
2. Add project specific applications to the rel tuple in reltool.config file
{sys, [ {lib_dirs, ["apps", "deps", "deps/erlang-web/apps" ]}, {rel, "trace-this", "1.0", [ %% Required applications ... %% Project specific applications myapp ]},
And an app tuple
{app, myapp, [{incl_cond, include}]}
3. Add copy directive to move project specific configuration files (like dispatch.conf) and templates
{copy, "apps/myapp/priv/config"}, {copy, "apps/myapp/priv/docroot"}, {copy, "apps/myapp/priv/templates"}
4. Run the following command every time you want to upgrade your project
./rebar generate force=1
It will build the project in rel directory. Option force=1 makes rebar ignore the fact that the @rel@ directory exists, and lets you upgrade your project.
Results
Rebar prepares the structure of rel directory, that is your project built direcotory:creates the mandatory directories for the Erlang Web framework, including:
bin
config
docroot
lib
log
pipes
releases
templates
copies the binary executables:
heart
run_erl
to_erl
erts directory
copy start scripts for both: interactive and embedded mode
creates start_erl.data configuration file
prepare sample framework configuration files (or copy project specific ones):
dispatch.conf
errors.conf
project.conf
builds simple welcome, 404 and 501 error pages
copies the required autocomplete wpart files
creates .rel and sys.config files
generates boot file
Creating skeleton for a new application in the project
1. Copy '''templates''' directory from Erlang Web to maint project directory
cp -r deps/erlang-web/templates ./
2. Run
./rebar create template=add [app_name=newapp] [app_vsn=0.1]
It puts a template structure for the new application in apps directory
Warning: Rebar looks for template add through all of project dependencies, and returns an error, bacause it doesn't find it. To solve it comment deps and sub_dirs sections
in rebar.config
Running the project
To start the server run in rel directory:bin/start
or
bin/start_interactive
相关文章推荐
- MinGW - Compiling and Building with MinGW
- Android for MSM Project,Downloading and Building from Source
- 使用Maven构建Java工程(Building Java Projects with Maven)
- Building Xcode iOS projects and creating *.ipa file from the command line
- Using Swift with Cocoa and Objective-C--在同个project中使用Swift和在同个project中
- Building Applications with Force.com and VisualForce (DEV401) 中用到的Recruiting Application介绍
- Eclipse or IDE integrated with Eclipse .project and .classpath files
- Building Applications with Force.com and VisualForce(Dev401)( 八):Designing Applications for Multiple users:Managing your users' experience II
- Building Applications with Force.com and VisualForce (DEV401) (二三):Visualforce Componets (Tags) Library Part III
- Building Faster APIs with NodeJs and Redis
- 用Python和OpenCV创建一个图片搜索引擎的完整指南 The complete guide to building an image search engine with Python and
- Deploy .Net project automatically with MsBuild and MsDeploy (0)
- GCC and Make Compiling, Linking and Building C/C++ Applications
- 使用Maven构建Java工程(Building Java Projects with Maven)
- Building a Basic .NET Remoting Application 之四 Compiling and Running the Basic Application
- Building and Installing ACE on Windows with Microsoft Visual C++
- Building real time app with Socket.io and Node.js
- Android Studio(六)Building Your Project with Gradle
- Building Applications with Force.com and VisualForce (DEV401) (二四):JavaScript in Visualforce
- Search Engine Optimization -Building Traffic and Making Money with SEO