[sbt] Scala continuations plugin with SBT?

355 views
Skip to first unread message

Oliver Schulz

unread,
Apr 25, 2010, 9:34:48 AM4/25/10
to simple-b...@googlegroups.com
Does anyone know how to enable the continuations compiler plugin included with
recent Scala versions (> 2.8.0.RC1) in SBT?

It's usually enabled with

scala -P:continuations:enable

resp.

scalac -P:continuations:enable

However

override def compileOptions = super.compileOptions ++ Seq(CompileOption("-P:continuations:enable"))

in the project definition for SBT doesn't seem to work, resulting in

[error] bad option: -P:continuations:enable

on sbt compile and the plugin not being enabled on the sbt console either.

I guess I'm going about it the wrong way - any ideas?


Cheers,

Oliver

--
You received this message because you are subscribed to the Google Groups "simple-build-tool" group.
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.

Josh Suereth

unread,
Apr 25, 2010, 12:00:23 PM4/25/10
to simple-b...@googlegroups.com
You need to add the compiler plugin to scala via a -X option (or SBT's built in scalac plugin features).   This is because SBT does not use the SCALA_HOME environment like a normal scala distribution (similarly with ANT/Maven - depending on your setup).

I forgot the syntax off the top of my head for scalac plugins in SBT, but I'm sure someone else can back me up here.  I had a continuations SBT project setup, however not on this computer...   Sorry for the lame response ;)


- Josh

Nathan

unread,
Apr 25, 2010, 12:46:01 PM4/25/10
to simple-build-tool
On Apr 25, 9:34 am, Oliver Schulz <oliver.sch...@tu-dortmund.de>
wrote:
> Does anyone know how to enable the continuations compiler plugin included with
> recent Scala versions (> 2.8.0.RC1) in SBT?

Here's an example:
http://github.com/n8han/spde-examples/blob/master/project/build/ExamplesProject.scala#L9

Nathan

Mark Harrah

unread,
Apr 25, 2010, 12:58:14 PM4/25/10
to simple-b...@googlegroups.com
On Sunday 25 April 2010, Nathan wrote:
> On Apr 25, 9:34 am, Oliver Schulz <oliver.sch...@tu-dortmund.de>
> wrote:
> > Does anyone know how to enable the continuations compiler plugin included with
> > recent Scala versions (> 2.8.0.RC1) in SBT?
>
> Here's an example:
> http://github.com/n8han/spde-examples/blob/master/project/build/ExamplesProject.scala#L9

Cool, thanks. I added it as an example on the compiler plugins page[1].

-Mark

[1] http://code.google.com/p/simple-build-tool/wiki/CompilerPlugins

oschulz

unread,
Apr 26, 2010, 10:01:09 AM4/26/10
to simple-build-tool
Thanks, looks like I was missing

... with AutoCompilerPlugins

and

val cont = compilerPlugin("org.scala-lang.plugins" %
"continuations" % "2.8.0.RC1")

Continuations run through the compiler fine now. However, they're
still unavailable in the
console. The following works fine in "scala -P:continuations:enable"

import scala.util.continuations._
reset { val i = shift { body: (Int => Unit) => body(5);
println("done") }; println(i) }

but fails in the SBT console, resulting in a

java.lang.NoSuchMethodError: scala.util.continuations.package
$.shift(Lscala/Function1;)Ljava/lang/Object;
at $anonfun$1.apply$mcV$sp(<console>:14)
at $anonfun$1.apply(<console>:14)
at $anonfun$1.apply(<console>:14)

I'd really love to have continuations available in the SBT console
(not only for testing code). Does anyone
know a way to do it?

Robert Wills

unread,
Apr 26, 2010, 10:12:11 AM4/26/10
to simple-b...@googlegroups.com
I suspect that there's no way to get it to work in the sbt console
unless sbt is itself built with the continuations plugin.

-Rob

Mark Harrah

unread,
Apr 26, 2010, 11:01:27 AM4/26/10
to simple-b...@googlegroups.com
On Monday 26 April 2010 10:01:09 am oschulz wrote:
> Thanks, looks like I was missing
>
> ... with AutoCompilerPlugins
>
> and
>
> val cont = compilerPlugin("org.scala-lang.plugins" %
> "continuations" % "2.8.0.RC1")
>
> Continuations run through the compiler fine now. However, they're
> still unavailable in the
> console. The following works fine in "scala -P:continuations:enable"
>
> import scala.util.continuations._
> reset { val i = shift { body: (Int => Unit) => body(5);
> println("done") }; println(i) }
>
> but fails in the SBT console, resulting in a
>
> java.lang.NoSuchMethodError: scala.util.continuations.package
> $.shift(Lscala/Function1;)Ljava/lang/Object;
> at $anonfun$1.apply$mcV$sp(<console>:14)
> at $anonfun$1.apply(<console>:14)
> at $anonfun$1.apply(<console>:14)
>
> I'd really love to have continuations available in the SBT console
> (not only for testing code). Does anyone
> know a way to do it?

There was an odd omission in sbt- no way to specify options to the console.
I've fixed this and by default consoleOptions = compileOptions. It should work
without further configuration now.

-Mark
Reply all
Reply to author
Forward
0 new messages