Hello, so we have a private repository https://example.com/event_schema_registry.git
which contains event schemas (as files in JSON schema format) which are used for validating events published to a message broker. It also contains a Ruby gem schema_registry
which uses (depends on) the before-mentioned schema files for validating the events in our Ruby code:
.
├── README.md
├── schemas # Schema files directory
│ ├── # [... snip ...]
│ └── my_event.json
├── ruby # Ruby gem schema_registry
│ ├── # [... snip ...]
│ └── schema_registry.gemspec
└── elixir # The new schema_registry Elixir package
├── # [... snip ...]
└── mix.exs
The ruby gem schema_registry
, located in the /ruby
directory, uses schema files in /schemas
, and when I add this gem to another Ruby projects as a git dependency it works without issues (thanks to bundler magic).
Now I want to write another event validator, but this time in Elixir, so I created a new mix project schema_registry
in the /elixir
directory. If schema files belonged only to the Elixir project, I would put them inside the project’s priv
directory, but alas, they are already used by the Ruby gem, and we don’t want to duplicate them.
The best idea I came up with was creating a symbolic link inside priv
that points to the shared shared schemas directory /schemas
. But it didn’t work when I tried to add schema_registry
as a git dependency to another Elixir project. On my first try time I added schema_registry
like this:
{:schema_registry, git: "https://example.com/event_schema_registry.git"}
but it failed to compile:
Could not compile :schema_registry, no "mix.exs", "rebar.config" or "Makefile" (pass :compile as an option to customize compilation, set it to "false" to do nothing)
On the next try I also added the :sparse
option:
{:schema_registry, git: "https://example.com/event_schema_registry.git", sparse: "elixir"}
This time the project compiled successfully, but schema_registry
doesn’t see any schema file (because now deps/schema_registry/elixir/priv
contains a broken symlink to files that were not checked out).
So the question: is there any way I can bundle shared data with an Elixir package so this package would work as a git-based Mix dependency?