One of my approaches was to create an application that does nothing but contains record definitions common to several projects. Then I used reinforcement to turn it into a dependency. When including hrl files, I use include_lib syntax. This syntax allows you to include hrl files from another application.
app ebin include priv src some_src.erl deps common_hrl_app include common_records.hrl src ebin other_dep_app src other_src.erl . . .
include_lib example that may appear in some_src.erl or other_src.erl:
-include_lib("common_hrl_app/include/common_records.hrl").
I like this approach because:
- It works great with rebar dependency system
- This allows me to track hrls in one place in version control
- I can change this application that allows me to pull certain versions if I want the new application to be compatible with another using the same entries.
Answering questions from comments:
I have a skeleton application file in the ebin directory that indicates the name and version of the application so that the armature can check the version. Here is an example
{application,common_hrl_app, [{description,[]}, {vsn,"1"}, {registered,[]}, {applications,[kernel,stdlib]}, {env,[]}, {modules,[]}]}.
In fixtures, you have a top-level application that can have multiple applications as dependencies. When the armature retrieves these dependencies, it places them in the deps directory. If any of these applications has its own dependencies, they are also extracted to the deps directory, etc. There is no infinitely nested deps directory hierarchy.