sbt update is not resolving the latest artifacts from repository - scala

My project has few snapshot dependencies in the build.sbt file like this:
Seq("com.asr.project.myproject.urproject" %% "asr-app" % "0.0.0+")
I am executing sbt update to get the latest dependencies.
Prior to this, I have recently published artifacts with latest SNAPSHOT versions for few dependencies.
By the definition sbt update should have checked for the latest dependencies versions on the repository but it doesn't seem to be working like that.

sbt uses coursier plugin to manage the dependency tree and the coursier plugin maintains the lifetime of the artifacts in the cache.
When a dependency is downloaded, it is not going to be checked for any updates for next 24 hours(Default).
This behavior can be altered by setting COURSIER_TTL as an environment variable (e.g export COURSIER_TTL=0s). Running sbt update alone will not have any effect without it. https://get-coursier.io/docs/ttl

Probably what you need is:
libraryDependencies ++= Seq(
"com.asr.project.myproject.urproject" %% "asr-app" % "0.0.+"
)
as described in Ivy revisions, or at Fixed and dynamic revisions with more details.

Related

IntelliJ 13 with SBT plugin does not recognize Scalding dependency

I am trying to add Scalding 2.10 as a managed dependency via build.sbt like so:
name := "ss"
version := "1.0"
libraryDependencies += "com.twitter" % "scalding_2.10" % "0.10.0"
IntelliJ downloads the jar and adds it as an external library (see screen below) but fails to resolve the com.twitter namespace.
I have tried both invalidating the IntelliJ cache and generating project files via sbt gen-idea but neither solutions have worked. Any ideas would be greatly appreciated.
The scalding jar file scalding_2.10 has no code in it to compile against. Its just 300 Bytes in size.
The correct dependency I feel should be
libraryDependencies += "com.twitter" % "scalding-core_2.10" % "0.11.1"
As the comment suggest try rm-ing your ivy2 cache, and try sbt gen-idea. If that doesn't work, other things to check:
makes sure you have indeed got the scala plugin installed.
Most likely you're java SDK is not set or pointing somewhere wrong; right click the project dir, click "Open Module Settings", go to SDK and make sure the path is correctly set to the jdk otherwise syntax highlighting will likely break.
To test your deps have been properly pulled in from tinternet, try sbt compile; if it compiles then you should indeed have downloaded the dependency properly.

Finding resolver and version of dependency, say play-json, in sbt?

