Skip to content

Instantly share code, notes, and snippets.

import sbt._
import std._
class TaskTest extends SingleProject
{
lazy val hello: Task[Unit] =
task { println("Hi!") }
lazy val three: Task[Int] =
task { 3 }
import sbt._
import xsbti.api._
class Single(info: ProjectInfo) extends DefaultProject(info)
{
lazy val allDefs = compile map { _.apis.internal.flatMap(_._2.definitions) }
lazy val modules = allDefs map {
_.collect { case c: ClassLike if c.definitionType == DefinitionType.Module => c.name }
}
}
You'll need 0.9.x set up (probably best to track 0.9 branch at this point):
https://github.com/harrah/xsbt/tree/0.9
$ git clone git://github.com/jorgeortiz85/rogue.git
$ cd rogue/
$ git checkout xsbt
$ xsbt
> compile
...
*** not compiled or checked, just for the idea ***
import sbt._
import Keys._
object MyBuild extends Build
{
... wiring into project not shown, see FullConfiguration for where to put `defaults` ...
val protocExePath = SettingKey[File]("protoc-exe-path")
@harrah
harrah / gist:3866442
Created October 10, 2012 15:42
archive Google Code wiki to HTML, replace old wiki with links to archive
import org.jsoup._
import java.io.{File, FileWriter}
/*
libraryDependencies += "org.jsoup" % "jsoup" % "1.7.1"
scalaVersion := "2.10.0-M7"
*/
object Main {
val WikiSuffix = ".wiki"
val HtmlSuffix = ".html"
@harrah
harrah / DeadlockAvoided.scala
Created February 5, 2013 14:09
Demonstrates "Resource deadlock avoided" exception on a file lock when there is no deadlock.
import java.io._
object A
{
/*
* Starts two concurrent threads that acquire file locks in a timed manner.
* Arguments:
* initialDelayA(ms) lockTimeA(ms) lockFileA initialDelayB(ms) lockTimeB(ms) lockFileB
*
* Example usage: demonstrates "Resource deadlock avoided" when there is no actual deadlock.