mirror of https://github.com/sbt/sbt.git
Move the tuple enrichments into sbt.TupleSyntax
This undeprecates the syntax, but at the same times moves it out of implicit scope, therefore requiring a 'import TupleSyntax._' to opt-in to the old syntax.
This commit is contained in:
parent
c5b21ab9d9
commit
0fe0de5fb3
|
|
@ -82,8 +82,10 @@ sealed abstract class SettingKey[T]
|
|||
|
||||
protected[this] def make[S](other: Initialize[S], source: SourcePosition)(
|
||||
f: (T, S) => T
|
||||
): Setting[T] =
|
||||
): Setting[T] = {
|
||||
import TupleSyntax._
|
||||
set((this, other)(f), source)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -143,8 +145,10 @@ sealed abstract class TaskKey[T]
|
|||
|
||||
private[this] def make[S](other: Initialize[Task[S]], source: SourcePosition)(
|
||||
f: (T, S) => T
|
||||
): Setting[Task[T]] =
|
||||
): Setting[Task[T]] = {
|
||||
import TupleSyntax._
|
||||
set((this, other)((a, b) => (a, b) map f.tupled), source)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -257,7 +261,10 @@ object Scoped {
|
|||
* @param i value to return if this setting doesn't have a value.
|
||||
* @return currently bound setting value, or `i` if unbound.
|
||||
*/
|
||||
final def or[T >: S](i: Initialize[T]): Initialize[T] = (this.?, i)(_ getOrElse _)
|
||||
final def or[T >: S](i: Initialize[T]): Initialize[T] = {
|
||||
import TupleSyntax._
|
||||
(this.?, i)(_ getOrElse _)
|
||||
}
|
||||
|
||||
/**
|
||||
* Like [[?]], but with a call-by-name parameter rather than an existing [[Def.Initialize]].
|
||||
|
|
@ -313,8 +320,10 @@ object Scoped {
|
|||
final class RichInitializeTask[S](i: Initialize[Task[S]]) extends RichInitTaskBase[S, Task] {
|
||||
protected def onTask[T](f: Task[S] => Task[T]): Initialize[Task[T]] = i apply f
|
||||
|
||||
def dependsOn(tasks: AnyInitTask*): Initialize[Task[S]] =
|
||||
def dependsOn(tasks: AnyInitTask*): Initialize[Task[S]] = {
|
||||
import TupleSyntax._
|
||||
(i, Initialize.joinAny[Task](tasks))((thisTask, deps) => thisTask.dependsOn(deps: _*))
|
||||
}
|
||||
|
||||
def failure: Initialize[Task[Incomplete]] = i(_.failure)
|
||||
def result: Initialize[Task[Result[S]]] = i(_.result)
|
||||
|
|
@ -331,17 +340,21 @@ object Scoped {
|
|||
private[this] def nonLocal(
|
||||
tasks: Seq[AnyInitTask],
|
||||
key: AttributeKey[Seq[Task[_]]]
|
||||
): Initialize[Task[S]] =
|
||||
): Initialize[Task[S]] = {
|
||||
import TupleSyntax._
|
||||
(Initialize.joinAny[Task](tasks), i)((ts, i) => i.copy(info = i.info.set(key, ts)))
|
||||
}
|
||||
}
|
||||
|
||||
final class RichInitializeInputTask[S](i: Initialize[InputTask[S]])
|
||||
extends RichInitTaskBase[S, InputTask] {
|
||||
protected def onTask[T](f: Task[S] => Task[T]): Initialize[InputTask[T]] = i(_ mapTask f)
|
||||
|
||||
def dependsOn(tasks: AnyInitTask*): Initialize[InputTask[S]] =
|
||||
def dependsOn(tasks: AnyInitTask*): Initialize[InputTask[S]] = {
|
||||
import TupleSyntax._
|
||||
(i, Initialize.joinAny[Task](tasks))((thisTask, deps) =>
|
||||
thisTask.mapTask(_.dependsOn(deps: _*)))
|
||||
}
|
||||
}
|
||||
|
||||
sealed abstract class RichInitTaskBase[S, R[_]] {
|
||||
|
|
@ -393,22 +406,6 @@ object Scoped {
|
|||
Initialize.joinAny[Task](keys).apply(deps => nop.dependsOn(deps: _*))
|
||||
}
|
||||
|
||||
// format: off
|
||||
|
||||
// this is the least painful arrangement I came up with
|
||||
@deprecated("The sbt 0.10 style DSL is deprecated: '(k1, k2) map { (x, y) => ... }' should now be '{ val x = k1.value; val y = k2.value }'.\nSee http://www.scala-sbt.org/0.13/docs/Migrating-from-sbt-012x.html", "0.13.13") implicit def t2ToTable2[A, B](t2: (ScopedTaskable[A], ScopedTaskable[B])): RichTaskable2[A, B] = new RichTaskable2(t2)
|
||||
@deprecated("The sbt 0.10 style DSL is deprecated: '(k1, k2) map { (x, y) => ... }' should now be '{ val x = k1.value; val y = k2.value }'.\nSee http://www.scala-sbt.org/0.13/docs/Migrating-from-sbt-012x.html", "0.13.13") implicit def t3ToTable3[A, B, C](t3: (ScopedTaskable[A], ScopedTaskable[B], ScopedTaskable[C])): RichTaskable3[A, B, C] = new RichTaskable3(t3)
|
||||
@deprecated("The sbt 0.10 style DSL is deprecated: '(k1, k2) map { (x, y) => ... }' should now be '{ val x = k1.value; val y = k2.value }'.\nSee http://www.scala-sbt.org/0.13/docs/Migrating-from-sbt-012x.html", "0.13.13") implicit def t4ToTable4[A, B, C, D](t4: (ScopedTaskable[A], ScopedTaskable[B], ScopedTaskable[C], ScopedTaskable[D])): RichTaskable4[A, B, C, D] = new RichTaskable4(t4)
|
||||
@deprecated("The sbt 0.10 style DSL is deprecated: '(k1, k2) map { (x, y) => ... }' should now be '{ val x = k1.value; val y = k2.value }'.\nSee http://www.scala-sbt.org/0.13/docs/Migrating-from-sbt-012x.html", "0.13.13") implicit def t5ToTable5[A, B, C, D, E](t5: (ScopedTaskable[A], ScopedTaskable[B], ScopedTaskable[C], ScopedTaskable[D], ScopedTaskable[E])): RichTaskable5[A, B, C, D, E] = new RichTaskable5(t5)
|
||||
@deprecated("The sbt 0.10 style DSL is deprecated: '(k1, k2) map { (x, y) => ... }' should now be '{ val x = k1.value; val y = k2.value }'.\nSee http://www.scala-sbt.org/0.13/docs/Migrating-from-sbt-012x.html", "0.13.13") implicit def t6ToTable6[A, B, C, D, E, F](t6: (ScopedTaskable[A], ScopedTaskable[B], ScopedTaskable[C], ScopedTaskable[D], ScopedTaskable[E], ScopedTaskable[F])): RichTaskable6[A, B, C, D, E, F] = new RichTaskable6(t6)
|
||||
@deprecated("The sbt 0.10 style DSL is deprecated: '(k1, k2) map { (x, y) => ... }' should now be '{ val x = k1.value; val y = k2.value }'.\nSee http://www.scala-sbt.org/0.13/docs/Migrating-from-sbt-012x.html", "0.13.13") implicit def t7ToTable7[A, B, C, D, E, F, G](t7: (ScopedTaskable[A], ScopedTaskable[B], ScopedTaskable[C], ScopedTaskable[D], ScopedTaskable[E], ScopedTaskable[F], ScopedTaskable[G])): RichTaskable7[A, B, C, D, E, F, G] = new RichTaskable7(t7)
|
||||
@deprecated("The sbt 0.10 style DSL is deprecated: '(k1, k2) map { (x, y) => ... }' should now be '{ val x = k1.value; val y = k2.value }'.\nSee http://www.scala-sbt.org/0.13/docs/Migrating-from-sbt-012x.html", "0.13.13") implicit def t8ToTable8[A, B, C, D, E, F, G, H](t8: (ScopedTaskable[A], ScopedTaskable[B], ScopedTaskable[C], ScopedTaskable[D], ScopedTaskable[E], ScopedTaskable[F], ScopedTaskable[G], ScopedTaskable[H])): RichTaskable8[A, B, C, D, E, F, G, H] = new RichTaskable8(t8)
|
||||
@deprecated("The sbt 0.10 style DSL is deprecated: '(k1, k2) map { (x, y) => ... }' should now be '{ val x = k1.value; val y = k2.value }'.\nSee http://www.scala-sbt.org/0.13/docs/Migrating-from-sbt-012x.html", "0.13.13") implicit def t9ToTable9[A, B, C, D, E, F, G, H, I](t9: (ScopedTaskable[A], ScopedTaskable[B], ScopedTaskable[C], ScopedTaskable[D], ScopedTaskable[E], ScopedTaskable[F], ScopedTaskable[G], ScopedTaskable[H], ScopedTaskable[I])): RichTaskable9[A, B, C, D, E, F, G, H, I] = new RichTaskable9(t9)
|
||||
@deprecated("The sbt 0.10 style DSL is deprecated: '(k1, k2) map { (x, y) => ... }' should now be '{ val x = k1.value; val y = k2.value }'.\nSee http://www.scala-sbt.org/0.13/docs/Migrating-from-sbt-012x.html", "0.13.13") implicit def t10ToTable10[A, B, C, D, E, F, G, H, I, J](t10: (ScopedTaskable[A], ScopedTaskable[B], ScopedTaskable[C], ScopedTaskable[D], ScopedTaskable[E], ScopedTaskable[F], ScopedTaskable[G], ScopedTaskable[H], ScopedTaskable[I], ScopedTaskable[J])): RichTaskable10[A, B, C, D, E, F, G, H, I, J] = new RichTaskable10(t10)
|
||||
@deprecated("The sbt 0.10 style DSL is deprecated: '(k1, k2) map { (x, y) => ... }' should now be '{ val x = k1.value; val y = k2.value }'.\nSee http://www.scala-sbt.org/0.13/docs/Migrating-from-sbt-012x.html", "0.13.13") implicit def t11ToTable11[A, B, C, D, E, F, G, H, I, J, K](t11: (ScopedTaskable[A], ScopedTaskable[B], ScopedTaskable[C], ScopedTaskable[D], ScopedTaskable[E], ScopedTaskable[F], ScopedTaskable[G], ScopedTaskable[H], ScopedTaskable[I], ScopedTaskable[J], ScopedTaskable[K])): RichTaskable11[A, B, C, D, E, F, G, H, I, J, K] = new RichTaskable11(t11)
|
||||
|
||||
// format: on
|
||||
|
||||
sealed abstract class RichTaskables[K[L[x]]](final val keys: K[ScopedTaskable])(
|
||||
implicit a: AList[K]
|
||||
) {
|
||||
|
|
@ -489,17 +486,6 @@ object Scoped {
|
|||
protected def convert[M[_], R](z: Fun[M, R]) = z.tupled
|
||||
}
|
||||
|
||||
@deprecated("The sbt 0.10 style DSL is deprecated: '(k1, k2) map { (x, y) => ... }' should now be '{ val x = k1.value; val y = k2.value }'.\nSee http://www.scala-sbt.org/0.13/docs/Migrating-from-sbt-012x.html", "0.13.13") implicit def t2ToApp2[A, B](t2: (Initialize[A], Initialize[B])): Apply2[A, B] = new Apply2(t2)
|
||||
@deprecated("The sbt 0.10 style DSL is deprecated: '(k1, k2) map { (x, y) => ... }' should now be '{ val x = k1.value; val y = k2.value }'.\nSee http://www.scala-sbt.org/0.13/docs/Migrating-from-sbt-012x.html", "0.13.13") implicit def t3ToApp3[A, B, C](t3: (Initialize[A], Initialize[B], Initialize[C])): Apply3[A, B, C] = new Apply3(t3)
|
||||
@deprecated("The sbt 0.10 style DSL is deprecated: '(k1, k2) map { (x, y) => ... }' should now be '{ val x = k1.value; val y = k2.value }'.\nSee http://www.scala-sbt.org/0.13/docs/Migrating-from-sbt-012x.html", "0.13.13") implicit def t4ToApp4[A, B, C, D](t4: (Initialize[A], Initialize[B], Initialize[C], Initialize[D])): Apply4[A, B, C, D] = new Apply4(t4)
|
||||
@deprecated("The sbt 0.10 style DSL is deprecated: '(k1, k2) map { (x, y) => ... }' should now be '{ val x = k1.value; val y = k2.value }'.\nSee http://www.scala-sbt.org/0.13/docs/Migrating-from-sbt-012x.html", "0.13.13") implicit def t5ToApp5[A, B, C, D, E](t5: (Initialize[A], Initialize[B], Initialize[C], Initialize[D], Initialize[E])): Apply5[A, B, C, D, E] = new Apply5(t5)
|
||||
@deprecated("The sbt 0.10 style DSL is deprecated: '(k1, k2) map { (x, y) => ... }' should now be '{ val x = k1.value; val y = k2.value }'.\nSee http://www.scala-sbt.org/0.13/docs/Migrating-from-sbt-012x.html", "0.13.13") implicit def t6ToApp6[A, B, C, D, E, F](t6: (Initialize[A], Initialize[B], Initialize[C], Initialize[D], Initialize[E], Initialize[F])): Apply6[A, B, C, D, E, F] = new Apply6(t6)
|
||||
@deprecated("The sbt 0.10 style DSL is deprecated: '(k1, k2) map { (x, y) => ... }' should now be '{ val x = k1.value; val y = k2.value }'.\nSee http://www.scala-sbt.org/0.13/docs/Migrating-from-sbt-012x.html", "0.13.13") implicit def t7ToApp7[A, B, C, D, E, F, G](t7: (Initialize[A], Initialize[B], Initialize[C], Initialize[D], Initialize[E], Initialize[F], Initialize[G])): Apply7[A, B, C, D, E, F, G] = new Apply7(t7)
|
||||
@deprecated("The sbt 0.10 style DSL is deprecated: '(k1, k2) map { (x, y) => ... }' should now be '{ val x = k1.value; val y = k2.value }'.\nSee http://www.scala-sbt.org/0.13/docs/Migrating-from-sbt-012x.html", "0.13.13") implicit def t8ToApp8[A, B, C, D, E, F, G, H](t8: (Initialize[A], Initialize[B], Initialize[C], Initialize[D], Initialize[E], Initialize[F], Initialize[G], Initialize[H])): Apply8[A, B, C, D, E, F, G, H] = new Apply8(t8)
|
||||
@deprecated("The sbt 0.10 style DSL is deprecated: '(k1, k2) map { (x, y) => ... }' should now be '{ val x = k1.value; val y = k2.value }'.\nSee http://www.scala-sbt.org/0.13/docs/Migrating-from-sbt-012x.html", "0.13.13") implicit def t9ToApp9[A, B, C, D, E, F, G, H, I](t9: (Initialize[A], Initialize[B], Initialize[C], Initialize[D], Initialize[E], Initialize[F], Initialize[G], Initialize[H], Initialize[I])): Apply9[A, B, C, D, E, F, G, H, I] = new Apply9(t9)
|
||||
@deprecated("The sbt 0.10 style DSL is deprecated: '(k1, k2) map { (x, y) => ... }' should now be '{ val x = k1.value; val y = k2.value }'.\nSee http://www.scala-sbt.org/0.13/docs/Migrating-from-sbt-012x.html", "0.13.13") implicit def t10ToApp10[A, B, C, D, E, F, G, H, I, J](t10: (Initialize[A], Initialize[B], Initialize[C], Initialize[D], Initialize[E], Initialize[F], Initialize[G], Initialize[H], Initialize[I], Initialize[J])): Apply10[A, B, C, D, E, F, G, H, I, J] = new Apply10(t10)
|
||||
@deprecated("The sbt 0.10 style DSL is deprecated: '(k1, k2) map { (x, y) => ... }' should now be '{ val x = k1.value; val y = k2.value }'.\nSee http://www.scala-sbt.org/0.13/docs/Migrating-from-sbt-012x.html", "0.13.13") implicit def t11ToApp11[A, B, C, D, E, F, G, H, I, J, K](t11: (Initialize[A], Initialize[B], Initialize[C], Initialize[D], Initialize[E], Initialize[F], Initialize[G], Initialize[H], Initialize[I], Initialize[J], Initialize[K])): Apply11[A, B, C, D, E, F, G, H, I, J, K] = new Apply11(t11)
|
||||
|
||||
def mkTuple2[A, B] = (a: A, b: B) => (a, b)
|
||||
def mkTuple3[A, B, C] = (a: A, b: B, c: C) => (a, b, c)
|
||||
def mkTuple4[A, B, C, D] = (a: A, b: B, c: C, d: D) => (a, b, c, d)
|
||||
|
|
@ -562,6 +548,43 @@ object Scoped {
|
|||
s1.key +: ss.map(_.key)
|
||||
}
|
||||
|
||||
/** The sbt 0.10 style DSL was deprecated in 0.13.13, favouring the use of the '.value' macro.
|
||||
*
|
||||
* See http://www.scala-sbt.org/0.13/docs/Migrating-from-sbt-012x.html for how to migrate.
|
||||
*/
|
||||
trait TupleSyntax {
|
||||
import Scoped._
|
||||
|
||||
// format: off
|
||||
|
||||
// this is the least painful arrangement I came up with
|
||||
implicit def t2ToTable2[A, B](t2: (ScopedTaskable[A], ScopedTaskable[B])): RichTaskable2[A, B] = new RichTaskable2(t2)
|
||||
implicit def t3ToTable3[A, B, C](t3: (ScopedTaskable[A], ScopedTaskable[B], ScopedTaskable[C])): RichTaskable3[A, B, C] = new RichTaskable3(t3)
|
||||
implicit def t4ToTable4[A, B, C, D](t4: (ScopedTaskable[A], ScopedTaskable[B], ScopedTaskable[C], ScopedTaskable[D])): RichTaskable4[A, B, C, D] = new RichTaskable4(t4)
|
||||
implicit def t5ToTable5[A, B, C, D, E](t5: (ScopedTaskable[A], ScopedTaskable[B], ScopedTaskable[C], ScopedTaskable[D], ScopedTaskable[E])): RichTaskable5[A, B, C, D, E] = new RichTaskable5(t5)
|
||||
implicit def t6ToTable6[A, B, C, D, E, F](t6: (ScopedTaskable[A], ScopedTaskable[B], ScopedTaskable[C], ScopedTaskable[D], ScopedTaskable[E], ScopedTaskable[F])): RichTaskable6[A, B, C, D, E, F] = new RichTaskable6(t6)
|
||||
implicit def t7ToTable7[A, B, C, D, E, F, G](t7: (ScopedTaskable[A], ScopedTaskable[B], ScopedTaskable[C], ScopedTaskable[D], ScopedTaskable[E], ScopedTaskable[F], ScopedTaskable[G])): RichTaskable7[A, B, C, D, E, F, G] = new RichTaskable7(t7)
|
||||
implicit def t8ToTable8[A, B, C, D, E, F, G, H](t8: (ScopedTaskable[A], ScopedTaskable[B], ScopedTaskable[C], ScopedTaskable[D], ScopedTaskable[E], ScopedTaskable[F], ScopedTaskable[G], ScopedTaskable[H])): RichTaskable8[A, B, C, D, E, F, G, H] = new RichTaskable8(t8)
|
||||
implicit def t9ToTable9[A, B, C, D, E, F, G, H, I](t9: (ScopedTaskable[A], ScopedTaskable[B], ScopedTaskable[C], ScopedTaskable[D], ScopedTaskable[E], ScopedTaskable[F], ScopedTaskable[G], ScopedTaskable[H], ScopedTaskable[I])): RichTaskable9[A, B, C, D, E, F, G, H, I] = new RichTaskable9(t9)
|
||||
implicit def t10ToTable10[A, B, C, D, E, F, G, H, I, J](t10: (ScopedTaskable[A], ScopedTaskable[B], ScopedTaskable[C], ScopedTaskable[D], ScopedTaskable[E], ScopedTaskable[F], ScopedTaskable[G], ScopedTaskable[H], ScopedTaskable[I], ScopedTaskable[J])): RichTaskable10[A, B, C, D, E, F, G, H, I, J] = new RichTaskable10(t10)
|
||||
implicit def t11ToTable11[A, B, C, D, E, F, G, H, I, J, K](t11: (ScopedTaskable[A], ScopedTaskable[B], ScopedTaskable[C], ScopedTaskable[D], ScopedTaskable[E], ScopedTaskable[F], ScopedTaskable[G], ScopedTaskable[H], ScopedTaskable[I], ScopedTaskable[J], ScopedTaskable[K])): RichTaskable11[A, B, C, D, E, F, G, H, I, J, K] = new RichTaskable11(t11)
|
||||
|
||||
implicit def t2ToApp2[A, B](t2: (Initialize[A], Initialize[B])): Apply2[A, B] = new Apply2(t2)
|
||||
implicit def t3ToApp3[A, B, C](t3: (Initialize[A], Initialize[B], Initialize[C])): Apply3[A, B, C] = new Apply3(t3)
|
||||
implicit def t4ToApp4[A, B, C, D](t4: (Initialize[A], Initialize[B], Initialize[C], Initialize[D])): Apply4[A, B, C, D] = new Apply4(t4)
|
||||
implicit def t5ToApp5[A, B, C, D, E](t5: (Initialize[A], Initialize[B], Initialize[C], Initialize[D], Initialize[E])): Apply5[A, B, C, D, E] = new Apply5(t5)
|
||||
implicit def t6ToApp6[A, B, C, D, E, F](t6: (Initialize[A], Initialize[B], Initialize[C], Initialize[D], Initialize[E], Initialize[F])): Apply6[A, B, C, D, E, F] = new Apply6(t6)
|
||||
implicit def t7ToApp7[A, B, C, D, E, F, G](t7: (Initialize[A], Initialize[B], Initialize[C], Initialize[D], Initialize[E], Initialize[F], Initialize[G])): Apply7[A, B, C, D, E, F, G] = new Apply7(t7)
|
||||
implicit def t8ToApp8[A, B, C, D, E, F, G, H](t8: (Initialize[A], Initialize[B], Initialize[C], Initialize[D], Initialize[E], Initialize[F], Initialize[G], Initialize[H])): Apply8[A, B, C, D, E, F, G, H] = new Apply8(t8)
|
||||
implicit def t9ToApp9[A, B, C, D, E, F, G, H, I](t9: (Initialize[A], Initialize[B], Initialize[C], Initialize[D], Initialize[E], Initialize[F], Initialize[G], Initialize[H], Initialize[I])): Apply9[A, B, C, D, E, F, G, H, I] = new Apply9(t9)
|
||||
implicit def t10ToApp10[A, B, C, D, E, F, G, H, I, J](t10: (Initialize[A], Initialize[B], Initialize[C], Initialize[D], Initialize[E], Initialize[F], Initialize[G], Initialize[H], Initialize[I], Initialize[J])): Apply10[A, B, C, D, E, F, G, H, I, J] = new Apply10(t10)
|
||||
implicit def t11ToApp11[A, B, C, D, E, F, G, H, I, J, K](t11: (Initialize[A], Initialize[B], Initialize[C], Initialize[D], Initialize[E], Initialize[F], Initialize[G], Initialize[H], Initialize[I], Initialize[J], Initialize[K])): Apply11[A, B, C, D, E, F, G, H, I, J, K] = new Apply11(t11)
|
||||
|
||||
// format: on
|
||||
}
|
||||
|
||||
object TupleSyntax extends TupleSyntax
|
||||
|
||||
import Scoped.extendScoped
|
||||
|
||||
/** Constructs InputKeys, which are associated with input tasks to define a setting.*/
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ object FullInstance
|
|||
KeyRanks.DTask)
|
||||
|
||||
def flatten[T](in: Initialize[Task[Initialize[Task[T]]]]): Initialize[Task[T]] = {
|
||||
import Scoped._
|
||||
import Scoped._, TupleSyntax._
|
||||
(in, settingsData, Def.capturedTransformations) {
|
||||
(a: Task[Initialize[Task[T]]], data: Task[SS], f) =>
|
||||
import TaskExtra.multT2Task
|
||||
|
|
@ -63,7 +63,7 @@ object FullInstance
|
|||
}
|
||||
|
||||
def flattenFun[S, T](in: Initialize[Task[S => Initialize[Task[T]]]]): Initialize[S => Task[T]] = {
|
||||
import Scoped._
|
||||
import Scoped._, TupleSyntax._
|
||||
(in, settingsData, Def.capturedTransformations) {
|
||||
(a: Task[S => Initialize[Task[T]]], data: Task[SS], f) => (s: S) =>
|
||||
import TaskExtra.multT2Task
|
||||
|
|
|
|||
|
|
@ -831,16 +831,20 @@ object Project extends ProjectExtra {
|
|||
|
||||
def updateState(f: (State, S) => State): Def.Initialize[Task[S]] = i(t => tx(t, f))
|
||||
|
||||
def storeAs(key: TaskKey[S])(implicit f: JsonFormat[S]): Def.Initialize[Task[S]] =
|
||||
def storeAs(key: TaskKey[S])(implicit f: JsonFormat[S]): Def.Initialize[Task[S]] = {
|
||||
import TupleSyntax._
|
||||
(Keys.resolvedScoped, i)(
|
||||
(scoped, task) =>
|
||||
tx(task,
|
||||
(state, value) =>
|
||||
persistAndSet(resolveContext(key, scoped.scope, state), state, value)(f)))
|
||||
}
|
||||
|
||||
def keepAs(key: TaskKey[S]): Def.Initialize[Task[S]] =
|
||||
def keepAs(key: TaskKey[S]): Def.Initialize[Task[S]] = {
|
||||
import TupleSyntax._
|
||||
(i, Keys.resolvedScoped)((t, scoped) =>
|
||||
tx(t, (state, value) => set(resolveContext(key, scoped.scope, state), state, value)))
|
||||
}
|
||||
}
|
||||
|
||||
import scala.reflect.macros._
|
||||
|
|
|
|||
|
|
@ -0,0 +1,9 @@
|
|||
### Changes with compatibility implications
|
||||
|
||||
- Moves the old, sbt 0.10 tuple enrichement DSL, which was deprecated in sbt 0.13.13, out of implicit scope and
|
||||
to `sbt.TupleSyntax`, so that it is now an opt-in. [#2762][]/[#3291][] by [@dwijnand][]
|
||||
|
||||
[@dwijnand]: https://github.com/dwijnand
|
||||
|
||||
[#2762]: https://github.com/sbt/sbt/issues/2762
|
||||
[#3291]: https://github.com/sbt/sbt/pull/3291
|
||||
|
|
@ -5,14 +5,13 @@ lazy val check = taskKey[Unit]("")
|
|||
|
||||
lazy val root = (project in file(".")).
|
||||
settings(
|
||||
ivyPaths := ((baseDirectory, target)( (dir, t) => IvyPaths(dir, Some(t / "ivy-cache")))).value,
|
||||
ivyPaths := IvyPaths(baseDirectory.value, Some(target.value / "ivy-cache")),
|
||||
publishTo := Some(Resolver.file("Test Publish Repo", file("test-repo"))),
|
||||
resolvers += (baseDirectory { base => "Test Repo" at (base / "test-repo").toURI.toString }).value,
|
||||
moduleName := artifactID,
|
||||
projectID := (baseDirectory { base => (if(base / "retrieve" exists) retrieveID else publishedID) }).value,
|
||||
projectID := (if (baseDirectory.value / "retrieve" exists) retrieveID else publishedID),
|
||||
artifact in (Compile, packageBin) := mainArtifact,
|
||||
libraryDependencies := ((libraryDependencies, baseDirectory) { (deps, base) =>
|
||||
deps ++ (if(base / "retrieve" exists) publishedID :: Nil else Nil) }).value,
|
||||
libraryDependencies ++= (if (baseDirectory.value / "retrieve" exists) publishedID :: Nil else Nil),
|
||||
// needed to add a jar with a different type to the managed classpath
|
||||
unmanagedClasspath in Compile += scalaInstance.map(_.libraryJar).value,
|
||||
classpathTypes := Set(tpe),
|
||||
|
|
@ -35,8 +34,8 @@ def publishedID = org % artifactID % vers artifacts(mainArtifact)
|
|||
def retrieveID = org % "test-retrieve" % "2.0"
|
||||
|
||||
// check that the test class is on the compile classpath, either because it was compiled or because it was properly retrieved
|
||||
def checkTask(classpath: TaskKey[Classpath]) = (classpath in Compile, scalaInstance) map { (cp, si) =>
|
||||
val loader = ClasspathUtilities.toLoader(cp.files, si.loader)
|
||||
def checkTask(classpath: TaskKey[Classpath]) = Def task {
|
||||
val loader = ClasspathUtilities.toLoader((classpath in Compile).value.files, scalaInstance.value.loader)
|
||||
try { Class.forName("test.Test", false, loader); () }
|
||||
catch { case _: ClassNotFoundException | _: NoClassDefFoundError => sys.error("Dependency not retrieved properly") }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
ivyPaths := (baseDirectory, target)( (dir, t) => IvyPaths(dir, Some(t / "ivy-cache"))).value
|
||||
ivyPaths := IvyPaths(baseDirectory.value, Some(target.value / "ivy-cache"))
|
||||
|
||||
libraryDependencies += "org.testng" % "testng" % "5.7" classifier "jdk15"
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
lazy val root = (project in file(".")).
|
||||
settings(
|
||||
ivyPaths := (baseDirectory, target)( (dir, t) => IvyPaths(dir, Some(t / "ivy-cache"))).value,
|
||||
ivyPaths := IvyPaths(baseDirectory.value, Some(target.value / "ivy-cache")),
|
||||
libraryDependencies += baseDirectory(transitive("javax.mail" % "mail" % "1.4.1")).value,
|
||||
TaskKey[Unit]("checkTransitive") := check(true).value,
|
||||
TaskKey[Unit]("checkIntransitive") := check(false).value
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
ivyPaths := (baseDirectory, target)( (dir, t) => IvyPaths(dir, Some(t / "ivy-cache"))).value
|
||||
ivyPaths := IvyPaths(baseDirectory.value, Some(target.value / "ivy-cache"))
|
||||
|
||||
publishMavenStyle := false
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
ivyPaths := (baseDirectory, target)( (dir, t) => IvyPaths(dir, Some(t / "ivy-cache")) ).value
|
||||
ivyPaths := IvyPaths(baseDirectory.value, Some(target.value / "ivy-cache"))
|
||||
|
||||
publishMavenStyle := false
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
lazy val root = (project in file(".")).
|
||||
settings(
|
||||
ivyPaths := (baseDirectory, target)( (dir, t) => IvyPaths(dir, Some(t / "ivy-cache"))).value,
|
||||
ivyPaths := IvyPaths(baseDirectory.value, Some(target.value / "ivy-cache")),
|
||||
libraryDependencies ++= baseDirectory (libraryDeps).value,
|
||||
TaskKey[Unit]("checkForced") := check("1.2.14").value,
|
||||
TaskKey[Unit]("checkDepend") := check("1.2.13").value
|
||||
|
|
|
|||
|
|
@ -2,13 +2,13 @@ import scala.xml._
|
|||
|
||||
lazy val root = (project in file(".")).
|
||||
settings(
|
||||
ivyPaths := (baseDirectory, target)( (dir, t) => IvyPaths(dir, Some(t / "ivy-cache"))).value,
|
||||
ivyXML := ((customInfo, organization, moduleName, version) apply inlineXML).value,
|
||||
ivyPaths := IvyPaths(baseDirectory.value, Some(target.value / "ivy-cache")),
|
||||
ivyXML := inlineXML(customInfo.value, organization.value, moduleName.value, version.value),
|
||||
scalaVersion := "2.9.1",
|
||||
projectID ~= (_ cross false),
|
||||
customInfo := (baseDirectory{_ / "info" exists }).value,
|
||||
customInfo := (baseDirectory.value / "info").exists,
|
||||
TaskKey[Unit]("check-download") := checkDownload.value,
|
||||
delivered := (deliverLocal map XML.loadFile).value,
|
||||
delivered := (XML loadFile deliverLocal.value),
|
||||
TaskKey[Unit]("check-info") := checkInfo.value
|
||||
)
|
||||
|
||||
|
|
@ -16,7 +16,7 @@ lazy val delivered = taskKey[NodeSeq]("")
|
|||
lazy val customInfo = settingKey[Boolean]("")
|
||||
|
||||
def inlineXML(addInfo: Boolean, organization: String, moduleID: String, version: String): NodeSeq =
|
||||
if(addInfo)
|
||||
if (addInfo)
|
||||
(<info organisation={organization} module={moduleID} revision={version}>
|
||||
<license name="Two-clause BSD-style" url="http://github.com/szeiger/scala-query/blob/master/LICENSE.txt" />
|
||||
<description homepage="http://github.com/szeiger/scala-query/">
|
||||
|
|
@ -27,14 +27,19 @@ def inlineXML(addInfo: Boolean, organization: String, moduleID: String, version:
|
|||
else
|
||||
<dependency org="org.scala-tools.testing" name="scalacheck_2.9.1" rev="1.9"/>
|
||||
|
||||
def checkDownload = (dependencyClasspath in Compile) map { cp => if(cp.isEmpty) sys.error("Dependency not downloaded"); () }
|
||||
def checkInfo = (customInfo, delivered) map { (addInfo, d) =>
|
||||
if((d \ "info").isEmpty)
|
||||
sys.error("No info tag generated")
|
||||
else if(addInfo) {
|
||||
if( !deliveredWithCustom(d) ) sys.error("Expected 'license' and 'description' tags in info tag, got: \n" + (d \ "info")) else ()
|
||||
} else
|
||||
if( deliveredWithCustom(d) ) sys.error("Expected empty 'info' tag, got: \n" + (d \ "info")) else ()
|
||||
def checkDownload = Def task {
|
||||
if ((dependencyClasspath in Compile).value.isEmpty) sys.error("Dependency not downloaded"); ()
|
||||
}
|
||||
def deliveredWithCustom(d: NodeSeq) = (d \ "info" \ "license").nonEmpty && (d \ "info" \ "description").nonEmpty
|
||||
|
||||
def checkInfo = Def task {
|
||||
val d = delivered.value
|
||||
val addInfo = customInfo.value
|
||||
if ((d \ "info").isEmpty)
|
||||
sys.error("No info tag generated")
|
||||
else if (addInfo) {
|
||||
if (!deliveredWithCustom(d)) sys.error("Expected 'license' and 'description' tags in info tag, got: \n" + (d \ "info")) else ()
|
||||
} else
|
||||
if (deliveredWithCustom(d)) sys.error("Expected empty 'info' tag, got: \n" + (d \ "info")) else ()
|
||||
}
|
||||
|
||||
def deliveredWithCustom(d: NodeSeq) = (d \ "info" \ "license").nonEmpty && (d \ "info" \ "description").nonEmpty
|
||||
|
|
|
|||
|
|
@ -1,15 +1,14 @@
|
|||
import scala.xml._
|
||||
|
||||
lazy val root = (project in file(".")).
|
||||
settings(
|
||||
readPom := (makePom map XML.loadFile).value,
|
||||
TaskKey[Unit]("checkPom") := checkPom.value,
|
||||
TaskKey[Unit]("checkExtra") := checkExtra.value,
|
||||
TaskKey[Unit]("checkVersionPlusMapping") := checkVersionPlusMapping.value,
|
||||
resolvers += Resolver.sonatypeRepo("snapshots"),
|
||||
makePomConfiguration ~= { _.copy(extra = <extra-tag/>) },
|
||||
libraryDependencies += "com.google.code.findbugs" % "jsr305" % "1.3.+"
|
||||
)
|
||||
lazy val root = (project in file(".")) settings (
|
||||
readPom := (makePom map XML.loadFile).value,
|
||||
TaskKey[Unit]("checkPom") := checkPom.value,
|
||||
TaskKey[Unit]("checkExtra") := checkExtra.value,
|
||||
TaskKey[Unit]("checkVersionPlusMapping") := checkVersionPlusMapping.value,
|
||||
resolvers += Resolver.sonatypeRepo("snapshots"),
|
||||
makePomConfiguration ~= { _.copy(extra = <extra-tag/>) },
|
||||
libraryDependencies += "com.google.code.findbugs" % "jsr305" % "1.3.+"
|
||||
)
|
||||
|
||||
val readPom = TaskKey[Elem]("read-pom")
|
||||
|
||||
|
|
@ -18,18 +17,19 @@ val fakeURL = "http://example.org"
|
|||
val fakeRepo = fakeName at fakeURL
|
||||
def extraTagName = "extra-tag"
|
||||
|
||||
def checkProject(pom: Elem) = if(pom.label != "project") sys.error("Top level element was not 'project': " + pom.label)
|
||||
def checkProject(pom: Elem) =
|
||||
if (pom.label != "project") sys.error("Top level element was not 'project': " + pom.label)
|
||||
|
||||
def withRepositories[T](pomXML: Elem)(f: NodeSeq => T) =
|
||||
{
|
||||
def withRepositories[T](pomXML: Elem)(f: NodeSeq => T) = {
|
||||
val repositoriesElement = pomXML \ "repositories"
|
||||
if(repositoriesElement.size == 1) f(repositoriesElement) else sys.error("'repositories' element not found in generated pom")
|
||||
if (repositoriesElement.size == 1) f(repositoriesElement)
|
||||
else sys.error("'repositories' element not found in generated pom")
|
||||
}
|
||||
|
||||
lazy val checkExtra = readPom map { pomXML =>
|
||||
checkProject(pomXML)
|
||||
val extra = pomXML \ extraTagName
|
||||
if(extra.isEmpty) sys.error("'" + extraTagName + "' not found in generated pom.xml.") else ()
|
||||
if (extra.isEmpty) sys.error("'" + extraTagName + "' not found in generated pom.xml.") else ()
|
||||
}
|
||||
|
||||
lazy val checkVersionPlusMapping = (readPom) map { (pomXml) =>
|
||||
|
|
@ -43,8 +43,10 @@ lazy val checkVersionPlusMapping = (readPom) map { (pomXml) =>
|
|||
()
|
||||
}
|
||||
|
||||
lazy val checkPom = (readPom, fullResolvers) map { (pomXML, ivyRepositories) =>
|
||||
lazy val checkPom = Def task {
|
||||
val pomXML = readPom.value
|
||||
checkProject(pomXML)
|
||||
val ivyRepositories = fullResolvers.value
|
||||
withRepositories(pomXML) { repositoriesElement =>
|
||||
val repositories = repositoriesElement \ "repository"
|
||||
val writtenRepositories = repositories.map(read).distinct
|
||||
|
|
@ -54,7 +56,7 @@ lazy val checkPom = (readPom, fullResolvers) map { (pomXML, ivyRepositories) =>
|
|||
|
||||
lazy val explain = (("Written:" +: writtenRepositories) ++ ("Declared:" +: mavenStyleRepositories)).mkString("\n\t")
|
||||
|
||||
if( writtenRepositories != mavenStyleRepositories )
|
||||
if (writtenRepositories != mavenStyleRepositories)
|
||||
sys.error("Written repositories did not match declared repositories.\n\t" + explain)
|
||||
else
|
||||
()
|
||||
|
|
@ -64,9 +66,9 @@ lazy val checkPom = (readPom, fullResolvers) map { (pomXML, ivyRepositories) =>
|
|||
def read(repository: xml.Node): MavenRepository =
|
||||
(repository \ "name").text at normalize((repository \ "url").text)
|
||||
|
||||
def normalize(url: String): String =
|
||||
{
|
||||
val base = uri( url ).normalize.toString
|
||||
if(base.endsWith("/")) base else (base + "/")
|
||||
}
|
||||
def normalize(url: String): String = {
|
||||
val base = uri(url).normalize.toString
|
||||
if (base.endsWith("/")) base else s"$base/"
|
||||
}
|
||||
|
||||
def normalize(repo: MavenRepository): MavenRepository = MavenRepository(repo.name, normalize(repo.root))
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
ivyPaths := (baseDirectory, target)( (dir, t) => IvyPaths(dir, Some(t / ".ivy2"))).value
|
||||
ivyPaths := IvyPaths(baseDirectory.value, Some(target.value / ".ivy2"))
|
||||
|
||||
// not in the default repositories
|
||||
libraryDependencies += "com.sun.jmx" % "jmxri" % "1.2.1"
|
||||
|
|
|
|||
|
|
@ -4,8 +4,10 @@ moduleName := "asdf"
|
|||
|
||||
crossPaths := false
|
||||
|
||||
TaskKey[Unit]("checkName") := ((moduleName, name, packageBin in Compile) map { (module, n, f) =>
|
||||
val path = f.getAbsolutePath
|
||||
assert(path contains module, "Path " + path + " did not contain module name " + module)
|
||||
assert(!path.contains(n), "Path " + path + " contained " + n)
|
||||
}).value
|
||||
TaskKey[Unit]("checkName") := Def task {
|
||||
val path = (packageBin in Compile).value.getAbsolutePath
|
||||
val module = moduleName.value
|
||||
val n = name.value
|
||||
assert(path contains module, s"Path $path did not contain module name $module")
|
||||
assert(!path.contains(n), s"Path $path contained $n")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
ivyPaths := (baseDirectory, target)( (dir, t) => IvyPaths(dir, Some(t / "ivy-cache"))).value
|
||||
ivyPaths := IvyPaths(baseDirectory.value, Some(target.value / "ivy-cache"))
|
||||
|
||||
organization := "org.example"
|
||||
|
||||
|
|
|
|||
|
|
@ -1,10 +1,15 @@
|
|||
autoScalaLibrary := false
|
||||
|
||||
ivyPaths := (baseDirectory, target)( (dir, t) => IvyPaths(dir, Some(t / "ivy-cache"))).value
|
||||
ivyPaths := IvyPaths(baseDirectory.value, Some(target.value / "ivy-cache"))
|
||||
|
||||
ivyScala := ((scalaVersion in update, scalaBinaryVersion in update) { (fv, bv) =>
|
||||
Some(IvyScala(fv, bv, Vector.empty, filterImplicit = false, checkExplicit = false, overrideScalaVersion = false))
|
||||
}).value
|
||||
ivyScala := Some(IvyScala(
|
||||
(scalaVersion in update).value,
|
||||
(scalaBinaryVersion in update).value,
|
||||
Vector.empty,
|
||||
filterImplicit = false,
|
||||
checkExplicit = false,
|
||||
overrideScalaVersion = false
|
||||
))
|
||||
|
||||
InputKey[Unit]("check") := {
|
||||
val args = Def.spaceDelimited().parsed
|
||||
|
|
|
|||
|
|
@ -7,30 +7,28 @@ lazy val root = (project in file(".")).
|
|||
val result = spaceDelimited("<args>").parsed
|
||||
checkPomRepositories(makePom.value, result, streams.value)
|
||||
},
|
||||
makePomConfiguration := ((makePomConfiguration, baseDirectory) { (conf, base) =>
|
||||
conf.copy(filterRepositories = pomIncludeRepository(base, conf.filterRepositories) )
|
||||
}).value,
|
||||
makePomConfiguration := {
|
||||
val conf = makePomConfiguration.value
|
||||
conf.copy(filterRepositories = pomIncludeRepository(baseDirectory.value, conf.filterRepositories))
|
||||
},
|
||||
ivyPaths := baseDirectory( dir => IvyPaths(dir, Some(dir / "ivy-home"))).value
|
||||
)
|
||||
|
||||
val local = "local-maven-repo" at "file://" + (Path.userHome / ".m2" /"repository").absolutePath
|
||||
|
||||
def pomIncludeRepository(base: File, prev: MavenRepository => Boolean): MavenRepository => Boolean =
|
||||
{
|
||||
case r: MavenRepository if (r.name == "local-preloaded") => false
|
||||
case r: MavenRepository if (base / "repo.none" exists) => false
|
||||
case r: MavenRepository if (base / "repo.all" exists) => true
|
||||
case r: MavenRepository => prev(r)
|
||||
}
|
||||
def pomIncludeRepository(base: File, prev: MavenRepository => Boolean): MavenRepository => Boolean = {
|
||||
case r: MavenRepository if (r.name == "local-preloaded") => false
|
||||
case r: MavenRepository if (base / "repo.none" exists) => false
|
||||
case r: MavenRepository if (base / "repo.all" exists) => true
|
||||
case r: MavenRepository => prev(r)
|
||||
}
|
||||
|
||||
def addSlash(s: String): String =
|
||||
s match {
|
||||
case s if s endsWith "/" => s
|
||||
case _ => s + "/"
|
||||
}
|
||||
def addSlash(s: String): String = s match {
|
||||
case s if s endsWith "/" => s
|
||||
case _ => s + "/"
|
||||
}
|
||||
|
||||
def checkPomRepositories(file: File, args: Seq[String], s: TaskStreams)
|
||||
{
|
||||
def checkPomRepositories(file: File, args: Seq[String], s: TaskStreams) {
|
||||
val repositories = scala.xml.XML.loadFile(file) \\ "repository"
|
||||
val extracted = repositories.map { repo => MavenRepository(repo \ "name" text, addSlash(repo \ "url" text)) }
|
||||
val expected = args.map(GlobFilter.apply)
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ lazy val root = (project in file(".")).
|
|||
externalPom(),
|
||||
scalaVersion := "2.9.0-1",
|
||||
check := checkTask.evaluated,
|
||||
managedClasspath in Provided := ((classpathTypes, update) map { (cpts, report) => Classpaths.managedJars(Provided, cpts, report) }).value
|
||||
managedClasspath in Provided := Classpaths.managedJars(Provided, classpathTypes.value, update.value)
|
||||
)
|
||||
|
||||
def checkTask = Def.inputTask {
|
||||
|
|
|
|||
|
|
@ -1,35 +1,21 @@
|
|||
import sbt.Def.Initialize
|
||||
val root = project in file(".")
|
||||
|
||||
lazy val checkPom = taskKey[Unit]("")
|
||||
val subJar = project in file("subJar")
|
||||
|
||||
lazy val root = (project in file(".")).
|
||||
settings(
|
||||
checkPom in ThisBuild := checkPomTask.value
|
||||
)
|
||||
|
||||
lazy val subJar = (project in file("subJar"))
|
||||
|
||||
lazy val subWar = (project in file("subWar")).
|
||||
settings(
|
||||
warArtifact
|
||||
)
|
||||
|
||||
lazy val subParent = (project in file("subParent")).
|
||||
settings(
|
||||
publishArtifact in Compile := false
|
||||
)
|
||||
|
||||
def art(p: ProjectReference) = makePom in p
|
||||
def checkPomTask: Initialize[Task[Unit]] =
|
||||
(art(subJar), art(subWar), art(subParent)) map { (jar, war, pom) =>
|
||||
checkPackaging(jar, "jar")
|
||||
checkPackaging(war, "war")
|
||||
checkPackaging(pom, "pom")
|
||||
}
|
||||
|
||||
def checkPackaging(pom: File, expected: String) =
|
||||
{
|
||||
val packaging = (xml.XML.loadFile(pom) \\ "packaging").text
|
||||
if(packaging != expected) sys.error("Incorrect packaging for '" + pom + "'. Expected '" + expected + "', but got '" + packaging + "'")
|
||||
}
|
||||
def warArtifact = artifact in (Compile, packageBin) ~= (_ withType "war" withExtension "war")
|
||||
val subWar = project in file("subWar") settings warArtifact
|
||||
|
||||
val subParent = project in file("subParent") settings (publishArtifact in Compile := false)
|
||||
|
||||
val checkPom = taskKey[Unit]("")
|
||||
checkPom in ThisBuild := {
|
||||
checkPackaging((makePom in subJar).value, "jar")
|
||||
checkPackaging((makePom in subWar).value, "war")
|
||||
checkPackaging((makePom in subParent).value, "pom")
|
||||
}
|
||||
|
||||
def checkPackaging(pom: File, expected: String) = {
|
||||
val packaging = (xml.XML.loadFile(pom) \\ "packaging").text
|
||||
if (packaging != expected)
|
||||
sys error s"Incorrect packaging for '$pom'. Expected '$expected', but got '$packaging'"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
autoScalaLibrary := false
|
||||
|
||||
ivyPaths := (baseDirectory, target)( (dir, t) => IvyPaths(dir, Some(t / "ivy-cache"))).value
|
||||
ivyPaths := IvyPaths(baseDirectory.value, Some(target.value / "ivy-cache"))
|
||||
|
||||
libraryDependencies ++= Seq(
|
||||
"org.sat4j" % "org.sat4j.pb" % "2.3.1",
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import sbt.internal.inc.classpath.ClasspathUtilities
|
|||
|
||||
lazy val root = (project in file(".")).
|
||||
settings(
|
||||
ivyPaths := (baseDirectory, target)( (dir, t) => IvyPaths(dir, Some(t / "ivy-cache"))).value,
|
||||
ivyPaths := IvyPaths(baseDirectory.value, Some(target.value / "ivy-cache")),
|
||||
libraryDependencies += "org.jsoup" % "jsoup" % "1.9.1" % Test from "http://jsoup.org/packages/jsoup-1.9.1.jar",
|
||||
ivyLoggingLevel := UpdateLogging.Full,
|
||||
TaskKey[Unit]("checkInTest") := checkClasspath(Test).value,
|
||||
|
|
|
|||
|
|
@ -1,11 +1,12 @@
|
|||
scalaSource in Configurations.Compile := sourceDirectory( _ / " scala test " ).value
|
||||
scalaSource in Configurations.Compile := (sourceDirectory.value / " scala test ")
|
||||
javaSource in Configurations.Compile := (sourceDirectory.value / " java test ")
|
||||
|
||||
javaSource in Configurations.Compile := sourceDirectory( _ / " java test " ).value
|
||||
|
||||
TaskKey[Unit]("init") := ((scalaSource in Configurations.Compile, javaSource in Configurations.Compile) map { (ss, js) =>
|
||||
import IO._
|
||||
createDirectories(ss :: js :: Nil)
|
||||
copyFile(file("changes") / "Test.scala", ss / " Test s.scala")
|
||||
copyFile(file("changes") / "A.java", js / "a" / "A.java")
|
||||
delete(file("changes"))
|
||||
}).value
|
||||
TaskKey[Unit]("init") := {
|
||||
val ss = (scalaSource in Configurations.Compile).value
|
||||
val js = ( javaSource in Configurations.Compile).value
|
||||
import IO._
|
||||
createDirectories(ss :: js :: Nil)
|
||||
copyFile(file("changes") / "Test.scala", ss / " Test s.scala")
|
||||
copyFile(file("changes") / "A.java", js / "a" / "A.java")
|
||||
delete(file("changes"))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import java.util.jar.{Attributes, Manifest}
|
||||
import Path.makeString
|
||||
import java.util.jar.{Attributes, Manifest}
|
||||
import Path.makeString
|
||||
|
||||
name := "Jar Manifest Test"
|
||||
|
||||
|
|
@ -9,12 +9,11 @@ crossPaths := false
|
|||
|
||||
mainClass := Some("jartest.Main")
|
||||
|
||||
packageOptions in (Compile, packageBin) := ((packageOptions in (Compile, packageBin), scalaInstance) map { (opts, si) =>
|
||||
def manifestExtra =
|
||||
{
|
||||
val mf = new Manifest
|
||||
mf.getMainAttributes.put(Attributes.Name.CLASS_PATH, makeString(si.libraryJar :: Nil) )
|
||||
mf
|
||||
}
|
||||
opts :+ Package.JarManifest(manifestExtra)
|
||||
}).value
|
||||
packageOptions in (Compile, packageBin) := {
|
||||
def manifestExtra = {
|
||||
val mf = new Manifest
|
||||
mf.getMainAttributes.put(Attributes.Name.CLASS_PATH, makeString(scalaInstance.value.libraryJar :: Nil))
|
||||
mf
|
||||
}
|
||||
(packageOptions in (Compile, packageBin)).value :+ Package.JarManifest(manifestExtra)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,13 +4,12 @@ version := "0.1"
|
|||
|
||||
crossPaths := false
|
||||
|
||||
packageOptions := ((packageOptions, scalaInstance) map { (opts, si) =>
|
||||
def manifestExtra =
|
||||
{
|
||||
import java.util.jar._
|
||||
val mf = new Manifest
|
||||
mf.getMainAttributes.put(Attributes.Name.CLASS_PATH, si.libraryJar.getAbsolutePath)
|
||||
mf
|
||||
}
|
||||
Package.JarManifest(manifestExtra) +: opts
|
||||
}).value
|
||||
packageOptions := {
|
||||
def manifestExtra = {
|
||||
import java.util.jar._
|
||||
val mf = new Manifest
|
||||
mf.getMainAttributes.put(Attributes.Name.CLASS_PATH, scalaInstance.value.libraryJar.getAbsolutePath)
|
||||
mf
|
||||
}
|
||||
Package.JarManifest(manifestExtra) +: packageOptions.value
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
buildDependencies in Global := ((buildDependencies in Global, thisProjectRef, thisProjectRef in LocalProject("a")) { (deps, refB, refA) =>
|
||||
deps.addClasspath(refA, ResolvedClasspathDependency(refB, None))
|
||||
}).value
|
||||
buildDependencies in Global :=
|
||||
(buildDependencies in Global).value.addClasspath(
|
||||
(thisProjectRef in LocalProject("a")).value,
|
||||
ResolvedClasspathDependency(thisProjectRef.value, None)
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,38 +1,27 @@
|
|||
import sbt.internal.inc.classpath.ClasspathUtilities
|
||||
val rootRef = LocalProject("root")
|
||||
val sub = project
|
||||
val superRoot = project in file("super") dependsOn rootRef
|
||||
|
||||
lazy val superRoot = (project in file("super")).
|
||||
dependsOn(rootRef)
|
||||
val root = project in file(".") dependsOn (sub % "provided->test") settings (
|
||||
TaskKey[Unit]("check") := {
|
||||
check0((fullClasspath in (sub, Test)).value, "sub test", true)
|
||||
check0((fullClasspath in (superRoot, Compile)).value, "superRoot main", false)
|
||||
check0((fullClasspath in (rootRef, Compile)).value, "root main", true)
|
||||
check0((fullClasspath in (rootRef, Runtime)).value, "root runtime", false)
|
||||
check0((fullClasspath in (rootRef, Test)).value, "root test", true)
|
||||
}
|
||||
)
|
||||
|
||||
lazy val root = (project in file(".")).
|
||||
dependsOn(sub % "provided->test").
|
||||
settings(
|
||||
rootSettings
|
||||
)
|
||||
|
||||
lazy val sub = project
|
||||
|
||||
lazy val rootRef = LocalProject("root")
|
||||
|
||||
def rootSettings = (TaskKey[Unit]("check") := checkTask.value)
|
||||
def checkTask = (fullClasspath in (rootRef, Compile), fullClasspath in (rootRef, Runtime), fullClasspath in (rootRef, Test), fullClasspath in (sub, Test), fullClasspath in (superRoot, Compile)) map { (rc, rr, rt, st, pr) =>
|
||||
check0(st, "sub test", true)
|
||||
check0(pr, "superRoot main", false)
|
||||
check0(rc, "root main", true)
|
||||
check0(rr, "root runtime", false)
|
||||
check0(rt, "root test", true)
|
||||
}
|
||||
|
||||
def check0(cp: Seq[Attributed[File]], label: String, shouldSucceed: Boolean): Unit =
|
||||
{
|
||||
def check0(cp: Seq[Attributed[File]], label: String, shouldSucceed: Boolean): Unit = {
|
||||
import sbt.internal.inc.classpath.ClasspathUtilities
|
||||
val loader = ClasspathUtilities.toLoader(cp.files)
|
||||
println("Checking " + label)
|
||||
val err = try { Class.forName("org.example.ProvidedTest", false, loader); None }
|
||||
catch { case e: Exception => Some(e) }
|
||||
|
||||
(err, shouldSucceed) match
|
||||
{
|
||||
(err, shouldSucceed) match {
|
||||
case (None, true) | (Some(_), false) => ()
|
||||
case (None, false) => sys.error("Expected failure")
|
||||
case (Some(x), true) => throw x
|
||||
case (None, false) => sys.error("Expected failure")
|
||||
case (Some(x), true) => throw x
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,5 @@
|
|||
publishTo := (baseDirectory in ThisBuild)(x =>
|
||||
Some(Resolver.file("test-publish", x / "repo/"))
|
||||
).value
|
||||
|
||||
resolvers += (baseDirectory in ThisBuild)(x =>
|
||||
"test" at (x / "repo/").asURL.toString
|
||||
).value
|
||||
|
||||
publishTo := Some(Resolver.file("test-publish", (baseDirectory in ThisBuild).value / "repo/"))
|
||||
resolvers += ("test" at ((baseDirectory in ThisBuild).value / "repo/").asURL.toString)
|
||||
resolvers += Resolver.mavenLocal
|
||||
|
||||
name := "demo1"
|
||||
|
|
|
|||
|
|
@ -1,11 +1,5 @@
|
|||
publishTo := (baseDirectory in ThisBuild)(x =>
|
||||
Some(Resolver.file("test-publish", x / "repo"))
|
||||
).value
|
||||
|
||||
resolvers += (baseDirectory in ThisBuild)(x =>
|
||||
"test" at (x / "repo").asURL.toString
|
||||
).value
|
||||
|
||||
publishTo := Some(Resolver.file("test-publish", (baseDirectory in ThisBuild).value / "repo"))
|
||||
resolvers += ("test" at ((baseDirectory in ThisBuild).value / "repo").asURL.toString)
|
||||
resolvers += Resolver.mavenLocal
|
||||
|
||||
name := "demo2"
|
||||
|
|
|
|||
|
|
@ -7,11 +7,11 @@ lazy val c = proj(project in file("c"))
|
|||
|
||||
def proj(p: Project): Project =
|
||||
p.settings(
|
||||
ivyPaths := (baseDirectory in root, target in root)( (dir, t) => IvyPaths(dir, Some(t / "ivy-cache"))).value,
|
||||
resolvers += (appConfiguration { app => // need this to resolve sbt
|
||||
val ivyHome = Classpaths.bootIvyHome(app) getOrElse sys.error("Launcher did not provide the Ivy home directory.")
|
||||
ivyPaths := IvyPaths((baseDirectory in root).value, Some((target in root).value / "ivy-cache")),
|
||||
resolvers += {
|
||||
val ivyHome = Classpaths.bootIvyHome(appConfiguration.value) getOrElse sys.error("Launcher did not provide the Ivy home directory.")
|
||||
Resolver.file("real-local", ivyHome / "local")(Resolver.ivyStylePatterns)
|
||||
}).value,
|
||||
},
|
||||
resolvers += Resolver.typesafeIvyRepo("releases"), // not sure why this isn't included by default
|
||||
resolvers += Resolver.mavenLocal
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,11 +1,5 @@
|
|||
publishTo := (baseDirectory in ThisBuild)(x =>
|
||||
Some(Resolver.file("test-publish", x / "repo"))
|
||||
).value
|
||||
|
||||
resolvers += (baseDirectory in ThisBuild)(x =>
|
||||
"test" at (x / "repo").asURL.toString
|
||||
).value
|
||||
|
||||
publishTo := Some(Resolver.file("test-publish", (baseDirectory in ThisBuild).value / "repo"))
|
||||
resolvers += ("test" at ((baseDirectory in ThisBuild).value / "repo").asURL.toString)
|
||||
resolvers += Resolver.mavenLocal
|
||||
|
||||
name := "demo3"
|
||||
|
|
|
|||
Loading…
Reference in New Issue