sbt build failure in jenkins - scala

I am trying to build my project after upgrading to scala 2.12 and sbt 1.3.2. The build is successful in local but failing in my jenkins pipeline. One of the dependency is resolved but not available during compile time. Here are the details
The error I am seeing in jenkins pipeline is
[error] /home/jenkins/agent/workspace/scala-app/src/main/scala/com/org/project/utils/JavaHelper.scala:5:8:
object FutureCallback is not a member of package com.google.common.util.concurrent
[error] import com.google.common.util.concurrent.{FutureCallback, Futures, ListenableFuture}
The associated library is "com.google.guava" % "guava" % "26.0-android".
This dependency is obtained indirectly which I have validated through dependencyTree command.
scala: 2.12.15
sbt: 1.3.2
I even tried declaring the dependency explicitly in build.sbt however the issue still persists. I have tried the build in a clean environment as well (docker container) and it was success.
I am unable to figure out what could be the cause for this issue. Any help is much appreciated.
Thank you

Related

SBT - Dependency missing

I did few changes in build.sbt files of working project. After changes I did sbt clean update it working fine. But While running sbt clean compile it showing compilation errors regarding squants package.
My build.sbt contains
"com.squants" % "squants_2.10" % "0.2.3" % Compile,
And I took the dependency graph tree "dependencyBrowseGraph". It not showing anything regarding squants package. What can I try to resolve this?
It happen because of missing squants library in one of the modules in same project.

SBT: modify the order of dependencies in the classpath

I'm currently experiencing a problem with Specs2 + SBT where my tests always fail via command-line because of dependency order in the classpath. Specs2 requires that the Mockito jars come after the Specs2 jars so that Mockito classes can be overridden to fix issues with by-name scala method parameters (see this issue for more information: https://github.com/etorreborre/specs2/issues/428).
In IntelliJ, I can order my dependencies via the Project Structure/Modules/Dependencies window, which fixes my tests when run inside IntelliJ, however, I have not found a solution to fix this issue when running my tests on the command-line via sbt test.
Does anyone know if it is possible to change the classpath order of dependencies for SBT using settings in build.sbt (or similar)?
To my knowledge you need to make sure that specs2-mock comes before mockito in your libraryDependencies setting.

In an sbt 0.13.7 project, compile the compiler-interfaces without compiling the project code

In a freshly checked out sbt ( 0.3.7 ) project and empty ivy cache, is it possible to trigger compilation of the compiler-interface(s) needed without compiling the project itself? I have poked around but haven't found a way.
Currently if a compiler-interface is required it will be created during compilation of the project. I would like to have this compiled directly in a separate command if possible. This would allow CircleCi to cache it saving 1-3 minutes with every build because it could be cached in the dependencies section of the circle.yml.
In sbt 0.13.12 compile:compileIncremental seems to do the trick. I ran inspect compile and inspected its dependencies to find the command.

Why don't specs2 + scalamock tests run in IntelliJ? Multiple suite traits detected

I'm trying to run Specs2 tests from IDEA from both Windows and Mac versions of Intellij IDEA 14. I generated the idea project files using both gen-idea and the built in SBT plugin and get the same results...
When I try to run them, I get
Error running Specs2 in 'scala': Test class not found
I've added packages and switched "search for tests" to in single module but still no avail. I also get the message below on the run config.
Multiple suite traits detected: List(ScTrait: SpecificationStructure, ScTrait: SpecificationStructure,)
The similar post How to run all Specs2 tests under IntelliJ IDEA? doesn't help and it all runs fine from SBT, BTW. I can't run individual tests via the short-cut either :'(
I'm suspecting it's a combination of scalamock and specs2, as if I remove the following from my build.sbt, I can run them again.
"org.scalamock" %% "scalamock-specs2-support" % "3.2" % "test"
Here's the run config.
You should check if you have multiple specs2 jars dependencies in your module. If you just leave one jar dependency the configuration error should disappear.
To help other googlers, it could also be that you have one package depending on specs2-core, and scalamock-specs2-support which depends on specs2. The solution is to add an explicit dependency on specs2, and both dependencies should be evicted to the one you import. I was just able to fix this with the following dependency: "org.specs2" %% "specs2" % "3.7" % "test"

Compiling my first DSL in Delite

I am trying to follow the tutorial on compiling a simple DSL using Delite+LMS. I compiled LMS and Delite succesfully. Now, following this tutorial closely: http://stanford-ppl.github.io/Delite/myfirstdsl.html I run into problems when I try to build my profiling dsl. It seems that the compiler cannot find the delite-collection classes:
felix#felix-UX32VD:~/Documents/phd/delite/Delite$ sbt compile
Loading /home/felix/sbt/bin/sbt-launch-lib.bash
[info] Loading project definition from /home/felix/Documents/phd/delite/Delite/project
[info] Set current project to delite (in build file:/home/felix/Documents/phd/delite/Delite/)
[info] Compiling 5 Scala sources to /home/felix/Documents/phd/delite/Delite/dsls/profiling/target/scala-2.10/classes...
[error] /home/felix/Documents/phd/delite/Delite/dsls/profiling/src/example/profiling/Profile.scala:7: object DeliteCollection is not a member of package ppl.delite.framework.datastruct.scala
[error] import ppl.delite.framework.datastruct.scala.DeliteCollection
[error] ^
[error] /home/felix/Documents/phd/delite/Delite/dsls/profiling/src/example/profiling/Profile.scala:69: not found: type ScalaGenProfileArrayOps
[error] with ScalaGenDeliteOps with ScalaGenProfileOps with ScalaGenProfileArrayOps
[error]
^
Does someone have some insights to what I'm doing wrong?
From SBT manual:
Library dependencies can be added in two ways:
unmanaged dependencies are jars dropped into the lib directory
managed dependencies are configured in the build definition and downloaded
automatically from repositories (through Apache Ivy, exactly like Maven)
In any case, adding code inside a framework project is a bad idea, because you will have to change the build process (for example, adding an extra module). In addition, you might have to recompile all the code of the framework and this would be very slow.
The right way to make your code depending on a framework is:
Reference the library as a managed dependency available in some kind of repository (best solution).
Copy the jar inside the lib folder of your project and add it as an unmanaged dependency.
Since apparently Delite is not available on any Ivy repo, the best approach is to clone the Git repo and publish it locally. See http://www.scala-sbt.org/release/docs/Detailed-Topics/Publishing.html
Publishing Locally
The publishLocal command will publish to the local
Ivy repository. By default, this is in ${user.home}/.ivy2/local. Other
projects on the same machine can then list the project as a
dependency. For example, if the SBT project you are publishing has
configuration parameters like:
name := 'My Project'
organization := 'org.me'
version :=
'0.1-SNAPSHOT'
Then another project can depend on it:
libraryDependencies += "org.me" %% "my-project" % "0.1-SNAPSHOT"