選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

173 行
10 KiB

  1. # Rebar3
  2. ![Build Status](https://github.com/erlang/rebar3/workflows/Common%20Test/badge.svg)
  3. 1. [What is Rebar3?](#what-is-rebar3)
  4. 2. [Why Rebar3?](#why-rebar3)
  5. 3. [Should I Use Rebar3?](#should-i-use-rebar3)
  6. 4. [Getting Started](#getting-started)
  7. 5. [Documentation](#documentation)
  8. 6. [Features](#features)
  9. 7. [Migrating from rebar2](#migrating-from-rebar2)
  10. 8. [Additional Resources](#additional-resources)
  11. ## What is Rebar3
  12. Rebar3 is an Erlang tool that makes it easy to create, develop, and
  13. release Erlang libraries, applications, and systems in a repeatable manner.
  14. Rebar3 will:
  15. - respect and enforce standard Erlang/OTP conventions for project
  16. structure so they are easily reusable by the community;
  17. - manage source dependencies and Erlang [packages](https://hex.pm)
  18. while ensuring repeatable builds;
  19. - handle build artifacts, paths, and libraries such that standard
  20. development tools can be used without a headache;
  21. - adapt to projects of all sizes on almost any platform;
  22. - treat [documentation](https://www.rebar3.org/docs/) as a feature,
  23. and errors or lack of documentation as a bug.
  24. Rebar3 is also a self-contained Erlang script. It is easy to distribute or
  25. embed directly in a project. Tasks or behaviours can be modified or expanded
  26. with a [plugin system](https://www.rebar3.org/docs/using-available-plugins)
  27. [flexible enough](https://www.rebar3.org/docs/plugins) that even other languages
  28. on the Erlang VM will use it as a build tool.
  29. ## Why Rebar3
  30. Rebar3 is the spiritual successor to [rebar
  31. 2.x](https://github.com/rebar/rebar), which was the first usable build tool
  32. for Erlang that ended up seeing widespread community adoption. It however
  33. had several shortcomings that made it difficult to use with larger projects
  34. or with teams with users new to Erlang.
  35. Rebar3 was our attempt at improving over the legacy of Rebar 2.x, providing the
  36. features we felt it was missing, and to provide a better environment in which
  37. newcomers joining our teams could develop.
  38. ## Should I use Rebar3?
  39. If your main language for your system is Erlang, that you value repeatable builds
  40. and want your various tools to integrate together, we do believe Rebar3 is the
  41. best experience you can get.
  42. ## Getting Started
  43. A [getting started guide is maintained on the official documentation website](https://www.rebar3.org/docs/getting-started),
  44. but installing rebar3 can be done by any of the ways described below
  45. Latest stable compiled version:
  46. ```bash
  47. $ wget https://s3.amazonaws.com/rebar3/rebar3 && chmod +x rebar3
  48. ```
  49. From Source (assuming you have a full Erlang install):
  50. ```bash
  51. $ git clone https://github.com/erlang/rebar3.git
  52. $ cd rebar3
  53. $ ./bootstrap
  54. ```
  55. Stable versions can also be obtained from the [releases page](https://github.com/erlang/rebar3/releases).
  56. The rebar3 escript can also extract itself with a run script under the user's home directory:
  57. ```bash
  58. $ ./rebar3 local install
  59. ===> Extracting rebar3 libs to ~/.cache/rebar3/lib...
  60. ===> Writing rebar3 run script ~/.cache/rebar3/bin/rebar3...
  61. ===> Add to $PATH for use: export PATH=~/.cache/rebar3/bin:$PATH
  62. ```
  63. To keep it up to date after you've installed rebar3 this way you can use `rebar3 local upgrade` which
  64. fetches the latest stable release and extracts to the same place as above. A [nightly version can
  65. also be obtained](https://s3.amazonaws.com/rebar3-nightly/rebar3) if desired.
  66. Rebar3 may also be available on various OS-specific package managers such as
  67. FreeBSD Ports. Those are maintained by the community and Rebar3 maintainers
  68. themselves are generally not involved in that process.
  69. If you do not have a full Erlang install, we recommend using [erln8](https://erln8.github.io/erln8/)
  70. or [kerl](https://github.com/yrashk/kerl). For binary packages, use those provided
  71. by [Erlang Solutions](https://www.erlang-solutions.com/resources/download.html),
  72. but be sure to choose the "Standard" download option or you'll have issues building
  73. projects.
  74. ## Documentation
  75. Rebar3 documentation is maintained on [https://www.rebar3.org/docs](https://www.rebar3.org/docs)
  76. ## Features
  77. Rebar3 supports the following features or tools by default, and may provide many
  78. others via the plugin ecosystem:
  79. | features | Description |
  80. |--------------------- |------------ |
  81. | Command composition | Rebar3 allows multiple commands to be run in sequence by calling `rebar3 do <task1>,<task2>,...,<taskN>`. |
  82. | Command dependencies | Rebar3 commands know their own dependencies. If a test run needs to fetch dependencies and build them, it will do so. |
  83. | Command namespaces | Allows multiple tools or commands to share the same name. |
  84. | Compiling | Build the project, including fetching all of its dependencies by calling `rebar3 compile` |
  85. | Clean up artifacts | Remove the compiled beam files from a project with `rebar3 clean` or just remove the `_build` directory to remove *all* compilation artifacts |
  86. | Code Coverage | Various commands can be instrumented to accumulate code coverage data (such as `eunit` or `ct`). Reports can be generated with `rebar3 cover` |
  87. | Common Test | The test framework can be run by calling `rebar3 ct` |
  88. | Dependencies | Rebar3 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](https://www.rebar3.org/docs/dependencies). Call `rebar3 tree` to show the whole dependency tree. |
  89. | Documentation | Print help for rebar3 itself (`rebar3 help`) or for a specific task (`rebar3 help <task>`). Full reference at [www.rebar3.org](https://www.rebar3.org/docs). |
  90. | Dialyzer | Run 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 |
  91. | Edoc | Generate documentation using edoc with `rebar3 edoc` |
  92. | Escript generation | Rebar3 can be used to generate [escripts](http://www.erlang.org/doc/man/escript.html) providing an easy way to run all your applications on a system where Erlang is installed |
  93. | Eunit | The test framework can be run by calling `rebar3 eunit` |
  94. | Locked dependencies | Dependencies 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`. |
  95. | Packages | [Hex packages](https://hex.pm) can be listed with `rebar3 pkgs`. They can be used as dependencies, will be cached locally for faster usage, and a local index will be used and updated with `rebar3 update`. |
  96. | Path | While paths are managed automatically, you can print paths to the current build directories with `rebar3 path`. |
  97. | Plugins | Rebar3 can be fully extended with [plugins](https://www.rebar3.org/docs/using-available-plugins). List or upgrade plugins by using the plugin namespace (`rebar3 plugins`). |
  98. | Profiles | Rebar3 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](https://www.rebar3.org/docs/profiles) in the docs. |
  99. | Releases | Rebar3 supports [building releases](https://www.rebar3.org/docs/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. |
  100. | Shell | A 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 |
  101. | Tarballs | Releases can be packaged into tarballs ready to be deployed. |
  102. | Templates | Configurable templates ship out of the box (try `rebar3 new` for a list or `rebar3 new help <template>` for a specific one). [Custom templates](https://www.rebar3.org/docs/using-templates) are also supported, and plugins can also add their own. |
  103. | Unstable namespace | We use a namespace to provide commands that are still in flux, allowing to test more experimental features we are working on. See `rebar3 unstable`. |
  104. | Xref | Run cross-reference analysis on the project with [xref](http://www.erlang.org/doc/apps/tools/xref_chapter.html) by calling `rebar3 xref`. |
  105. ## Migrating From rebar2
  106. The grievances we had with Rebar 2.x were not fixable without breaking
  107. compatibility in some very important ways.
  108. A full guide titled [From Rebar 2.x to Rebar3](https://www.rebar3.org/docs/from-rebar-2x-to-rebar3)
  109. is provided on the documentation website.
  110. Notable modifications include mandating a more standard set of directory
  111. structures, changing the handling of dependencies, moving some compilers (such
  112. as C, Diameter, ErlyDTL, or ProtoBuffs) to
  113. [plugins](https://www.rebar3.org/docs/using-available-plugins) rather than
  114. maintaining them in core rebar, and moving release builds from reltool to
  115. relx.
  116. ## Additional Resources
  117. In the case of problems that cannot be solved through documentation or examples, you
  118. may want to try to contact members of the community for help. The community is
  119. also where you want to go for questions about how to extend rebar, fill in bug
  120. reports, and so on.
  121. The main place to go for questions is the [rebar mailing
  122. list](https://lists.basho.com/pipermail/rebar_lists.basho.com/). If you need
  123. quick feedback, you can try the #rebar channel on
  124. [irc.freenode.net](https://freenode.net). Be sure to check the
  125. [documentation](https://www.rebar3.org/v3.0/docs) first, just to be sure you're not
  126. asking about things with well-known answers.
  127. For bug reports, roadmaps, and issues, visit the [github issues
  128. page](https://github.com/erlang/rebar3/issues).
  129. General rebar community resources and links:
  130. - [Rebar Mailing List](https://lists.basho.com/pipermail/rebar_lists.basho.com/)
  131. - #rebar on [irc.freenode.net](https://freenode.net/)
  132. - [issues](https://github.com/erlang/rebar3/issues)
  133. - [Documentation](https://www.rebar3.org/v3.0/docs)
  134. To contribute to rebar3, please refer to [CONTRIBUTING](CONTRIBUTING.md).