xsbt: Running a class

6 views
Skip to first unread message

Brian Clapper

unread,
Feb 5, 2010, 9:44:56 PM2/5/10
to simple-b...@googlegroups.com
I'm starting to cut my code over to Scala 2.8, so I'm using xsbt. In one
project, I'm using sbt to invoke the IzPack compiler, and (for lack of a
better way to do it), I'm doing it manually, as follows:

import sbt.Run.{run => runClass}
val izPath = "lib_managed" / "compile" * "*.jar"
val args = List(temp.getPath,
"-h", izPackHome,
"-b", ".",
"-o", ("target"/"install.jar").absolutePath,
"-k", "standard")
runClass("com.izforge.izpack.compiler.Compiler",
izPath.get, args, log)

This worked perfectly in sbt 0.5. It fails with xsbt, and a glance at the
new API docs shows why.

I'm currently poring over the API docs and the code, trying to find the
class or object that will let me do what I used to do with sbt.Run.run().
But I thought maybe someone on the list might already have solved this
problem.

Any takers?
--
Brian Clapper, b...@clapper.org

Mark Harrah

unread,
Feb 5, 2010, 10:12:03 PM2/5/10
to simple-b...@googlegroups.com
Hi Brian,

You can use

runTask("com.izforge.izpack.compiler.Compiler", izPath.get, args)

to create a task or use the 'defaultRunner' member of Project like 'Run' in
0.5.6. I've updated Run so that it should be source compatible with 0.5.6 for
the next release. Thanks for pointing out the problem.

-Mark

Brian Clapper

unread,
Feb 5, 2010, 10:28:04 PM2/5/10
to simple-b...@googlegroups.com
Mark Harrah wrote:
> Hi Brian,
>
> You can use
>
> runTask("com.izforge.izpack.compiler.Compiler", izPath.get, args)
>
> to create a task or use the 'defaultRunner' member of Project like 'Run' in
> 0.5.6. I've updated Run so that it should be source compatible with 0.5.6 for
> the next release. Thanks for pointing out the problem.

Excellent. FYI, runTask(), as shown above, gives me a compiler error. But
defaultRunner.run() works as advertised.
--
Brian Clapper, b...@clapper.org

Mark Harrah

unread,
Feb 5, 2010, 10:36:46 PM2/5/10
to simple-b...@googlegroups.com
On Friday 05 February 2010, Brian Clapper wrote:

Right, sorry. The main class should be wrapped in Some for some reason I
forget, probably compatibility.

-Mark

Brian Clapper

unread,
Feb 6, 2010, 12:33:29 PM2/6/10
to simple-b...@googlegroups.com

Mark,

The project file is here:

http://github.com/bmc/grizzled-scala/blob/master/project/build/GrizzledScalaProject.scala

That's an API. With sbt 0.5.x, I would simply do an "sbt publish-local", and
my other projects could use the most recent (unpublished) version of the API.
That does not appear to be happening now. Now, when other projects reference
the API (example below), I get a download error.

It's entirely possible I'm doing something boneheaded here.

Here's a sample reference:

val grizzled = "org.clapper" %% "grizzled-scala" % "0.3"

--
Brian Clapper, b...@clapper.org

Mark Harrah

unread,
Feb 6, 2010, 5:50:15 PM2/6/10
to simple-b...@googlegroups.com
Brian,

Thanks. There were a couple of issues that needed to be fixed. 'publish-
local' should properly handle the jar for your project now.

-Mark

Reply all
Reply to author
Forward
0 new messages