Skip to content

Commit

Permalink
Merge pull request #421 from baseballlover723/master
Browse files Browse the repository at this point in the history
Added a configuration option to specify the path of the project plt file
  • Loading branch information
jeremyjh committed Dec 23, 2020
2 parents 96a3a89 + 7fe6cb0 commit 8c1707f
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ Running the mix task `dialyzer` by default builds several PLT files:
* A project environment specific file in _build/env/dialyze_erlang-[OTP Version]_elixir-[Elixir Version]_deps-dev.plt

The core files are simply copied to your project folder when you run `dialyxir` for the first time with a given version of Erlang and Elixir. By default, all
the modules in the project PLT are checked against your dependencies to be sure they are up to date. If you do not want to use MIX_HOME to store your core Erlang and Elixir files, you can provide a :plt_core_path key with a file path. You can specify a different location for the project PLT file with the :plt_file keyword - this is deprecated because people were using it with the old `dialyxir` to have project-specific PLTs, which are now the default. To silence the deprecation warning, specify this value as `plt_file: {:no_warn, "/myproject/mypltfile"}`.
the modules in the project PLT are checked against your dependencies to be sure they are up to date. If you do not want to use MIX_HOME to store your core Erlang and Elixir files, you can provide a :plt_core_path key with a file path. You can specify a different directory for the project PLT file with the :plt_local_path keyword. You can specify a different filename for the project PLT file with the :plt_file keyword - this is deprecated because people were using it with the old `dialyxir` to have project-specific PLTs, which are now the default. To silence the deprecation warning, specify this value as `plt_file: {:no_warn, "/myproject/mypltfile"}`.

The core PLTs include a basic set of OTP applications, as well as all of the Elixir standard libraries.
The apps included by default are `[ :erts, :kernel, :stdlib, :crypto]`.
Expand Down
4 changes: 3 additions & 1 deletion lib/dialyxir/project.ex
Original file line number Diff line number Diff line change
Expand Up @@ -258,9 +258,11 @@ defmodule Dialyxir.Project do
defp core_path(), do: dialyzer_config()[:plt_core_path] || Mix.Utils.mix_home()

defp local_plt(name) do
Path.join(Mix.Project.build_path(), "dialyxir_" <> name <> ".plt")
Path.join(local_path(), "dialyxir_" <> name <> ".plt")
end

defp local_path(), do: dialyzer_config()[:plt_local_path] || Mix.Project.build_path()

defp default_paths() do
reduce_umbrella_children([], fn paths ->
[Mix.Project.compile_path() | paths]
Expand Down
2 changes: 2 additions & 0 deletions lib/mix/tasks/dialyzer.ex
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ defmodule Mix.Tasks.Dialyzer do
* `dialyzer: :plt_file` - Deprecated - specify the plt file name to create and use - default is to create one in the project's current build environmnet (e.g. _build/dev/) specific to the Erlang/Elixir version used. Note that use of this key in version 0.4 or later will produce a deprecation warning - you can silence the warning by providing a pair with key :no_warn e.g. `plt_file: {:no_warn,"filename"}`.
* `dialyzer: :plt_local_path` - specify the plt directory name to create and use - default is the project's current build environmnet (e.g. _build/dev/).
* `dialyzer: :plt_core_path` - specify an alternative to MIX_HOME to use to store the Erlang and Elixir core files.
* `dialyzer: :ignore_warnings` - specify file path to filter well-known warnings.
Expand Down
8 changes: 7 additions & 1 deletion test/dialyxir/project_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,13 @@ defmodule Dialyxir.ProjectTest do

test "Default Project PLT File in _build dir" do
in_project(:default_apps, fn ->
assert Regex.match?(~r/_build.*plt/, Project.plt_file())
assert Regex.match?(~r/_build\/.*plt/, Project.plt_file())
end)
end

test "Can specify a different local PLT path" do
in_project(:alt_local_path, fn ->
assert Regex.match?(~r/dialyzer\/.*plt/, Project.plt_file())
end)
end

Expand Down
7 changes: 7 additions & 0 deletions test/fixtures/alt_local_path/mix.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
defmodule AltLocalPath.Mixfile do
use Mix.Project

def project do
[app: :alt_local_path, version: "1.0.0", dialyzer: [plt_local_path: "dialyzer"]]
end
end

0 comments on commit 8c1707f

Please sign in to comment.