Convert Figma logo to code with AI

erlang logorebar3

Erlang build tool that makes it easy to compile and test Erlang applications and releases.

1,689
515
1,689
196

Top Related Projects

11,341

Erlang/OTP

24,386

Elixir is a dynamic, functional language for building scalable and maintainable applications

7,256

Small, fast, modern HTTP server for Erlang/OTP.

13,968

The most scalable open-source MQTT broker for IoT, IIoT, and connected vehicles

Robust, Ubiquitous and Massively Scalable Messaging Platform (XMPP, MQTT, SIP Server)

Quick Overview

Rebar3 is the official build tool for Erlang projects. It automates compiling, testing, dependency management, and release packaging for Erlang applications. Rebar3 aims to simplify the development process and improve project consistency across the Erlang ecosystem.

Pros

  • Comprehensive build and dependency management tool specifically designed for Erlang
  • Integrates well with OTP (Open Telecom Platform) principles and structures
  • Supports multiple package repositories, including Hex.pm
  • Provides a plugin system for extending functionality

Cons

  • Learning curve for developers new to Erlang or coming from other build systems
  • Some legacy projects may require migration effort to fully utilize Rebar3
  • Limited support for non-Erlang dependencies or mixed-language projects

Code Examples

  1. Creating a new Erlang application:
$ rebar3 new app myapp

This command creates a new Erlang application structure with the name "myapp".

  1. Compiling an Erlang project:
$ rebar3 compile

This command compiles all Erlang source files in the project.

  1. Running tests:
$ rebar3 eunit

This command runs EUnit tests for the project.

  1. Creating a release:
$ rebar3 release

This command creates a release package for the Erlang application.

Getting Started

To get started with Rebar3:

  1. Install Erlang/OTP (version 18 or later)
  2. Install Rebar3:
    $ wget https://s3.amazonaws.com/rebar3/rebar3 && chmod +x rebar3
    $ ./rebar3 local install
    
  3. Create a new project:
    $ rebar3 new app myapp
    $ cd myapp
    
  4. Add dependencies to rebar.config:
    {deps, [
      {cowboy, "2.9.0"}
    ]}.
    
  5. Compile and run:
    $ rebar3 compile
    $ rebar3 shell
    

This will set up a basic Erlang application using Rebar3 for build management.

Competitor Comparisons

11,341

Erlang/OTP

Pros of OTP

  • Comprehensive standard library and runtime system for building scalable, fault-tolerant applications
  • Includes built-in support for concurrency, distribution, and hot code reloading
  • Provides a complete ecosystem for developing and deploying Erlang applications

Cons of OTP

  • Steeper learning curve due to its extensive features and concepts
  • Larger codebase and more complex structure compared to Rebar3
  • May be overkill for smaller projects or those not requiring all OTP features

Code Comparison

OTP (supervisor behavior):

init([]) ->
    {ok, {{one_for_one, 5, 10},
          [{my_server, {my_server, start_link, []},
            permanent, 5000, worker, [my_server]}]}}.

Rebar3 (rebar.config):

{erl_opts, [debug_info]}.
{deps, []}.
{plugins, [rebar3_auto]}.
{shell, [{apps, [my_app]}]}.

Summary

OTP is a comprehensive framework for building robust Erlang applications, offering a wide range of features and tools. Rebar3, on the other hand, is a build tool and package manager for Erlang projects. While OTP provides the core runtime and libraries, Rebar3 simplifies project management and dependency handling. OTP is better suited for large-scale, distributed systems, while Rebar3 excels in streamlining the development workflow for Erlang projects of various sizes.

24,386

Elixir is a dynamic, functional language for building scalable and maintainable applications

Pros of Elixir

  • Built-in support for metaprogramming and macros, enabling more expressive and concise code
  • Improved syntax and modern language features, making it more approachable for developers coming from other languages
  • Integrated tooling, including mix for project management, testing, and dependency handling

