From 521cc31ab92f116115d5a4ddbe9f2381a7114d72 Mon Sep 17 00:00:00 2001 From: Josh Suereth Date: Fri, 28 Oct 2011 11:40:40 -0400 Subject: [PATCH] Fixed task definition with 1 dependency --- README.md | 2 +- src/main/scala/SimpleTask.scala | 20 ++++++++++++++------ 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index ded43f787..517ad5dca 100644 --- a/README.md +++ b/README.md @@ -123,7 +123,7 @@ or if you need to depend on other keys: simple_task("zomg2") on (name, version) is { (n,v) => println("ZOMG " + n + " = " + v + " !!!!!") } -The DSL currently supports between 2 and 9 dependencies. The DSL does not allow defining tasks on different configurations, although this will be added shortly. +The DSL currently supports between 0 and 9 dependencies. The DSL does not allow defining tasks on different configurations, although this will be added shortly. ### Simple Setttings diff --git a/src/main/scala/SimpleTask.scala b/src/main/scala/SimpleTask.scala index f823be3a2..a48e404de 100644 --- a/src/main/scala/SimpleTask.scala +++ b/src/main/scala/SimpleTask.scala @@ -2,15 +2,18 @@ package sbt.extra.dsl import sbt._ import Scoped._ -import Project.{richInitializeTask,richInitialize} +import Project._ +import Project.Setting /** Represents the new 'id' of a task to define on a project. */ final class TaskId(name: String) { /** Creates a Task that has no dependencies. */ final def is[R: Manifest](f: => R) = TaskKey[R](name) := f - /*final def on[A1](a: ScopedTaskable[A1]): TaskDepend1[A1] = - new TaskDepend1[A1](name, a)*/ + final def on[A1](a: Initialize[Task[A1]]): TaskDepend1Task[A1] = + new TaskDepend1Task[A1](name, a) + final def on[A1](a: Initialize[A1]): TaskDepend1Setting[A1] = + new TaskDepend1Setting[A1](name, a) final def on[A1, A2](a1: ScopedTaskable[A1], a2: ScopedTaskable[A2]): TaskDepend2[A1, A2] = new TaskDepend2[A1, A2](name, a1, a2) final def on[A1, A2, A3](a1: ScopedTaskable[A1], @@ -64,12 +67,17 @@ final class TaskId(name: String) { new TaskDepend9[A1, A2, A3, A4, A5, A6, A7, A8, A9](name, a1, a2, a3, a4, a5, a6, a7, a8, a9) } -/** Represents a not-yet-defined task that has one dependency */ -/*final class TaskDepend1[A1](name: String, a1: ScopedTaskable[A1]) { +final class TaskDepend1Setting[A1](name: String, a1: Initialize[A1]) { final def is[R: Manifest](f: A1 => R): Setting[Task[R]] = { TaskKey[R](name) <<= a1 map f } -}*/ +} +/** Represents a not-yet-defined task that has one dependency */ +final class TaskDepend1Task[A1](name: String, a1: Initialize[Task[A1]]) { + final def is[R: Manifest](f: A1 => R): Setting[Task[R]] = { + TaskKey[R](name) <<= a1 map f + } +} /** Represents a not-yet-defined task that has two dependencies */ final class TaskDepend2[A1, A2](name: String,