problems getting started with sbt

16 views
Skip to first unread message

Russ P.

unread,
Dec 22, 2009, 4:01:37 PM12/22/09
to simple-build-tool
I am learning Scala, and I am having problems getting sbt to work. I
tried to follow the online instructions, but I must be missing
something -- probably something that should be obvious.

I am on Red Hat 5, and I am using Scala 2.8 with the latest
experimental sbt. I set up a directory with the required structure and
several Scala source files in the src/main/scala directory. My sbt
script is an exact copy of the script shown on the Setup page. I
created a "Hello World" task very similar to the example:

import sbt._

class MyProject(info: ProjectInfo) extends DefaultProject(info) {
lazy val hi = task { println("Hello, Worlds"); None }
}

It prints it's message just fine. Here is where I am stuck. Shouldn't
I be able to type

> sbt compile

and have my source files compile? When I type that, it says "Nothing
to compile," and nothing gets compiled. What step did I miss? Thanks.

Russ P.

Mark Harrah

unread,
Dec 23, 2009, 12:54:56 AM12/23/09
to simple-b...@googlegroups.com
Hi Russ,

If you have already compiled your sources, you might see something like:

[info] == compile ==
[info] Source analysis: 0 new/modified, 0 indirectly invalidated, 0 removed.
[info] Compiling main sources...
[info] Nothing to compile.
[info] Post-analysis: 2 classes.
[info] == compile ==

Note the Post-analysis: 2 classes, which means that your sources were already
compiled. The 0 modified, etc... mean all sources are uptodate.

If you see Post-analysis: 0 classes, I'm not sure what the problem is. You
could zip up your project (no need to include project/boot), post it to the
files section [1], and I'll see if it works for me.

Thanks,
Mark

[1] http://groups.google.com/group/simple-build-tool/files

Russ Paielli

unread,
Dec 23, 2009, 1:47:45 AM12/23/09
to simple-b...@googlegroups.com
Thanks for the reply. I see what the problem was. I was looking in the source directory for the class files, but I just realized they are under the target directory.

--Russ



--

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.





--
http://RussP.us

Russ Paielli

unread,
Dec 25, 2009, 12:22:40 AM12/25/09
to simple-b...@googlegroups.com
Now I'm trying to figure out how to use sbt to automatically run tests. Every step seems to baffle me. A few examples in the documentation would be helpful.

I have everything set up, with a couple of tests in the src/test/scala directory, and I successfully compiled them with

    sbt test-compile

Then I ran

    sbt test

and it said "no tests to run." The docs say this "Runs all tests detected during compilation." How do I tell it which tests to run? Do I need to put something in my project file? Thanks.

Russ P.
--
http://RussP.us

Seth Tisue

unread,
Dec 25, 2009, 9:20:49 AM12/25/09
to simple-b...@googlegroups.com
>>>>> "Russ" == Russ Paielli <russ.p...@gmail.com> writes:

Russ> Now I'm trying to figure out how to use sbt to automatically run
Russ> tests. Every step seems to baffle me. A few examples in the
Russ> documentation would be helpful.
Russ> I have everything set up, with a couple of tests in the
Russ> src/test/scala directory, and I successfully compiled them with
Russ> sbt test-compile
Russ> Then I ran
Russ> sbt test
Russ> and it said "no tests to run." The docs say this "Runs all tests
Russ> detected during compilation." How do I tell it which tests to
Russ> run? Do I need to put something in my project file? Thanks.

What do your tests look like? Which test framework are you using?

--
Seth Tisue @ Northwestern University | http://tisue.net
lead developer, NetLogo: http://ccl.northwestern.edu/netlogo/

Russ Paielli

unread,
Dec 25, 2009, 1:40:32 PM12/25/09
to simple-b...@googlegroups.com
At this point, my tests are just Scala files with a "main" method and lots of "asserts." The code I am testing has no main method, by the way. It is just "library" code.

--

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.





--
http://RussP.us

Josh Cough

unread,
Dec 25, 2009, 2:14:51 PM12/25/09
to simple-b...@googlegroups.com
in that case you should be able to run the test-run task at the sbt console.
or sbt test-run from bash or whatever. 

test-run finds classes with main methods in the test sources. 
test runs subclasses of the test frameworks (scalatest, specs, scalacheck and more can be added)

let us know if that works, and if you want to move to one of the test frameworks we can help with that too.

Josh Cough

unread,
Dec 25, 2009, 2:20:36 PM12/25/09
to simple-b...@googlegroups.com
oh i should have said that test-run only works of youre using the 0.6.x line, sorry. if youre using the old 0.5.x sbt line, youll have to migrate your tests to one of the test frameworks before youll be able to run them.

Russ P.

unread,
Dec 29, 2009, 11:20:22 PM12/29/09
to simple-build-tool
Hey, test-run worked fine. Thanks.

