How to add a compiler to Mix

Hi all,
I’ve tried to add a compiler to the brand new Elixir project. I’ve created a new file lib/mix/tasks/compile.drab.ex with simple run function:

defmodule Mix.Tasks.Compile.Drab do
  use Mix.Task

  def run(_args) do
    IO.puts "Drab compile"
    :ok
  end
end

Then added it to mix.exs:

  def project do
    [....
     compilers: [:drab] ++ Mix.compilers,
    ....]
  end

Now, I can run mix compile.drab with success:

kim:grych<~/elixir/t>% mix compile.drab
Compiling 2 files (.ex)
Generated t app
Drab compile
kim:grych<~/elixir/t>% mix compile
Drab compile

But, after clean, mix compile it does not work:

kim:grych<~/elixir/t>% mix clean
kim:grych<~/elixir/t>% mix compile
** (Mix) The task "compile.drab" could not be found. Did you mean "compile"?

I can “fix” it by calling mix compile.drab again:

kim:grych<~/elixir/t>% mix compile.drab
Compiling 2 files (.ex)
Generated t app
Drab compile
kim:grych<~/elixir/t>% mix compile
Drab compile

Am I missing something? Checked it with Elixir 1.3.4 and 1.5.0-dev

Solved. Sorry for bothering!
My compiler should go after default compilers!

  def project do
    [....
     compilers: Mix.compilers ++ [:drab],
    ....]
  end
6 Likes