Referencing modules from other mix project

Hello,
I’m pretty new to the Elixir programming language and I’ve encountered an issue. I’m writing an application, that would generate some things during the compile time of the application and that happens via custom annotation.

I already have the generation code, but I would like to set up some tests for that - I’d like to have separate applications that basically get compiled and output the generated things to priv directory.

The problem that I’ve encountered is that I don’t understand how to reference mix project from another directory.

I’d like to have the following structure:

lib
    generator.ex         <- this defines an attribute
tests
    apps
        math
            lib
                math.ex    <-  this references attribute as an annotation
            priv
                generated.txt    <- generation result ends up here
            mix.exs
mix.exs

Sorry if this question is silly, but this is way trickier than in the programming framework that I’m used to (.NET) :slight_smile:

Thanks in advance!

1 Like

You can put the logic in one module (normal runtime functions), test that module, and use a different module to run the same code at compile time.

1 Like

Solved by adding dependency like this:

  defp deps do
    [
      {:generator, path: "..\\..\\..\\"}
    ]
  end

That will only work locally though.

@dimitarvp Is there a similar way for it to work not only locally?