1%% directory for artifacts produced by rebar3
2{base_dir, "_build"}.
3%% directory in '<base_dir>/<profile>/' where deps go
4{deps_dir, "lib"}.
5%% where rebar3 operates from; defaults to the current working directory
6{root_dir, "."}.
7%% where checkout dependencies are to be located
8{checkouts_dir, "_checkouts"}.
9%% directory in '<base_dir>/<profile>/' where plugins go
10{plugins_dir, "plugins"}.
11%% directories where OTP applications for the project can be located
12{project_app_dirs, ["apps/*", "lib/*", "."]}.
13%% Directories where source files for an OTP application can be found
14{src_dirs, ["src"]}.
15%% Paths to miscellaneous Erlang files to compile for an app
16%% without including them in its modules list
17{extra_src_dirs, []}.
18%% Paths the compiler outputs when reporting warnings or errors
19%% relative (default), build (all paths are in _build, default prior
20%% to 3.2.0, and absolute are valid options
21{compiler_source_format, relative}.
22
23
24
25%
26{overrides, [
27 %% For all apps:
28 {del, [{erl_opts, [warnings_as_errors]}]},
29 %% Or for just one app:
30 {del, one_app, [{erl_opts, [warnings_as_errors]}]}
31]}.
32
33
34
35
36
37{erl_opts, [
38 warn_unused_vars
39 ,warn_export_all
40 ,warn_shadow_vars
41 ,warn_unused_import
42 ,warn_unused_function
43 ,warn_bif_clash
44 ,warn_unused_record
45 ,warn_deprecated_function
46 ,warn_obsolete_guard
47 ,strict_validation
48 ,warn_export_vars
49 ,warn_exported_vars
50 ,warn_missing_spec
51 ,warn_untyped_record
52 ,debug_info % 调试
53 ,no_debug_info %
54 ,nowarn_unused_function
55 ,{i, "./include"} % 指定include文件目录
56 ,{d, 'NOTEST', true} %
57 ,{d, TEST, true} % -ifdef(TEST).
58 ,{d, EUNIT, true} % -ifdef(EUNIT).
59 ,{parse_transform, lager_transform}
60]}.
61
62
63% 增加这句,依赖有冲突时,会中止
64{deps_error_on_conflict, true}.
65% 设定rebar镜像
66{rebar_packages_cdn, "https://hexpm.upyun.com"}.
67
68%% ================================================
69%% 插件
70%% ================================================
71{plugins, [
72 { pc, {git, "https://github.com/blt/port_compiler.git", {tag, "1.6.0"}}}
73 % .dtl格式文件插件
74 {rebar3_erlydtl_plugin, ".*",
75 {git, "https://github.com/tsloughter/rebar3_erlydtl_plugin.git", {branch, "master"}}}
76]}.
77
78{erlydtl_opts,[ % erlydtl插件相关配置
79 {doc_root, "templates"}
80 %,{compiler_options, [report, return, debug_info]}
81]}.
82
83
84%% ================================================
85%% deps
86%% ================================================
87{deps, [
88 %% Packages
89 rebar,
90 {rebar,"1.0.0"},
91 {rebar, {pkg, rebar_fork}}, % rebar app under a different pkg name
92 {rebar, "1.0.0", {pkg, rebar_fork}},
93 %% Source Dependencies
94 {rebar, {git, "git://github.com/erlang/rebar3.git"}},
95 {rebar, {git, "http://github.com/erlang/rebar3.git"}},
96 {rebar, {git, "https://github.com/erlang/rebar3.git"}},
97 {rebar, {git, "git@github.com:erlang/rebar3.git"}},
98 {rebar, {hg, "https://othersite.com/erlang/rebar3"}},
99 {rebar, {git, "git://github.com/erlang/rebar3.git", {ref, "aef728"}}},
100 {rebar, {git, "git://github.com/erlang/rebar3.git", {branch, "master"}}},
101 {rebar, {git, "git://github.com/erlang/rebar3.git", {tag, "3.0.0"}}},
102 %% Legacy support -- added parts such as [raw] are ignored
103 {rebar, "3.*", {git,"git://github.com/erlang/rebar3.git"}},
104 {rebar, {git, "git://github.com/erlang/rebar3.git"}, [raw]},
105 {rebar, "3.*", {git, "git://github.com/erlang/rebar3.git"}, [raw]}
106]}.
107
108
109
110
111%% ================================================
112%% hooks
113%% ================================================
114{provider_hooks, [ %% hook钩子
115 {pre, [{compile, {erlydtl, compile}}]} % 执行rebar3 compile时先执行rebar3 plugin compile
116]}.
117
118{pre_hooks, [{"(linux|darwin|solaris)", compile, "make -C \"$REBAR_DEPS_DIR/merl\" all -W test"},
119 {"(freebsd|netbsd|openbsd)", compile, "gmake -C \"$REBAR_DEPS_DIR/merl\" all"},
120 {"win32", compile, "make -C \"%REBAR_DEPS_DIR%/merl\" all -W test"},
121 {eunit, "erlc -I include/erlydtl_preparser.hrl -o test test/erlydtl_extension_testparser.yrl"},
122 {"(linux|darwin|solaris)", eunit, "make -C \"$REBAR_DEPS_DIR/merl\" test"},
123 {"(freebsd|netbsd|openbsd)", eunit, "gmake -C \"$REBAR_DEPS_DIR/merl\" test"},
124 {"win32", eunit, "make -C \"%REBAR_DEPS_DIR%/merl\" test"}
125 ]}.
126
127
128{post_hooks, [
129% {compile, "./relx"} % 每次调用 rebar compile 时,都会生成 release
130]}.
131
132
133
134%% ================================================
135%% relx
136%% ================================================
137{relx, [
138 {release,
139 { demo_erlang, "0.1.2" },
140 [
141 cowboy,
142 lager,
143 demo_erlang,
144 reloader,
145 sasl
146 ]
147 },
148 {release,
149 { demo_lager, "0.0.3" },
150 [
151 observer_cli,
152 lager,
153 demo_lager,
154 reloader,
155 sasl
156 ]
157 },
158
159 {sys_config, "./config/sys.config"},
160 {vm_args, "./config/vm.args"},
161
162 {dev_mode, true},
163 {include_erts, false},
164
165 {extended_start_script, true}
166]}.
167
168
169%% ================================================
170%% profiles
171%% ================================================
172{profiles, [
173 {prod, [{relx, [
174 {dev_mode, false},
175 {include_erts, true}
176 ]}]},
177 {cowboy, [{relx, [
178 {release,
179 { demo_erlang, "0.1.0" },
180 [
181 cowboy,
182 demo_erlang,
183 sasl
184 ]
185 },
186 {dev_mode, false}
187 ]}]},
188 {lager, [{relx, [
189 {dev_mode, false}
190 ]}]}
191 ]
192}.