title: Run custom task automatically before/after standard task
body: <p>I often want to do some customization before one of the standard tasks are run. I realize I can make new tasks that executes existing tasks in the order I want, but I find that cumbersome and the chance that a developer misses that he is supposed to run my-compile instead of compile is big and leads to hard to fix errors.</p>
  
  <p>So I want to define a custom task (say <strong>prepare-app</strong>) and inject it into the dependency tree of the existing tasks (say <strong>package-bin</strong>) so that every time someone invokes <strong>package-bin</strong> my custom tasks is run right before it. </p>
  
  <p>I tried doing this</p>
  
  <pre><code>  def mySettings = {
      inConfig(Compile)(Seq(prepareAppTask &lt;&lt;= packageBin in Compile map { (pkg: File) =&gt;
        // fiddle with the /target folder before package-bin makes it into a jar
      })) ++
      Seq(name := "my project", version := "1.0")
    }
  
    lazy val prepareAppTask = TaskKey[Unit]("prepare-app")
  </code></pre>
  
  <p>but it's not executed automatically by <strong>package-bin</strong> right before it packages the compile output into a jar. So how do I alter the above code to be run at the right time ? </p>
  
  <p>More generally where do I find info about hooking into other tasks like compile and is there a general way to ensure that your own tasks are run before and after a standard tasks are invoked ?.</p>