All Downloads are FREE. Search and download functionalities are using the official Maven repository.

sbt.internal.util.ExitHook.scala Maven / Gradle / Ivy

There is a newer version: 0.1.0-M13
Show newest version
/* sbt -- Simple Build Tool
 * Copyright 2009, 2010  Mark Harrah
 */
package sbt.internal.util

/** Defines a function to call as sbt exits.*/
trait ExitHook {
  /** Subclasses should implement this method, which is called when this hook is executed. */
  def runBeforeExiting(): Unit
}
object ExitHook {
  def apply(f: => Unit): ExitHook = new ExitHook { def runBeforeExiting() = f }
}

object ExitHooks {
  /** Calls each registered exit hook, trapping any exceptions so that each hook is given a chance to run. */
  def runExitHooks(exitHooks: Seq[ExitHook]): Seq[Throwable] =
    exitHooks.flatMap(hook =>
      ErrorHandling.wideConvert(hook.runBeforeExiting()).left.toOption)
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy