Since 0.10 removed lib_managed and so broke ensime, I thought, hey,
I might get some of the functionality back and even learn something
about the architecture of my build environment by writing a small
plugin that writes an .ensime file in the project directory that tells
ensime about the classpath for all dependencies. That shouldn't be too
hard, the documentation even contains example code on how to access the
classpath:
// get the full classpath in the 'compile' configuration, or Nil if it isn't defined
val cp: Seq[Attributed[File]] = fullClasspath in (currentRef, Compile) get structure.data getOrElse Nil
Except that that doesn't even compile:
[error] found : Product
[error] required: Seq[sbt.Attributed[sbt.package.File]]
[error] val cp : Seq[Attributed[File]] = fullClasspath in (currentRef, Compile) get structure.data getOrElse Nil
[error] ^
So, how do I get, say, the test classpath?
(And am I the only one who thinks that the current scaladoc is nigh
useless for codebases that rely heavily on implicits? Where does that "in"
come from, and whereever it comes from, it doesn't seem to return anything
with a "get" method...)
- Florian.
--
#!/bin/sh -
set - `type -p $0` 'tr [a-m][n-z]RUXJAKBOZ [n-z][a-m]EH$W/@OBM' fu XUBZRA.fvt\
angher echo;while [ "$5" != "" ];do shift;done;$4 "gbhpu $3;fraqznvy sKunef.q\
r<$3&&frq -a -rc "`$4 "$0"|$1`">$3;rpub 'Jr ner Svt bs Obet.'"|$1|`$4 $2|$1`
On Sat, 18 Jun 2011 14:58:18 +0200
Florian Hars <flo...@hars.de> wrote:
> How do I get at the classpaths in 0.10 ?
>
> Since 0.10 removed lib_managed and so broke ensime, I thought, hey,
> I might get some of the functionality back and even learn something
> about the architecture of my build environment by writing a small
> plugin that writes an .ensime file in the project directory that tells
> ensime about the classpath for all dependencies.
I think this is a good idea. From what I can tell, it is generally the case that plugin authors pick up the underlying concepts. Sorry about the bad documentation though...
> That shouldn't be too
> hard, the documentation even contains example code on how to access the
> classpath:
>
> // get the full classpath in the 'compile' configuration, or Nil if it isn't defined
> val cp: Seq[Attributed[File]] = fullClasspath in (currentRef, Compile) get structure.data getOrElse Nil
>
> Except that that doesn't even compile:
>
> [error] found : Product
> [error] required: Seq[sbt.Attributed[sbt.package.File]]
> [error] val cp : Seq[Attributed[File]] = fullClasspath in (currentRef, Compile) get structure.data getOrElse Nil
> [error] ^
>
> So, how do I get, say, the test classpath?
Sorry, that documentation was clearly incorrect. I've fixed it. You get back a task that you have to run. See the Running Tasks section of Build State[1]. Also, see the IDE plugins linked to on the 0.10 plugins page[2].
> (And am I the only one who thinks that the current scaladoc is nigh
> useless for codebases that rely heavily on implicits? Where does that "in"
> come from, and whereever it comes from, it doesn't seem to return anything
> with a "get" method...)
Yes, the onus is currently on the library author to come up with a good way of documenting it. Scaladoc is more useful for heavy classes. I've tried some things for the settings API, but nothing as simple as I'd like and definitely nothing automated.
-Mark
[1] https://github.com/harrah/xsbt/wiki/Build-State
[2] https://github.com/harrah/xsbt/wiki/sbt-0.10-plugins-list
Oh thanks, that looks good. Now I just have to use part of my
copious spare time to actually write a plugin...
Thanks to the updated documentation I have managed to get at the classpath
and write a little plugin that writes all the ~/.ivy2/cache/...jar paths
to a simple .ensime file. That is not really a final solution for sbt-0.10
support in ensime, but for simple projects it seems to work. Code is there:
https://github.com/fhars/sbt-ensime-plugin
> On Sat, Jun 18, 2011 at 02:58:18PM +0200, Florian Hars wrote:
> > Since 0.10 removed lib_managed and so broke ensime, I thought, hey,
> > I might get some of the functionality back and even learn something
> > about the architecture of my build environment by writing a small
> > plugin that writes an .ensime file in the project directory that tells
> > ensime about the classpath for all dependencies.
>
> Thanks to the updated documentation I have managed to get at the classpath
> and write a little plugin that writes all the ~/.ivy2/cache/...jar paths
> to a simple .ensime file. That is not really a final solution for sbt-0.10
> support in ensime, but for simple projects it seems to work. Code is there:
>
> https://github.com/fhars/sbt-ensime-plugin
Looks good. Consider adding it to the 0.10 plugins list:
https://github.com/harrah/xsbt/wiki/sbt-0.10-plugins-list
-Mark