What is an "Attributed"

311 views
Skip to first unread message

Maxime Lévesque

unread,
Jan 24, 2012, 10:23:42 PM1/24/12
to simple-b...@googlegroups.com

I wanted do add this to a build definition :

   fullClasspath in Runtime <+= baseDirectory.map(bd => bd / "... some file..")

didn't compile, I googled a bit and found I had to do this :

   fullClasspath in Runtime <+= baseDirectory.map(bd => Attributed.blank(bd / "... some file.."))

I'm curious, what is the meaning of  Attributed and blank in this context ?

Thanks

ML

Jason Zaugg

unread,
Jan 25, 2012, 3:16:35 AM1/25/12
to simple-b...@googlegroups.com
Hi Maxime,

Here's the source for Attributed: https://github.com/harrah/xsbt/blob/0.12/util/collection/Attributes.scala

Attributed[T] is a single value of type T, accompanied by a map of metadata. For example, entries in the classpath that correspond to a libraryDependency have the ModuleID stored as metadata.

Let's try it out in console project [1] :

> analytics-utils/console-project
[info] Starting scala interpreter...

scala> val fc = evalTask(fullClasspath in Compile in analyticsUtils, currentState)
warning: there were 1 deprecation warnings; re-run with -deprecation for details
fc: sbt.Keys.Classpath = List(Attributed(C:\code\analytics\analytics-utils\target\classes), Attributed(C:\Users\zgg\.sbt\boot\scala-2.9.1\lib\scala-library.jar), Attributed(C:\Users\zgg\.ivy2\cache\org.scalaz\scalaz-core_2.9.0-1\jars\scalaz-core_2.9.0-1-6.0.1.jar), Attributed(C:\Users\zgg\.ivy2\cache\com.google.guava\guava\jars\guava-r03-EFG.jar), Attributed(C:\Users\zgg\.ivy2\cache\fastutil\fastutil\jars\fastutil-5.1.5.jar), Attributed(C:\Users\zgg\.ivy2\cache\joda-time\joda-time\jars\joda-time-1.6.jar), Attributed(C:\Users\zgg\.ivy2\cache\ch.qos.logback\logback-classic\jars\logback-classic-1.0.0.jar), Attributed(C:\Users\zgg\.ivy2\cache\ch.qos.logback\logback-core\jars\logback-core-1.0.0.jar), Attributed(C:\Users\zgg\.ivy2\cache\org.slf4j\slf4j-api\jars\slf4j-api-1.6.4.jar), Attribute...


scala> fc.map(cp => (cp.data, cp.metadata.keys)).take(5).mkString("\n")
res6: String = 
(C:\code\analytics\analytics-utils\target\classes,Set(analysis))
(C:\Users\zgg\.sbt\boot\scala-2.9.1\lib\scala-library.jar,Set(artifact, module-id, configuration))
(C:\Users\zgg\.ivy2\cache\org.scalaz\scalaz-core_2.9.0-1\jars\scalaz-core_2.9.0-1-6.0.1.jar,Set(artifact, module-id, configuration))
(C:\Users\zgg\.ivy2\cache\com.google.guava\guava\jars\guava-r03-EFG.jar,Set(artifact, module-id, configuration))
(C:\Users\zgg\.ivy2\cache\fastutil\fastutil\jars\fastutil-5.1.5.jar,Set(artifact, module-id, configuration))

scala> fc.map(cp => (cp.data, cp.get(Keys.moduleID.key))).take(5).mkString("\n")
res4: String = 
(C:\code\analytics\analytics-utils\target\classes,None)
(C:\Users\zgg\.sbt\boot\scala-2.9.1\lib\scala-library.jar,Some(org.scala-lang:scala-library:2.9.1))
(C:\Users\zgg\.ivy2\cache\org.scalaz\scalaz-core_2.9.0-1\jars\scalaz-core_2.9.0-1-6.0.1.jar,Some(org.scalaz:scalaz-core_2.9.0-1:6.0.1))
(C:\Users\zgg\.ivy2\cache\com.google.guava\guava\jars\guava-r03-EFG.jar,Some(com.google.guava:guava:r03-EFG))
(C:\Users\zgg\.ivy2\cache\fastutil\fastutil\jars\fastutil-5.1.5.jar,Some(fastutil:fastutil:5.1.5))

Maxime Lévesque

unread,
Jan 25, 2012, 12:51:51 PM1/25/12
to simple-b...@googlegroups.com

Thanks for your explanation, one more dot connected.

2012/1/25 Jason Zaugg <jza...@gmail.com>

--
You received this message because you are subscribed to the Google Groups "simple-build-tool" group.
To view this discussion on the web visit https://groups.google.com/d/msg/simple-build-tool/-/WJY485poFaMJ.
To post to this group, send email to simple-b...@googlegroups.com.
To unsubscribe from this group, send email to simple-build-t...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/simple-build-tool?hl=en.

Reply all
Reply to author
Forward
0 new messages