summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/rebar_app_discover.erl3
-rw-r--r--src/rebar_app_info.erl4
-rw-r--r--src/rebar_otp_app.erl19
3 files changed, 13 insertions, 13 deletions
diff --git a/src/rebar_app_discover.erl b/src/rebar_app_discover.erl
index 4f7442b..67acf54 100644
--- a/src/rebar_app_discover.erl
+++ b/src/rebar_app_discover.erl
@@ -229,7 +229,8 @@ try_handle_app_file(AppInfo0, [File], AppDir, AppSrcFile, _, Validate) ->
[F] ->
rebar_app_info:app_file_src(AppInfo1, F);
[] ->
- AppInfo1;
+ %% Set to undefined in case AppInfo previous had a .app.src
+ rebar_app_info:app_file_src(AppInfo1, undefined);
Other when is_list(Other) ->
throw({error, {multiple_app_files, Other}})
end,
diff --git a/src/rebar_app_info.erl b/src/rebar_app_info.erl
index b41880e..bb9f7a4 100644
--- a/src/rebar_app_info.erl
+++ b/src/rebar_app_info.erl
@@ -232,6 +232,8 @@ app_file_src(#app_info_t{app_file_src=AppFileSrc}) ->
ec_cnv:to_list(AppFileSrc).
-spec app_file_src(t(), file:filename_all()) -> t().
+app_file_src(AppInfo=#app_info_t{}, undefined) ->
+ AppInfo#app_info_t{app_file_src=undefined};
app_file_src(AppInfo=#app_info_t{}, AppFileSrc) ->
AppInfo#app_info_t{app_file_src=ec_cnv:to_list(AppFileSrc)}.
@@ -248,6 +250,8 @@ app_file_src_script(#app_info_t{app_file_src_script=AppFileSrcScript}) ->
ec_cnv:to_list(AppFileSrcScript).
-spec app_file_src_script(t(), file:filename_all()) -> t().
+app_file_src_script(AppInfo=#app_info_t{}, undefined) ->
+ AppInfo#app_info_t{app_file_src_script=undefined};
app_file_src_script(AppInfo=#app_info_t{}, AppFileSrcScript) ->
AppInfo#app_info_t{app_file_src_script=ec_cnv:to_list(AppFileSrcScript)}.
diff --git a/src/rebar_otp_app.erl b/src/rebar_otp_app.erl
index c1d90bc..ddaa44b 100644
--- a/src/rebar_otp_app.erl
+++ b/src/rebar_otp_app.erl
@@ -60,7 +60,7 @@ compile(State, App) ->
format_error({missing_app_file, Filename}) ->
io_lib:format("App file is missing: ~s", [Filename]);
format_error({file_read, File, Reason}) ->
- io_lib:format("Failed to read app file ~s for processing: ~p", [File, file:format_error(Reason)]);
+ io_lib:format("Failed to read required file ~s for processing: ~s", [File, file:format_error(Reason)]);
format_error({invalid_name, File, AppName}) ->
io_lib:format("Invalid ~s: name of application (~p) must match filename.", [File, AppName]).
@@ -110,7 +110,7 @@ preprocess(State, AppInfo, AppSrcFile) ->
A1 = apply_app_vars(AppVars, AppData),
%% AppSrcFile may contain instructions for generating a vsn number
- Vsn = app_vsn(AppSrcFile, State),
+ Vsn = app_vsn(AppData, AppSrcFile, State),
A2 = lists:keystore(vsn, 1, A1, {vsn, Vsn}),
%% systools:make_relup/4 fails with {missing_param, registered}
@@ -128,7 +128,7 @@ preprocess(State, AppInfo, AppSrcFile) ->
AppFile;
{error, Reason} ->
- ?PRV_ERROR({file_read, AppSrcFile, Reason})
+ throw(?PRV_ERROR({file_read, AppSrcFile, Reason}))
end.
load_app_vars(State) ->
@@ -214,15 +214,10 @@ consult_app_file(Filename) ->
end
end.
-app_vsn(AppFile, State) ->
- case consult_app_file(AppFile) of
- {ok, [{application, _AppName, AppData}]} ->
- AppDir = filename:dirname(filename:dirname(AppFile)),
- Resources = rebar_state:resources(State),
- rebar_utils:vcs_vsn(get_value(vsn, AppData, AppFile), AppDir, Resources);
- {error, Reason} ->
- throw(?PRV_ERROR({file_read, AppFile, Reason}))
- end.
+app_vsn(AppData, AppFile, State) ->
+ AppDir = filename:dirname(filename:dirname(AppFile)),
+ Resources = rebar_state:resources(State),
+ rebar_utils:vcs_vsn(get_value(vsn, AppData, AppFile), AppDir, Resources).
get_value(Key, AppInfo, AppFile) ->
case proplists:get_value(Key, AppInfo) of