Skip to content

Commit

Permalink
Add support for Attributed
Browse files Browse the repository at this point in the history
Fixes sbt#112
  • Loading branch information
dwijnand committed Feb 23, 2018
1 parent b0519a1 commit 15b1cb6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/main/scala/sbtbuildinfo/ScalaRenderer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ abstract class ScalaRenderer extends BuildInfoRenderer {
case TypeExpression("sbt.librarymanagement.ModuleID", Nil) => Some("String")
case TypeExpression("sbt.librarymanagement.Resolver", Nil) => Some("String")

case TypeExpression("sbt.internal.util.Attributed", Seq(TypeExpression("java.io.File", Nil))) => Some("java.io.File")

case TypeExpression("scala.Option", Seq(arg)) =>
tpeToReturnType(arg) map { x => s"scala.Option[$x]" }
case TypeExpression("scala.collection.Seq", Seq(arg)) =>
Expand Down Expand Up @@ -52,6 +54,7 @@ abstract class ScalaRenderer extends BuildInfoRenderer {
case op: Option[_] => op map { x => "scala.Some(" + quote(x) + ")" } getOrElse {"scala.None"}
case url: java.net.URL => "new java.net.URL(%s)" format quote(url.toString)
case file: java.io.File => "new java.io.File(%s)" format quote(file.toString)
case attr: sbt.Attributed[_] => quote(attr.data)
case s => "\"%s\"" format encodeStringLiteral(s.toString)
}

Expand Down
4 changes: 4 additions & 0 deletions src/sbt-test/sbt-buildinfo/simple/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ lazy val root = (project in file(".")).
name := "helloworld",
version := "0.1",
scalaVersion := "2.11.8",
TaskKey[Classpath]("someCp") := Seq(Attributed.blank(file("/tmp/f.txt"))),
buildInfoKeys := BuildInfoKey.ofN(
name,
BuildInfoKey.map(version) { case (n, v) => "projectVersion" -> v.toDouble },
Expand All @@ -18,6 +19,7 @@ lazy val root = (project in file(".")).
"year" -> 2012,
"sym" -> 'Foo,
BuildInfoKey.action("buildTime") { 1234L },
TaskKey[Classpath]("someCp"),
target
),
buildInfoPackage := "hello",
Expand Down Expand Up @@ -57,6 +59,8 @@ lazy val root = (project in file(".")).
""" val sym: scala.Symbol = 'Foo""" ::
""" /** The value is 1234L. */""" ::
""" val buildTime: scala.Long = 1234L""" ::
""" /** The value is scala.collection.Seq(new java.io.File("/tmp/f.txt")). */""" ::
""" val someCp: scala.collection.Seq[java.io.File] = scala.collection.Seq(new java.io.File("/tmp/f.txt"))""" ::
targetInfoComment ::
targetInfo :: // """
""" override val toString: String = {""" ::
Expand Down

0 comments on commit 15b1cb6

Please sign in to comment.