Currently `mix.exs` is always evaluated when compiling project, even when
it is only dependency. This has its positive side, but also one negative
side: application version need to be hardcoded somewhere, either within
`mix.exs` itself or in some file, commonly `VERSION`. However this has main
disadvantage - keeping all of them in sync, especially when using SCM as
version source. What I am proposing here is to add new function to Mix (I
haven't found proper place for it yet) that will read version from some
known metadata file (for example `hex_metadata.config` file) and if this
file do not exist, then it will fall back to provided callback function, ex.
def project do
[
# …
version: try_cached_version(&version/0),
#…
]
end
def version do
case System.cmd("git", ~w[describe]) do
{version, 0} -> version
_ -> "0.0.0-dev"
end
end
This would allow users to generate version via their project version using
SCM of their choice and would not fail when building project as dependency.
--
You received this message because you are subscribed to the Google Groups
"elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/elixir-lang-core/8c5f6b60-6088-474e-ba94-50927aa23d1f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.