Run sbt scoverage commande on Scala Play - scala

I have Play project, I am trying to publish the coverage result with scoverage plugin and sbt. Everything works locally but when I try to run the same commands with jenkins it shows following error.
My Jenkins Configuration for sbt is like this:
Also the configuration of build.sbt and plugins.sbt

Are you using the instructions from the github repo ?
sbt clean coverage test
and
sbt coverageReport
should do the work. It seems you are missing a camel case on coveragereport.
you can also have a look at the example they provide
also, is it an open source project we can have a look at? Or just paste the build.sbt and project/plugins.sbt files

Related

Intellij 13.1.3 import project from sbt not working

I have followed the instructions , attempting to either import from build.sbt or open project from build.sbt.
The end result is that the scala libraries are not imported as shown in the screenshot.
I have also tried sbt gen-idea from the command line.
This is just a problem that keeps surfacing..
If you are using Intellij, why don't you create scala sbt project? Then just add the libraries in the build.sbt and refresh the project or re-run the sbt gen-idea. The libraries will appear. See this link:
http://confluence.jetbrains.com/display/IntelliJIDEA/Getting+Started+with+SBT
I STILL have not figured out what the "magic" sequence of actions to follow in order to have a reliable sbt build.
This time around the following worked:
TWICE running
sbt gen-idea
and then import'ing the build.sbt as a new scala project
What did not work
Import project from build.sbt (without sbt gen-idea)
Open project from build.sbt (ditto)
Open build.sbt from Explorer (selecting IJ to open it)

Using sbt 0.13.1, tests won't compile using the generated externalIvyFile

For our Scala development we currently use ivy + ant, but we are also trying to use sbt for our development workflow. This would be for the continuous incremental compilation when not using an IDE.
sbt uses ivy, so in theory this should work. But when using an ivy external file the tests won't compile.
To reproduce this you can even use the generated ivy.xml file from any sbt project.
Here are the steps to reproduce the error on a sbt project with tests,
from the sbt console run deliverLocal (deliver-local in previous versions of sbt)
copy the generated ivy file into your project home and rename it to 'ivy.xml'. From my understanding using this file should be equivalent to declaring the dependencies in build.sbt.
edit the build.sbt, add externalIvyFile() on one line and then comment all dependencies declarations
in the console, run reload, then test
compile will run just fine, but test will fail at compile time. None of the dependencies will be honoured, not even the production code of the current project.
What am I missing?
In my case it worked with the following build.sbt:
externalIvyFile()
classpathConfiguration in Compile := Compile
classpathConfiguration in Test := Test
classpathConfiguration in Runtime := Runtime
You just need the extra three lines in the end. Here is a link for more info: http://www.scala-sbt.org/release/docs/Detailed-Topics/Library-Management.html#ivy-file-dependency-configuration
Look for the Full Ivy Example. I hope it helps!
EDIT: Just to be complete - here is what pointed me to the above link: https://github.com/sbt/sbt/issues/849.

Editing Build.scala in Intellij

I want to migrate our build from maven to SBT, so now I work separatedly on Build.scala file. However I don't benefit from any syntax highlighting (that is quite obvious, I don't have SBT in my classpath). What is the correct way to get SBT to my classpath, adding sbt-launch.jar does not seem to help.
IntelliJ 13 has built-in SBT support; if you're running a lower version, then you can have a look at their sbt plugin.
There's also an sbt plugin on github for generating idea project files. I've had success with running the gen-idea task it provides.
Run sbt gen-idea. It will create a "YOUR_PROJECT_NAME - build" project within your main project (for whatever your YOUR_PROJECT_NAME happens to be). Under the project folder of the build project, I was able to write a Build.scala with the following code:
import sbt._
object Build extends Build {
}
The SBT Build trait is recognized just fine. I'm running IntelliJ 13 build #IU-133-696, Scala plugin 0.30.378.
Eventually what I did is finished to write my build.sbt stub, and opened a project with it. Now everything seem to work.

SBT sources in IDEA

I'm using *.scala files in the project folder for configuring my SBT project. I'm using IDEA12 with the Scala Plugin and sbt-idea for generating the project. After calling gen-idea in the SBT shell, everything works fine except for one thing. When I click go to declaration on some method in my project code, IDEA shows me how it is implemented (redirects me to the library sources). But when I'm trying to "inspect" SBT's internal sources it shows me something like this:
def settings: Seq[Setting[_]] = { /** compiled code **/ }
How can I attach SBT sources to my IDEA project?
I'm using SBT 0.12.3.
In SBT there are two command which may interest you:
update-classifiers - will download all sources and documentation for all libs in your project
update-sbt-classifiers - downloads sbt sources and docs
This will download all the sources you need. To make an IDEA project with them just call gen-idea sbt-classifiers.
If you don't want to call each time this commands for re-generating you project, you should add something like this to your build.sbt: addCommandAlias("make-idea", ";update-classifiers; update-sbt-classifiers; gen-idea sbt-classifiers").
As of sbt version 1.2.8, the command is changed to:
sbt updateClassifiers - to download all sources and docs
sbt updateSbtClassifiers - to download sbt sources and docs.

How to build a jar file out of github project in sbt to be used in a scala program

I am trying to use scala to access Amazon's DynamoDB and found this great package on github https://github.com/piotrga/async-dynamo
so I downloaded the code as a zip file , unzipped it and then did "sbt clean test" and getting the following error
error sbt.ResolveException: unresolved dependency: asyncdynamo#async-dynamo;1.6.0: not found
Questions : is this the correct way to generate a jar file that I can include in my Scala program or is there a better way?
thanks in advance.
EDIT:
just for the benefit of others, the SCALA SBT documentation provides lots of information regarding the build process.
Instead of generating a jar file, you can just run 'sbt publish-local' and then include the lines for the managed dependency in the other project.
Sbt/ivy will see you have the artifact that way you don't need to add the jar to the other project which is much cleaner.
Then for example if you need to update the other project you don't need to replace the jar again - just publish-local again and clean and run your other project!
You are not the only one to have problems with this it seems, see github issues page:
https://github.com/piotrga/async-dynamo/issues
The command 'sbt clean test' will run the tests sbt detects. If you want a .jar file you could use 'sbt clean package', which produces a .jar in the target/ folder.
I cloned the repo and was able to run sbt package after changing release.sbt a bit. I had to change the 'publishTo'-variable as it seemed to depend on the repository creators local environment variable, so I just commented it away.
I did not get the dependency problem, so I suppose it is correctly declared. The tests it tries to run do fail though, but sbt package compiles produces the .jar just fine.
EDIT: As Matthias Schlaipfer pointed out in the comments, the more elegant way(and much easier) would just be to add this as an depency in your build.sbt. From the readme, this is what you need to add:
resolvers += "piotrga" at
"https://github.com/piotrga/piotrga.github.com/tree/master/maven-repo"
libraryDependencies += "asyncdynamo" % "async-dynamo" % "1.6"