Say I want to include a dependency on the play-json library in my sbt file. How and where can I find that information?
I tried searching central repo, play git repository -- couldn't find anything.
First of all, when you want to include a dependency, you've somehow been told about it - about the required version and where to find it. Ask the person this question and you're done. The official source should always be the home page of a dependency.
I'd use http://search.maven.org/ or http://mvnrepository.com/ and pick whatever version is the most current. In your case, however, esp. after the comment where you pointed at Adding Play JSON Library to sbt the answer was right there - in the answers - see https://stackoverflow.com/a/20475410/1305344:
Play 2.2 is out and can be added separately from rest of Play
Framework. in build.sbt:
resolvers += "Typesafe Repo" at "http://repo.typesafe.com/typesafe/releases/"
libraryDependencies += "com.typesafe.play" %% "play-json" % "2.2.1"
The trick is to set up resolvers properly and using the above resolver gives http://repo.typesafe.com/typesafe/releases/com/typesafe/play/play-json_2.10.
When you've got resolvers and any version in your build configuration, you may want to use sbt-updates that's (quoting the plugin's headline) "SBT plugin that can check maven repositories for dependency updates". Quite handy to have it installed as a global plugin, i.e. .sbt/0.13/plugins/sbt-updates.sbt with the following:
resolvers += Classpaths.sbtPluginSnapshots
addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.1.6-SNAPSHOT")
When you execute dependencyUpdates you're told what needs version update.
> dependencyUpdates
[info] Found 1 dependency update for superapp
[info] org.jacoco:org.jacoco.agent:jacoco : 0.6.4.201312101107 -> 0.6.5.201403032054 -> 0.7.0.201403182114
[success] Total time: 1 s, completed 2014-03-28 18:30:12
As you can see, I need to upgrade jacoco.
If the project you depend on releases to some known repositories, running sbt-updates regularly will ultimately tell you about the update. I'd strongly recommend reading RELEASE_NOTES for an update before upgrading since it may be introducing some breaking changes you'd rather know about before going to production.

sbt: cobertura4sbt cannot be found from sbt 0.12

I am about to use cobertura4sbt sbt plugin from maven repository.
I added the following lines to project\plugins.sbt:
resolvers += "Sonatype OSS Snapshots" at "https://oss.sonatype.org/content/groups/scala-tools"
addSbtPlugin("de.johoop" % "cobertura4sbt" % "1.0.0")
However, as I tried to "sbt compile", it always appended my local SBT and Scala version number to the resolving path so that the corresponding pom cannot be found. Do I miss something anywhere?
[warn] ==== Sonatype OSS Snapshots: tried
[warn] https://oss.sonatype.org/content/groups/scala-tools/de/johoop/cobertura4sbt_2.9.2_0.12/1.0.0/cobertura4sbt-1.0.0.pom
[warn] ==== public: tried
cobertura4sbt on sbt 0.7.4
The auto-postfixing of Scala and sbt version was added a while back in sbt to distinguish plugins for different releases of sbt. From this source, cobertura4sbt looks like it was built for 0.7.4, but the author says the plugin is no longer maintained:
This SBT plug-in enables you to measure your code coverage with the help of the great Cobertura tool.
However, since Cobertura is not really actively developed any more, I decided to stop working on this plugin for the time being, and instead started jacoco4sbt. Please ponder using jacoco4sbt instead of this plugin...
jacoco4sbt seems to be available for the latest sbt 0.13.0 too. Either plugin you choose, follow the instruction in the wiki.
jacoco4sbt on sbt 0.12.x
Given the log, I am assuming you're using sbt 0.12.x. jacoco4sbt for sbt 0.12 is published at Sonatype OSS, and the latest seems to be 2.0.0: https://oss.sonatype.org/content/groups/public/de/johoop/jacoco4sbt_2.9.2_0.12/2.0.0/
Try putting this in project/plugins.sbt:
resolvers += Resolver.sonatypeRepo("public")
addSbtPlugin("de.johoop" % "jacoco4sbt" % "2.0.0")
and in jacoco.sbt:
jacoco.settings
This loads jacoco:cover task into sbt shell, which I was able to run and get the report out in target/scala-2.10/jacoco directory.

setting sbt scalafx project

javafx is now in oracle-jdk.
scalafx gives delicious examples in its repository
The main questions I'm not being able to answer is "How to get started with scalafx"?
How can I add scalafx libary dependencies on my sbt project?
ScalaFX is soon to reach a stable release state.
As I write this you can find the published artifacts for version 1.0.0-M2 on the maven central repo
Adding the dependency to your sbt build should suffice
libraryDependencies += "org.scalafx" %% "scalafx" % "1.0.0-M2"
I did it the following way: I cloned the scalafx repository, build the jar using sbt package, then just copied the resulting jar into lib/ directory of my project. Make sure to reference your ${JAVAFX_HOME}/lib/jfxrt.jar as well.
If you want to use local maven, just run sbt publish-local in your scalafx dir, then add the following dependency to your project:
"org.scalafx" % "scalafx" % "1.0-SNAPSHOT"
(Look up that version in scalafx build.sbt, I pasted what was in mine)
#ayvango i have created a giter8 scalafx project template.just use
g8 jugchennai/scalafx.g8
You just need a new version of JDK, Giter8 and SBT. Dependency settings for javafx, scala, scalafx are predefined! IDE support also available.
URL : https://github.com/jugchennai/scalafx.g8

How do I force SBT plugins and plugins to be downloaded through Nexus?

I think that by now I figured out how to force project dependencies to be downloaded through Nexus. (I did that by explicitly setting externalResolvers to a Seq with only one value:
override lazy val settings = super.settings ++ Seq(
externalResolvers := Seq("Nexus repository" at "http://.../nexus/content/groups/public/")
)
However, if I drop my Ivy cache, SBT still accesses a number of public repositories for getting the plugins. Ideally I would like that to go through Nexus as well, to make sure we are not dependent on those repositories to exist forever. (Which they don't.)
Any clues? (I'm on SBT 0.11.2)
sbt 0.12 added Global repository setting for this purpose.
Define the repositories to use by putting a standalone [repositories] section (see the Launcher Specification page) in ~/.sbt/repositories and pass -Dsbt.override.build.repos=true to sbt. Only the repositories in that file will be used by the launcher for retrieving sbt and Scala and by sbt when retrieving project dependencies.