Cons of Elixir

  • Smaller ecosystem compared to Erlang, with fewer libraries and resources available
  • Potential performance overhead due to additional language abstractions
  • Learning curve for developers unfamiliar with functional programming concepts

Code Comparison

Elixir:

defmodule Hello do
  def world do
    IO.puts "Hello, World!"
  end
end

Erlang (using rebar3):

-module(hello).
-export([world/0]).

world() ->
    io:format("Hello, World!~n").

Both examples achieve the same result, but Elixir's syntax is more concise and resembles modern programming languages. Erlang's syntax is more traditional and may be less intuitive for developers coming from other language backgrounds.

While rebar3 is a build tool for Erlang projects, Elixir comes with mix, which provides similar functionality out of the box. This integrated approach in Elixir can lead to a more streamlined development experience, especially for newcomers to the BEAM ecosystem.

7,256

Small, fast, modern HTTP server for Erlang/OTP.

Pros of Cowboy

  • Specialized HTTP server library for Erlang/OTP, offering high performance and low latency
  • Supports both HTTP/1.1 and HTTP/2, as well as WebSockets
  • Lightweight and modular design, allowing for easy customization

Cons of Cowboy

  • Narrower scope compared to Rebar3, focusing solely on HTTP server functionality
  • Steeper learning curve for developers new to Erlang or HTTP server implementation
  • May require additional tools or libraries for a complete web application stack

Code Comparison

Cowboy (HTTP server setup):

start(_Type, _Args) ->
    Dispatch = cowboy_router:compile([
        {'_', [{"/", my_handler, []}]}
    ]),
    {ok, _} = cowboy:start_clear(my_http_listener,
        [{port, 8080}],
        #{env => #{dispatch => Dispatch}}
    ),
    my_app_sup:start_link().

Rebar3 (Project configuration):

{erl_opts, [debug_info]}.
{deps, [
    {cowboy, "2.9.0"}
]}.
{relx, [{release, {my_app, "0.1.0"},
         [my_app, sasl]},
        {mode, dev}]}.

Note: The code snippets demonstrate different aspects of each project, as Rebar3 is a build tool and Cowboy is an HTTP server library.

13,968

The most scalable open-source MQTT broker for IoT, IIoT, and connected vehicles

Pros of EMQX

  • Specialized MQTT broker with extensive IoT messaging features
  • Scalable architecture supporting millions of concurrent connections
  • Rich plugin ecosystem for extending functionality

Cons of EMQX

  • More complex setup and configuration compared to Rebar3
  • Narrower focus on MQTT and IoT, less versatile for general Erlang projects
  • Steeper learning curve for developers new to MQTT or IoT

Code Comparison

EMQX configuration example:

{emqx, [
  {listeners, [
    {tcp, 1883, [{acceptors, 16}, {max_connections, 512000}]}
  ]},
  {mqtt, [
    {allow_anonymous, true},
    {max_clientid_len, 1024}
  ]}
]}

Rebar3 configuration example:

{erl_opts, [debug_info]}.
{deps, [
  {cowboy, "2.9.0"},
  {jsx, "3.1.0"}
]}.
{relx, [{release, {my_app, "0.1.0"}, [my_app]}]}.

While EMQX focuses on MQTT broker configuration, Rebar3 is a build tool for managing Erlang projects, dependencies, and releases. EMQX provides a more specialized solution for IoT messaging, while Rebar3 offers broader project management capabilities for Erlang development.

Robust, Ubiquitous and Massively Scalable Messaging Platform (XMPP, MQTT, SIP Server)

Pros of ejabberd

  • Specialized XMPP server with extensive messaging features
  • Highly scalable and robust for real-time communication applications
  • Active community and regular updates for security and performance

Cons of ejabberd

  • Steeper learning curve for non-XMPP developers
  • More complex setup and configuration compared to general-purpose build tools
  • Limited use cases outside of XMPP/messaging applications

Code Comparison

ejabberd (XMPP stanza handling):

