Skip to content

Commit 489e0cb

Browse files
committed
Upgrade to Rebar3, additions to publish to Hex.pm
Uses rebar3 as the build tool, but with a rebar.config.script for rebar2 backwards-compatibility. A few bits filled in on the .app.src file for Hex.pm publishing.
1 parent 108846c commit 489e0cb

File tree

5 files changed

+53
-14
lines changed

5 files changed

+53
-14
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,6 @@ src/eini_lexer.erl
55
ebin/*.app
66
.eunit
77
deps
8+
/_build
9+
/TEST-*.xml
10+
.rebar

rebar.config

+14-12
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
%% -*- mode: erlang; -*-
12
{erl_opts, [warnings_as_errors,
23
warn_export_all,
34
warn_unused_import
@@ -9,13 +10,6 @@
910

1011
{clean_files, [".eunit/*", "ebin/*.beam"]}.
1112

12-
{eunit_opts, [{report,{eunit_surefire,[{dir,"."}]}}]}.
13-
14-
{cover_enabled, true}.
15-
16-
{plugins, [rebar_covertool]}.
17-
{covertool_eunit, ".eunit/eunit.coverage.xml"}.
18-
1913
{edoc_opts, [{dialyzer_specs, all},
2014
{report_missing_type, true},
2115
{report_type_mismatch, true},
@@ -26,9 +20,17 @@
2620

2721
{deps,
2822
[
29-
{proper,
30-
".*", {git, "git://github.com/manopapad/proper.git", {branch, "master"}}},
31-
32-
{covertool,
33-
".*", {git, "https://github.com/idubrov/covertool.git", {branch, "master"}}}
3423
]}.
24+
25+
{profiles, [
26+
{test, [
27+
{eunit_opts, [{report,{eunit_surefire,[{dir,"."}]}}]}
28+
,{cover_enabled, true}
29+
,{plugins, [rebar_covertool]}
30+
,{covertool_eunit, ".eunit/eunit.coverage.xml"}
31+
,{deps, [
32+
{proper, {git, "https://github.com/manopapad/proper.git", {ref, "v1.2"}}},
33+
{covertool, {git, "https://github.com/idubrov/covertool.git", {branch, "master"}}}
34+
]}
35+
]}
36+
]}.

rebar.config.script

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
%% -*- mode: erlang; -*-
2+
case erlang:function_exported(rebar3, main, 1) of
3+
true ->
4+
%% rebar3
5+
CONFIG;
6+
false ->
7+
%% rebar 2.x or older
8+
%% rebuild deps
9+
Rebar3Deps = proplists:get_value(deps, CONFIG),
10+
Rebar3TestProf = proplists:get_value(test, proplists:get_value(profiles, CONFIG)),
11+
{value, {deps, Rebar3TestDeps}, Rebar3TestProf2} = lists:keytake(deps, 1, Rebar3TestProf),
12+
13+
%% whenever adding a new Hex package dependency, this fun should be
14+
%% updated
15+
HexToRepo = fun(proper) -> "https://github.com/manopapad/proper.git";
16+
(covertool) -> "https://github.com/idubrov/covertool.git"
17+
end,
18+
19+
ConvertDep =
20+
fun({DepName, {git, Repo, {ref, Tag}}}) ->
21+
{DepName, ".*", {git, Repo, {tag, Tag}}};
22+
({DepName, {git, Repo, {branch, Branch}}}) ->
23+
{DepName, ".*", {git, Repo, {branch, Branch}}};
24+
({HexDepName, HexDepVersion}) ->
25+
{HexDepName, ".*", {git, HexToRepo(HexDepName), {tag, HexDepVersion}}}
26+
end,
27+
28+
Rebar2Deps = [ ConvertDep(Dep) || Dep <- Rebar3Deps ++ Rebar3TestDeps ],
29+
30+
lists:keystore(deps, 1, CONFIG, {deps, Rebar2Deps}) ++ Rebar3TestProf2
31+
end.

rebar.lock

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[].

src/eini.app.src

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
{application, eini, [
22
{description, "An Erlang INI parser"},
3-
{vsn, "1.2.1"},
3+
{vsn, git},
44
{applications, [kernel, stdlib]},
55
{modules, []},
66
{registered, []},
7-
{mod, {eini_app, []}}
7+
{mod, {eini_app, []}},
8+
{licenses, ["Apache 2.0"]},
9+
{links, [{"Github", "https://github.com/erlcloud/eini"}]}
810
]}.

0 commit comments

Comments
 (0)