自定义混合任务无法找到"任务"

use*_*213 7 elixir-mix elixir

我有一个任务在lib/mix/tasks/thing.exs

代码是:

defmodule Mix.Tasks.Thing do
  use Mix.Task

  def run(_) do
    IO.puts "hello world"
  end

end
Run Code Online (Sandbox Code Playgroud)

当我跑步mix thingmix Thing我得到The task thing could not be foundThe task Thing could not be found

mix compile事先尝试过跑步,但没有帮助.

我也尝试将这个问题的代码直接放到我的mix.exs中,如该问题所示.我仍然无法执行任务.

Gaz*_*ler 6

需要编译混合任务.如果你重命名lib/mix/tasks/thing.exs,lib/mix/tasks/thing.ex那么它应该工作.

您可以在以下网址阅读有关脚本模式(.exs)的更多信息:http://elixir-lang.org/getting-started/modules.html#scripted-mode