Skip to content

Commit 8161e43

Browse files
committed
Clarify Mix.Project usage
1 parent b2e33b4 commit 8161e43

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

lib/mix/lib/mix/project.ex

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,33 @@ defmodule Mix.Project do
9191
to be part of the configuration returned by `project/0`. This setting also
9292
makes sure Elixir is not added as a dependency to the generated `.app` file or
9393
to the escript generated with `mix escript.build`, and so on.
94+
95+
## Invoking this module
96+
97+
This module contains many functions that return project information and
98+
metadata. However, since Mix is not included nor configured during releases,
99+
we recommend using the functions in this module only inside Mix tasks.
100+
If you need to configure your own app, consider using the application
101+
environment instead. For example, don't do this:
102+
103+
def some_config do
104+
Mix.Project.config()[:some_config]
105+
end
106+
107+
Nor this:
108+
109+
@some_config Mix.Project.config()[:some_config]
110+
111+
Instead, do this:
112+
113+
def some_config do
114+
Application.get_env(:my_app, :some_config)
115+
end
116+
117+
Or this:
118+
119+
@some_config Application.compile_env(:my_app, :some_config)
120+
94121
"""
95122

96123
@doc false

0 commit comments

Comments
 (0)