erlware / rebar_vsn_plugin

Provides a more reasonable versioning scheme then the rebar standard 'git' vsn extension
17 stars 14 forks source link

Compilation failure trying to use reltool.config as .app file #13

Closed define-null closed 11 years ago

define-null commented 11 years ago

This changes should be done to prevent from failing of compilation if rel directory is set in sub_dirs. Rebar plugin mechanism is calling post and pre hooks for targets both for app files and for reltool.config files, and functions are provided to check wherether it is app dir or rel dir.

rebar_vsn_plugin/src/rebar_vsn_plugin.erl
@@ -29,14 +29,19 @@
 %% API
 %%============================================================================
 post_compile(Config, AppFile) ->
-    {AppName, SrcDetail} =
-        get_app_meta(Config, AppFile),
-    case proplists:get_value(vsn, SrcDetail) of
-        "semver" ->
-            do_vsn_replacement(AppName, Config, AppFile);
-        semver ->
-            do_vsn_replacement(AppName, Config, AppFile);
-        _ ->
+    case rebar_app_utils:is_app_dir() of
+        {true, AppFile} ->
+            {AppName, SrcDetail} =
+                get_app_meta(Config, AppFile),
+            case proplists:get_value(vsn, SrcDetail) of
+                "semver" ->
+                    do_vsn_replacement(AppName, Config, AppFile);
+                semver ->
+                    do_vsn_replacement(AppName, Config, AppFile);
+                _ ->
+                    ok
+            end;
+        false ->
             ok
     end.
ericbmerritt commented 11 years ago

@define-null I am not a reltool user, so I didn't realize it called the 'compile' on both. Thats more then a bit crazy. However, I will get a patch out with your changes.