1. Create a project folder:
mkdir MYAPPCD MyApp
2. Download the rebar binary file to the folder of this project.
git clone https://github.com/basho/rebar.git;
3. Use the rebar template system to build the "skeleton" of our project.
Rebar Creat-app Appid=myapp
After this command executes, a subfolder "src" is generated in the project file, which contains three files:
Resource files for MYAPP.APP.SRC:OTP applications
Myapp_app.erl: Application behaviour for an OTP application
Myapp_sup.erl: Supervisor behaviour for an OTP application
4. Compiling the project
Rebar Compile
After execution, a Ebin folder will be generated, and the beam file corresponding to the source file under the SRC folder will be produced under Ebin. At the same time, rebar will dynamically generate a suitable OTP project resource file based on the MYAPP.APP.SRC.
In addition, rebar clean can clear the compiled beam file
5. Add Common dependencies
In the project directory (in the same directory as the SRC folder), create a new Rebar.config file with the following file contents:
{erl_opts, [Debug_info,{parse_transform, Lager_transform}]}. {Deps, [ {lager_amqp_backend, '. * ', {git, ' https://github.com/jbrisbin/lager_amqp_backend.git ', ' Master '}}, {amqp_client, ". *", {git, "https://github.com/jbrisbin/amqp_client.git", {tag, "rabbitmq_2.7.0"}}}, { Ranch, ". *", {git, "https://github.com/ninenines/ranch.git", {tag, "1.1.0"}}},{protobuffs, ". *", "{git," git:// Github.com/basho/erlang_protobuffs.git ", Master}}]}.
After running, rebar get-deps can generate the Deps folder and complete the basic creation.
PS: Purely individual study notes, if there is insufficient please point out, thank you!
Building an Erlang project through rebar