title: Using a custom sbt plugin
body: <p>I've created a new scala project and written an <code>AutoPlugin</code> underneath it in a <code>src/main/scala/com/company/plugin</code> directory and a corresponding namespace.  The plugin code is a cut and paste of <code>HelloPlugin3</code> from [1], however I have changed the names.</p>
  
  <p>Then, in a second sbt project I've updated the <code>project/plugins.sbt</code> file to include my new Hello World plugin.  This second project has other 'business code' in.  When I run sbt in that second project, the plugin is resolved and I've tested that by deleting the jar from underneath the <code>~/.ivy/local/...</code> and then reloading the project and witnessing sbt complain that it can't find the plugin.  When I <code>publishLocal</code> my plugin project again, that error goes away.</p>
  
  <p>So I'm happy that the plugin is resolved and the jar file is not empty because I have checked its contents.</p>
  
  <p>However, when I do an <code>sbt&gt; about</code> my custom plugin isn't listed and the command I was expecting to be available isn't.  ("[error] Not a valid command: hello").  But the other plugin I list in plugins.sbt (io.spray sbt-revolver) does appear in the output.  </p>
  
  <p>Both the plugin project and the second project have <code>scalaVersion  := "2.10.3"</code> specified in their <code>build.sbt</code> files.</p>
  
  <p>I'm using sbt 0.13.6.  Interestingly, and perhaps related, is the sbt command <code>plugins</code> is not apparently valid in this project either, although it works just fine in the plugin project.</p>
  
  <p>What extra step am I missing to make the command available to my second project?  How do I check to see if I've got some particularly messed up sbt config happening?</p>
  
  <p>For convenience, the plugin code is below, but as mentioned, it's a copy from the link underneath it.</p>
  
  <pre><code>package com.company.plugin
  
  import sbt._
  import Keys._
  
  object HelloPlugin extends AutoPlugin {
  
    object autoImport {
      val greeting = settingKey[String]("greeting")
    }
  
    import autoImport._
    override def trigger = allRequirements
    override lazy val buildSettings = Seq(
      greeting := "Hi",
      commands += helloCommand)
    lazy val helloCommand = 
      Command.command("hello") { (state: State) =&gt;
        println("fred")
        state
      }   
  
  }
  </code></pre>
  
  <p>Edit:</p>
  
  <p>The <code>build.sbt</code> for the plugin project as as follows;</p>
  
  <pre><code>sbtPlugin := true
  
  scalaVersion  := "2.10.3"
  
  organization  := "com.company"
  
  name    := "name"
  
  version   := "0.0.1-SNAPSHOT"
  </code></pre>
  
  <p>The only other file I've created in this project is the <code>.scala</code> file for the plugin itself.</p>
  
  <p>[1] <a href="http://www.scala-sbt.org/release/docs/Plugins.html" rel="nofollow">http://www.scala-sbt.org/release/docs/Plugins.html</a> </p>