Here's another question. Mark told me how to run sbt with Scala 2.8
RC5. When I did that, sbt must have automatically installed that
version of Scala for me, but I can't find it. Can someone give me a
clue where to find it so I can make it my default Scala version?
Thanks.

Russ P.


On Dec 25, 11:14 am, Josh Cough <joshco...@gmail.com> wrote:
> in that case you should be able to run the test-run task at the sbt console.
> or sbt test-run from bash or whatever.
>
> test-run finds classes with main methods in the test sources.
> test runs subclasses of the test frameworks (scalatest, specs, scalacheck
> and more can be added)
>
> let us know if that works, and if you want to move to one of the test
> frameworks we can help with that too.
>

> On Fri, Dec 25, 2009 at 12:40 PM, Russ Paielli <russ.paie...@gmail.com>wrote:
>
> > At this point, my tests are just Scala files with a "main" method and lots
> > of "asserts." The code I am testing has no main method, by the way. It is
> > just "library" code.
>

> > On Fri, Dec 25, 2009 at 6:20 AM, Seth Tisue <s...@tisue.net> wrote:


>
> >> >>>>> "Russ" == Russ Paielli <russ.paie...@gmail.com> writes:
>
> >>  Russ> Now I'm trying to figure out how to use sbt to automatically run
> >>  Russ> tests.  Every step seems to baffle me. A few examples in the
> >>  Russ> documentation would be helpful.
> >>  Russ> I have everything set up, with a couple of tests in the
> >>  Russ> src/test/scala directory, and I successfully compiled them with
> >>  Russ>     sbt test-compile
> >>  Russ> Then I ran
> >>  Russ>     sbt test
> >>  Russ> and it said "no tests to run." The docs say this "Runs all tests
> >>  Russ> detected during compilation." How do I tell it which tests to
> >>  Russ> run? Do I need to put something in my project file? Thanks.
>
> >> What do your tests look like?  Which test framework are you using?
>
> >> --
> >> Seth Tisue @ Northwestern University |http://tisue.net
> >> lead developer, NetLogo:http://ccl.northwestern.edu/netlogo/
>
> >> --
>
> >> 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<simple-build-tool%2Bunsu...@googlegroups.com>


> >> .
> >> For more options, visit this group at
> >>http://groups.google.com/group/simple-build-tool?hl=en.
>
> > --
> >http://RussP.us
>
> > --
> > 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<simple-build-tool%2Bunsu...@googlegroups.com>

Josh Cough

unread,
Dec 29, 2009, 11:41:30 PM12/29/09
to simple-b...@googlegroups.com
Here's a directory listing for one of my projects. sbt puts the files under project/boot.

~/intellij-workspace/interpreter (master)
$ ls project/boot/scala-2.8.0.Beta1-RC5/lib/scala-*
project/boot/scala-2.8.0.Beta1-RC5/lib/scala-compiler.jar
project/boot/scala-2.8.0.Beta1-RC5/lib/scala-library.jar

However, it doesn't download the full distribution, and so you won't have a scala executable to run directly, if thats what you were looking for. That's to the best of my knowledge at least.

To unsubscribe from this group, send email to simple-build-t...@googlegroups.com.

Seth Tisue

unread,
Dec 30, 2009, 9:36:08 AM12/30/09
to simple-b...@googlegroups.com
>>>>> "Russ" == Russ P <russ.p...@gmail.com> writes:

Russ> Hey, test-run worked fine. Thanks. Here's another question. Mark
Russ> told me how to run sbt with Scala 2.8 RC5. When I did that, sbt
Russ> must have automatically installed that version of Scala for me,
Russ> but I can't find it. Can someone give me a clue where to find it
Russ> so I can make it my default Scala version? Thanks.

It only pulls down the compiler and library jars (to
project/boot/scala-2.8.0.Beta1-RC5/lib), not the entire distribution.

Mohamed Bana

unread,
Dec 30, 2009, 10:03:36 AM12/30/09
to simple-b...@googlegroups.com, Josh Cough
You might be able to run Scala from the command line once you've figured out were the jars are downloaded by

  java -classpath <scala-jars> scala.tools.nsc.MainGenericRunner -classpath <runtime-classpath>

e.g., scala-jars = project/boot/scala-2.8.0.Beta1-RC5/lib/

—Mohamed

Russ P.

unread,
Jan 1, 2010, 3:45:32 AM1/1/10
to simple-build-tool
I usually run my terminals with a black background. sbt uses a dark
blue for some of its output, and it is almost impossible to read on a
black background. How can I change that text to a lighter color?
Thanks.

Russ P.

Mark Harrah

unread,
Jan 2, 2010, 12:05:46 PM1/2/10
to simple-b...@googlegroups.com

sbt uses ANSI escape sequences. The exact color of blue is set by your
terminal, which you can probably configure there.

-Mark

Reply all
Reply to author
Forward
0 new messages