handle_info({route, From, To, Packet}, State) ->
    case catch do_route(From, To, Packet) of
        {'EXIT', Reason} ->
            ?ERROR_MSG("error routing packet: ~p", [Reason]);
        _ -> ok
    end,
    {noreply, State}.

rebar3 (Plugin compilation):

compile(State, Apps) ->
    [begin
         Opts = rebar_app_info:opts(AppInfo),
         AppDir = rebar_app_info:dir(AppInfo),
         compile_app(State, Opts, AppDir)
     end || AppInfo <- Apps],
    {ok, State}.

While ejabberd focuses on XMPP protocol handling and messaging functionality, rebar3 is a general-purpose Erlang build tool. ejabberd is better suited for developers building messaging systems, while rebar3 is more versatile for various Erlang projects. The code snippets highlight their different purposes: ejabberd deals with routing XMPP packets, while rebar3 manages compilation of Erlang applications.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Rebar3

Build Status Erlang Versions

  1. What is Rebar3?
  2. Why Rebar3?
  3. Should I Use Rebar3?
  4. Getting Started
  5. Documentation
  6. Features
  7. Migrating from rebar2
  8. Additional Resources

What is Rebar3

Rebar3 is an Erlang tool that makes it easy to create, develop, and release Erlang libraries, applications, and systems in a repeatable manner.

Rebar3 will:

  • respect and enforce standard Erlang/OTP conventions for project structure so they are easily reusable by the community;
  • manage source dependencies and Erlang packages while ensuring repeatable builds;
  • handle build artifacts, paths, and libraries such that standard development tools can be used without a headache;
  • adapt to projects of all sizes on almost any platform;
  • treat documentation as a feature, and errors or lack of documentation as a bug.

Rebar3 is also a self-contained Erlang script. It is easy to distribute or embed directly in a project. Tasks or behaviours can be modified or expanded with a plugin system flexible enough that even other languages on the Erlang VM will use it as a build tool.

Why Rebar3

Rebar3 is the spiritual successor to rebar 2.x, which was the first usable build tool for Erlang that ended up seeing widespread community adoption. It however had several shortcomings that made it difficult to use with larger projects or with teams with users new to Erlang.

Rebar3 was our attempt at improving over the legacy of Rebar 2.x, providing the features we felt it was missing, and to provide a better environment in which newcomers joining our teams could develop.

Should I use Rebar3?

If your main language for your system is Erlang, that you value repeatable builds and want your various tools to integrate together, we do believe Rebar3 is the best experience you can get.

Getting Started

A getting started guide is maintained on the official documentation website, but installing rebar3 can be done by any of the ways described below

Latest stable compiled version:

$ wget https://s3.amazonaws.com/rebar3/rebar3 && chmod +x rebar3

From Source (assuming you have a full Erlang install):

$ git clone https://github.com/erlang/rebar3.git
$ cd rebar3
$ ./bootstrap

Stable versions can also be obtained from the releases page.

The rebar3 escript can also extract itself with a run script under the user's home directory:

$ ./rebar3 local install
===> Extracting rebar3 libs to ~/.cache/rebar3/lib...
===> Writing rebar3 run script ~/.cache/rebar3/bin/rebar3...
===> Add to $PATH for use: export PATH=~/.cache/rebar3/bin:$PATH

To keep it up to date after you've installed rebar3 this way you can use rebar3 local upgrade which fetches the latest stable release and extracts to the same place as above. A nightly version can also be obtained if desired.

Rebar3 may also be available on various OS-specific package managers such as FreeBSD Ports. Those are maintained by the community and Rebar3 maintainers themselves are generally not involved in that process.

If you do not have a full Erlang install, we recommend using erln8 or kerl. For binary packages, use those provided by Erlang Solutions, but be sure to choose the "Standard" download option or you'll have issues building projects.

Do note that if you are planning to work with multiple Erlang versions on the same machine, you will want to build Rebar3 with the oldest one of them. The 3 newest major Erlang releases are supported at any given time: if the newest version is OTP-27, building with versions as old as OTP-25 will be supported, and produce an executable that will work with those that follow.

Documentation

