When I try to create the ScalaTest example with this command:
sbt new scala/scalatest-example.g8 fails on TransportException
I get the following:
[info] Set current project to scala (in build file:/Users/chasrmartin/Dropbox/Etudes/Scala/)
[error] org.eclipse.jgit.api.errors.TransportException: git#github.com:scala/scalatest-example.g8.git: Auth fail
[error] at org.eclipse.jgit.api.FetchCommand.call(FetchCommand.java:139)
[error] at org.eclipse.jgit.api.CloneCommand.fetch(CloneCommand.java:193)
I've tried several workarounds from around the next (eg this SO question) to no avail. It would seem this has to be a simple problem, I got this command from a beginners tutorial.
Update
I got this command from https://www.scala-lang.org/documentation/getting-started-sbt-track/testing-scala-with-sbt-on-the-command-line.html
This project doesn't seems to exists anymore.
Instead I would prefer to run with the normal scala-seed.g8
> sbt new scala/scala-seed.g8
And add the test classes manually.
This is an equivalent tutorial with the same classes and tests.
The scala seed template already comes with the structure you want, with the test dependency. You can run sbt test normally.
Related
I have recently revisited a project I have not worked on in over a year. Yesterday I was able to successfully run the REST service with no problems. Today while I was refactoring the location of certain controllers in this project I started to encounter errors related to controllers could not be found within a given package.
My routes file that looks like this:
UserController is defined as such:
However; when trying to compile this project, I receive a list of errors like: (redacted most, only included one controller for sample)
type UserController is not a member of package com.jkdev.controllers
[error] POST /users com.jkdev.controllers.UserController.createUser
Additionally, my Binders are no longer being detected by the routes file as well, so I am seeing errors like: [error] /Users/...../Developer/cashflows/metadata/conf/routes: object binders is not a member of package com.jkdev.
Like I mentioned, yesterday this was working, so I tried reverting to that commit and rebuilding, but this issue persists.
I have attempted to delete all target directories and recompile, ran sbt clean; cleanFiles. All of which provided nothing of value.
Overall this feels like a build error; but I changed nothing about the build file so I have no idea where to look next
The problem was:
I updated the intelliJ SBT preferences to use sbt shell for all builds,tests,runs, etc.
After deleting all of the ./target directories, doing SBT compile and run did not reproduce the target directories for my projects.
After updating IJ SBT preferences to not use SBT shell for builds; I was able to re-compile w/ IJ and reproduce the target directories.
Doing sbt run afterwards successfully launches the server.
I followed the steps for adding integration tests found at http://www.scala-sbt.org/release/docs/Detailed-Topics/Testing#integration-tests.
However, when I run sbt it, see the following:
$ sbt it
[info] Loading project definition from myproj/project
[info] Set current project to myproj (in build file:myproj/)
[error] Not a valid command: it
[error] Not a valid project ID: it
[error] Expected ':' (if selecting a configuration)
[error] Not a valid key: it
[error] it
[error] ^
sbt test works as expected
What's described in Integration Tests is about how to add a new configuration, namely it. There are many configurations available, e.g. Compile, Test, Runtime, Docs, Pom - you can find the default ones as vals in the sbt.Configuration object.
The official documentation of SBT in Selecting the configuration and Scoping by configuration axis should explain why you calling sbt it would require a command or a task with the it name which as it turned out was not the case.
The it configuration binds tasks that you may have used in the other configurations like test be reconfigured so the integration tests are in it directory (rather than in their default one - src/test).
After a bunch of googling, I realized the problem was that integration tests aren't quite the same as tests. To run integration tests, the configuration is slightly different:
sbt it:test
When I do that, everything works fine.
I'm new to Scala and Lift and SBT. I've cloned Ecommerce example from Lift's sample applications.
Now I want to simply run the application.
Documentation says, that container:start should start the app. But I'm getting error:
> container:start
[error] No action named 'container:start' exists.
[info] Execute 'help' for a list of commands or 'actions' for a list of available project actions and methods.
[info]
[info] Total time: 0 s, completed 25.05.2013 16:47:05
I guess that maybe it's because version difference.
[info] using LiftProject with sbt 0.7.5 and Scala 2.7.7
How can I start this application ?
And if it's caused by version difference is it possible to upgrade the application to latest sbt and scala version ?
Update
I've tried to use jetty-start and received another error:
> jetty-start
[error] No action named 'jetty-start' exists.
[info] Execute 'help' for a list of commands or 'actions' for a list of available project actions and methods.
I've also found another similar command jetty-run from sbt help. When I run it I'm getting a huge number of compilation errors. It seems like my scala 2.9.2 cannot compile the code.
This project, as far as I see, uses the old SBT version. The old way to start the web application is:
./sbt
> jetty-start
if you want to reload the app on source change, use ~ jetty-start
Note that there's a far more up to date liftweb project example here: https://github.com/lift/lift_25_sbt
probably sbt did not download the requried jar files.
run the following command
> sbt
> update
now sbt should download the requried jar files
>jetty-run
now sbt should compile and run the web-app.
I have used Scala for about a year and now want to get into Lift.
Following the official site, I got the guide at http://simply.liftweb.net/index-Chapter-2.html#toc-Chapter-2
However, the example does not work. Here is the error I get.
C:\Lift\hello>sbt update ~jetty-run
C:\Lift\hello>set SCRIPT_DIR=C:\scala\bin\
C:\Lift\hello>java -Xmx512M -jar "C:\scala\bin\sbt-launch.jar" update ~jetty-run
[info] Set current project to default-7944be (in build file:/C:/Lift/hello/)
[success] Total time: 0 s, completed 22 Feb, 2012 3:41:06 PM
[error] Not a valid command: jetty-run
[error] Not a valid project ID: jetty-run
[error] Not a valid configuration: jetty-run
[error] Not a valid key: jetty-run (similar: run)
[error] ~jetty-run
[error] ^
I have not used sbt before and prefer not to get sidetracked by having to learn sbt, maven or other stuff. I essentially want a "hello" world application (in this case, the chat application) to start up and running before I do any more digging into Lift.
It is unfortunate that the very first example in the official "getting started" guide is broken. Any ideas what the errors are. I tried the method suggested at http://groups.google.com/group/simple-build-tool/browse_thread/thread/60635edfadbcd816 without any luck
UPDATE
If what you want is just a "hello" world Lift application, I will suggest you download the official Lift 2.4 release here.
After you unzip that file, just cd scala_28\lift_blank or cd scala_29\lift_blank according to what Scala version you would like to use.
Then run sbt update ~jetty-run, this release included correct version and SBT start script for windows.
After this, you should able to browse http://localhost:8080 and get a single web page that has current date and time displayed, a typical Hello World program for web framework.
It seems you are using SBT 0.11 but Simply Lift is using SBT 0.7.x.
SBT has been made a lot of changes from 0.7.x to 0.11, there is no jetty-run command in 0.11.
You should download old SBT version if you just want it work and do not care using a old version SBT.
http://code.google.com/p/simple-build-tool/downloads/list
I think 0.7.7 will work.
It seems like you don't have ./ on your path. I believe all you need to do is go into the chat folder and use the command "./sbt update ~jetty-run" instead of "sbt update ~jetty-run".
It's and old question, but I haven't found that solution anywhere yet:
Seems like in lift 2.5 you should do container:start instead of ~jetty-run, so:
./sbt[enter]
update[enter]
container:start[enter]
My chat app was on http://0.0.0.0:8080
Install SBT 0.11+
Create a folder and follow instructions http://www.assembla.com/wiki/show/liftweb/Using_SBT
Copy src folder of https://github.com/lift/lift_24_sbt/tree/master/scala_29/lift_blank (or lift_basic) in your project folder
cd to your project folder and run sbt.
container:start will start server, container:stop to stop
OR use lifty
The answer: Making stand-alone jar with Simple Build Tool seems like what I need, but it did not have enough information for me, so this is a followup.
(1) How do I adapt the answer to my need? I don't understand what would need to be changed.
(2) What command do I run to create the standalone jar?
(3) Where can I find the jar after it has been created?
What I've tried:
Pasting the code in the linked answer verbatim into my: project/build/dsg.scala file. The file now has a
class ForkRun(info: ProjectInfo) extends DefaultProject(info)
(from before, used for running projects in a separate VM from SBT) and the new:
trait AssemblyProject extends BasicScalaProject
from the linked answer.
I also tried pasting the body (all defs and the lazy val of the AssemblyProject into the body of ForkRun.
To create a jar I ran package at the SBT prompt and get:
[info] Packaging ./target/scala_2.8.1/dsg_2.8.1-1.0.jar ...
[info] Packaging complete.
So I tried running the dsg_2.8.1-1.0.jar from the shell via:
java -jar dsg_2.8.1-1.0.jar
But I get:
Failed to load Main-Class manifest attribute from
dsg_2.8.1-1.0.jar
Could this be caused by having multiple entry points into my project? I select from a list when I execute run from the SBT prompt. Perhaps I need to specify the default when creating the package?
Here's a writeup I did on one way to make an executable jar with SBT:
http://janxspirit.blogspot.com/2011/01/create-executable-scala-jar-with-sbt.html
sbt-assembly is a sbt plugin to create a standalone jar of Scala sbt project with all of its dependencies.
Refer this post for more details with an example.