[erlang-questions] customizing the rebar-generated .app file

Tim Watson <>
Wed Oct 5 15:39:14 CEST 2011


On 5 October 2011 14:30, Joel Reymont <> wrote:

> I would like to customize the app file created by rebar.
>
> For example, I would like to change the env section and make sure
> applications includes mnesia and lager.
>

If you put the env section in your src/<name>.app.src file then it will be
copied across verbatim.

Last but not least, I would like to change the version to the output of `git
> rev-parse --short HEAD`.
>
>
If your application is in a subdirectory within the project (i.e., is one of
sub_dirs) then you can do this by generating the version you want in a file
inside the project subdirectory named priv/vsn.git - then you can put {vsn,
git} in your app.src and it will work fine. I do something similar using a
rebar plugin here:
https://github.com/hyperthunk/nodewatch/blob/master/build/src/git_vsn_plugin.erl

Other approaches include

- write a rebar plugin that hooks into post_compile/2 and overwrites the
value in the generated .app file
- write a command line hook that uses sed on the generated .app file, and
register it as {post_hooks, [{compile, "sed ....."}]} in your rebar.config

You may even be able to do this with rebar's app.vars file, although I'm not
100% sure if that'll work.

HTH!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20111005/17746a50/attachment.html>


More information about the erlang-questions mailing list