Rebar3 documentation is maintained on https://rebar3.org/docs

Features

Rebar3 supports the following features or tools by default, and may provide many others via the plugin ecosystem:

featuresDescription
Command compositionRebar3 allows multiple commands to be run in sequence by calling rebar3 do <task1>,<task2>,...,<taskN>.
Command dependenciesRebar3 commands know their own dependencies. If a test run needs to fetch dependencies and build them, it will do so.
Command namespacesAllows multiple tools or commands to share the same name.
CompilingBuild the project, including fetching all of its dependencies by calling rebar3 compile
Clean up artifactsRemove the compiled beam files from a project with rebar3 clean or just remove the _build directory to remove all compilation artifacts
Code CoverageVarious commands can be instrumented to accumulate code coverage data (such as eunit or ct). Reports can be generated with rebar3 cover
Common TestThe test framework can be run by calling rebar3 ct
DependenciesRebar3 maintains local copies of dependencies on a per-project basis. They are fetched deterministically, can be locked, upgraded, fetched from source, packages, or from local directories. See Dependencies on the documentation website. Call rebar3 tree to show the whole dependency tree.
DocumentationPrint help for rebar3 itself (rebar3 help) or for a specific task (rebar3 help <task>). Full reference at rebar3.org.
DialyzerRun the Dialyzer analyzer on the project with rebar3 dialyzer. Base PLTs for each version of the language will be cached and reused for faster analysis
EdocGenerate documentation using edoc with rebar3 edoc
Escript generationRebar3 can be used to generate escripts providing an easy way to run all your applications on a system where Erlang is installed
EunitThe test framework can be run by calling rebar3 eunit
Locked dependenciesDependencies are going to be automatically locked to ensure repeatable builds. Versions can be changed with rebar3 upgrade or rebar3 upgrade <app>, or locks can be released altogether with rebar3 unlock.
PackagesA given Hex package can be inspected rebar3 pkgs <name>. This will output its description and available versions
PathWhile paths are managed automatically, you can print paths to the current build directories with rebar3 path.
PluginsRebar3 can be fully extended with plugins. List or upgrade plugins by using the plugin namespace (rebar3 plugins).
ProfilesRebar3 can have subconfiguration options for different profiles, such as test or prod. These allow specific dependencies or compile options to be used in specific contexts. See Profiles in the docs.
ReleasesRebar3 supports building releases with the relx tool, providing a way to ship fully self-contained Erlang systems. Release update scripts for live code updates can also be generated.
ShellA full shell with your applications available can be started with rebar3 shell. From there, call tasks as r3:do(compile) to automatically recompile and reload the code without interruption
TarballsReleases can be packaged into tarballs ready to be deployed.
TemplatesConfigurable templates ship out of the box (try rebar3 new for a list or rebar3 new help <template> for a specific one). Custom templates are also supported, and plugins can also add their own.
XrefRun cross-reference analysis on the project with xref by calling rebar3 xref.

Migrating From rebar2

The grievances we had with Rebar 2.x were not fixable without breaking compatibility in some very important ways.

A full guide titled From Rebar 2.x to Rebar3 is provided on the documentation website.

Notable modifications include mandating a more standard set of directory structures, changing the handling of dependencies, moving some compilers (such as C, Diameter, ErlyDTL, or ProtoBuffs) to plugins rather than maintaining them in core rebar, and moving release builds from reltool to relx.

Additional Resources

In the case of problems that cannot be solved through documentation or examples, you may want to try to contact members of the community for help. The community is also where you want to go for questions about how to extend rebar, fill in bug reports, and so on.

If you need quick feedback, you can try the #rebar channel on irc.freenode.net or the #rebar3 channel on erlanger.slack.com. Be sure to check the documentation first, just to be sure you're not asking about things with well-known answers.

For bug reports, roadmaps, and issues, visit the github issues page.

General rebar community resources and links can be found at rebar3.org/docs/about/about-us/#community

To contribute to rebar3, please refer to CONTRIBUTING.