sbt doesn't find class of managed dependency - scala

I try to include the build of jep (https://mvnrepository.com/artifact/jep/jep/2.24) into this scala project using sbt: https://github.com/shadaj/scalapy
So, instead of building jep manually via an unmanaged dependency, I want to include it as a managed dependency. Therefore I just included:
resolvers += "jep" at "https://mvnrepository.com/artifact/"
libraryDependencies += "jep" % "jep" % "2.24"
in the build.sbt
The .jar is getting downloaded and included in my .ivy2 folder but when compiling, sbt seems not to find it:
> compile
[info] Updating {file:/C:/scalapy_indp/scalapy/}scalapy...
[info] Resolving org.sonatype.oss#oss-parent;9 ...
[info] downloading https://repo1.maven.org/maven2/org/scala-lang/scala-library/2.12.1/scala-library-2.12.1.jar ...
[info] [SUCCESSFUL ] org.scala-lang#scala-library;2.12.1!scala-library.jar (1406ms)
[info] downloading https://repo1.maven.org/maven2/org/scala-lang/scala-reflect/2.12.1/scala-reflect-2.12.1.jar ...
[info] [SUCCESSFUL ] org.scala-lang#scala-reflect;2.12.1!scala-reflect.jar (1156ms)
[info] downloading https://repo1.maven.org/maven2/jep/jep/2.24/jep-2.24.jar ...
[info] [SUCCESSFUL ] jep#jep;2.24!jep.jar (188ms)
[info] downloading https://repo1.maven.org/maven2/org/scala-lang/scala-compiler/2.12.1/scala-compiler-2.12.1.jar ...
[info] [SUCCESSFUL ] org.scala-lang#scala-compiler;2.12.1!scala-compiler.jar (2469ms)
[info] downloading https://repo1.maven.org/maven2/org/scala-lang/modules/scala-xml_2.12/1.0.6/scala-xml_2.12-1.0.6.jar ...
[info] [SUCCESSFUL ] org.scala-lang.modules#scala-xml_2.12;1.0.6!scala-xml_2.12.jar(bundle) (360ms)
[info] downloading https://repo1.maven.org/maven2/jline/jline/2.14.1/jline-2.14.1.jar ...
[info] [SUCCESSFUL ] jline#jline;2.14.1!jline.jar (250ms)
[info] Done updating.
[info] Compiling 16 Scala sources to C:\scalapy_indp\scalapy\target\scala-2.12\classes...
[info] 'compiler-interface' not yet compiled for Scala 2.12.1. Compiling...
[info] Compilation completed in 15.285 s
[error] C:\scalapy_indp\scalapy\src\gen\scala\me\shadaj\scalapy\py\ObjectTupleReaders.scala:2: not found: object jep
[error] import jep.Jep
[error] ^
The errors of course keep coming for every Jep appearance in the code.
I'm absolutely not familiar with scala or sbt, I'm just trying to get this running without having to use unmanaged dependencies i.e. having it platform independent. Building jep manually seems to be platform dependent regarding the files which are being create:
If the build succeeds it will create a directory jep/build which will
contain a jep.jar and the compiled C library of Jep, typically named
jep.so or jep.dll depending on your platform.
see https://github.com/mrj0/jep/wiki/Getting-Started

The dependency is correctly setup, but the import is wrong.
Try
import org.nfunk.jep.JEP
instead.
--
Actually, I just realized those may be two different projects. The dependencies you included is this one: http://sens.cse.msu.edu/Software/jep-2.23/doc/website/doc/doc_usage.htm

Related

addSbtPlugin(...) cause eviction warning but 'evicted' command shows nothing

With sbt 1.2.7 and sbt-pgp plugin, sbt shows eviction warning.
$ rm -rf target project/target && sbt ";clean;compile"
[info] Loading global plugins from /home/kbigwheel/.sbt/1.0/plugins
[info] Loading project definition from /home/kbigwheel/code/_investigation/2019-01-04-evicted-warning-investigation-3/plugins/project/project
[info] Loading settings for project plugins-build from test.sbt ...
[info] Loading project definition from /home/kbigwheel/code/_investigation/2019-01-04-evicted-warning-investigation-3/plugins/project
[info] Updating ProjectRef(uri("file:/home/kbigwheel/code/_investigation/2019-01-04-evicted-warning-investigation-3/plugins/project/"), "plugins-build")...
[info] Done updating.
[warn] There may be incompatibilities among your library dependencies; run 'evicted' to see detailed eviction warnings.
[info] Loading settings for project plugins from build.sbt ...
[info] Set current project to plugins (in build file:/home/kbigwheel/code/_investigation/2019-01-04-evicted-warning-investigation-3/plugins/)
[success] Total time: 0 s, completed 2019/01/05 13:27:05
[info] Updating ...
[info] Done updating.
[success] Total time: 0 s, completed 2019/01/05 13:27:05
However, evicted command shows nothing.
$ sbt evicted
[info] Loading global plugins from /home/kbigwheel/.sbt/1.0/plugins
[info] Updating ProjectRef(uri("file:/home/kbigwheel/.sbt/1.0/plugins/"), "global-plugins")...
[info] Done updating.
[info] Loading project definition from /home/kbigwheel/proj-name/project/project
[info] Updating ProjectRef(uri("file:/home/kbigwheel/proj-name/project/project/"), "proj-name-build-build")...
[info] Done updating.
[info] Loading settings for project proj-name-build from test.sbt ...
[info] Loading project definition from /home/kbigwheel/proj-name/project
[info] Updating ProjectRef(uri("file:/home/kbigwheel/proj-name/project/"), "proj-name-build")...
[info] Done updating.
[warn] There may be incompatibilities among your library dependencies; run 'evicted' to see detailed eviction warnings.
[info] Set current project to proj-name (in build file:/home/kbigwheel/proj-name/)
[info] Updating ...
[info] Done updating.
[success] Total time: 0 s, completed 2019/01/05 13:52:46
Additional Info
With sbt 1.1.6, no warnings
With sbt 1.2.0, warning occured
With sbt-sonatype, no warnings
With sbt-native-packager, warning occured
Therefore, this warning must happens with specific plugin and sbt 1.2.0 or higher.
source to reproduce: https://github.com/bigwheel/sbt-unknown-evicted-warning
Why the warning shows ? and how to resolve this message ?
Remember that SBT is recuersive - that means, SBT uses SBT to build the SBT used to build your project.
The eviction warning you are seeing is not for your main project, but for the meta-project!
You can check that by running the evicted command in the meta project using the reload plugins command.
(I will be using sbt as shell instead of as a batch command executor, which is better and faster for development).
$ sbt
[info] Updated file /home/balmungsan/sbt-unknown-evicted-warning/project/build.properties: set sbt.version to 1.2.7
[info] Loading settings for project global-plugins from plugins.sbt ...
[info] Loading global plugins from /home/balmungsan/.sbt/1.0/plugins
[info] Loading project definition from /home/balmungsan/sbt-unknown-evicted-warning/project/project
[info] Updating ProjectRef(uri("file:/home/balmungsan/sbt-unknown-evicted-warning/project/project/"), "sbt-unknown-evicted-warning-build-build")...
[info] Done updating.
[warn] There may be incompatibilities among your library dependencies; run 'evicted' to see detailed eviction warnings.
[info] Loading settings for project sbt-unknown-evicted-warning-build from plugins.sbt ...
[info] Loading project definition from /home/balmungsan/sbt-unknown-evicted-warning/project
[info] Updating ProjectRef(uri("file:/home/balmungsan/sbt-unknown-evicted-warning/project/"), "sbt-unknown-evicted-warning-build")...
[info] Done updating.
[warn] There may be incompatibilities among your library dependencies; run 'evicted' to see detailed eviction warnings.
[info] Set current project to sbt-unknown-evicted-warning (in build file:/home/balmungsan/sbt-unknown-evicted-warning/)
[info] sbt server started at local:///home/balmungsan/.sbt/1.0/server/91ac4486f32705bdcc38/sock
sbt:sbt-unknown-evicted-warning> evicted
[info] Updating ...
[info] Done updating.
[success] Total time: 3 s, completed Jan 5, 2019 9:49:12 AM
sbt:sbt-unknown-evicted-warning> reload plugins
[info] Loading settings for project global-plugins from plugins.sbt ...
[info] Loading global plugins from /home/balmungsan/.sbt/1.0/plugins
[info] Loading project definition from /home/balmungsan/sbt-unknown-evicted-warning/project/project
[info] Updating ProjectRef(uri("file:/home/balmungsan/sbt-unknown-evicted-warning/project/project/"), "project-build")...
[info] Done updating.
[warn] There may be incompatibilities among your library dependencies; run 'evicted' to see detailed eviction warnings.
[info] Loading settings for project project from plugins.sbt ...
[info] Loading project definition from /home/balmungsan/sbt-unknown-evicted-warning/project
sbt:project> evicted
[info] Updating ProjectRef(uri("file:/home/balmungsan/sbt-unknown-evicted-warning/project/"), "project")...
[info] Done updating.
[info] Here are other dependency conflicts that were resolved:
[info] * org.scala-lang.modules:scala-parser-combinators_2.12:1.0.5 is selected over 1.0.4
[info] +- com.jsuereth:pgp-library_2.12:1.1.1 (depends on 1.0.5)
[info] +- com.typesafe:ssl-config-core_2.12:0.2.2 (depends on 1.0.4)
[success] Total time: 11 s, completed Jan 5, 2019 9:50:25 AM
(PS: To return to the main project execute the reload return command).

Why does sbt 1.0.2 hang after compilation?

I have installed sbt 1.0.2 and tried building the "hello project", but it hangs after done compilation.
I waited for 2 hours and it does not complete. what am I missing here?
HOSTPC:IdeaProjects XYZ2017$ sbt new sbt/scala-seed.g8
[info] Loading settings from plugins.sbt ...
[info] Loading global plugins from /Users/XYZ2017/.sbt/1.0/plugins
[info] Set current project to ideaprojects (in build file:/Users/XYZ2017/IdeaProjects/)
A minimal Scala project.
name [Scala Seed Project]: hello
Template applied in ./hello
HOSTPC:IdeaProjects XYZ2017$ ls
hello
HOSTPC:IdeaProjects XYZ2017$ cd hello/
HOSTPC:hello XYZ2017$ sbt
[info] Loading settings from plugins.sbt ...
[info] Loading global plugins from /Users/XYZ2017/.sbt/1.0/plugins
[info] Loading project definition from /Users/XYZ2017/IdeaProjects/hello/project
[info] Updating {file:/Users/XYZ2017/IdeaProjects/hello/project/}hello-build...
[info] Done updating.
[info] Compiling 1 Scala source to /Users/XYZ2017/IdeaProjects/hello/project/target/scala-2.12/sbt-1.0/classes ...
[info] Done compiling.

Exclude test dependency resolution from `sbt compile`

When running sbt compile, dependencies marked as test are still resolved even though they are not later included later in compilation. It seems like this should only happen during the test:compile task. Is there a way to exclude test dependencies from being resolved and downloaded during the compile task?
Here is an example with the org.mockito#mockito-all dependency. I have it declared as test-only:
"org.mockito" % "mockito-all" % "1.9.0" % "test"
However, when (clearing it from my local Ivy cache and) running sbt compile, it gets needlessly downloaded:
$ sbt compile
[info] Loading global plugins from /Users/rbrainard/.sbt/plugins
[info] Loading project definition from /Users/rbrainard/Development/spitball/project
[info] Set current project to spitball (in build file:/Users/rbrainard/Development/spitball/)
[info] Updating {file:/Users/rbrainard/Development/spitball/}spitball...
[info] Resolving org.mockito#mockito-all;1.9.0 ...
[info] downloading http://repo1.maven.org/maven2/org/mockito/mockito-all/1.9.0/mockito-all-1.9.0.jar ...
[info] [SUCCESSFUL ] org.mockito#mockito-all;1.9.0!mockito-all.jar (2075ms)
[info] Done updating.
[success] Total time: 7 s, completed May 28, 2014 4:51:20 PM
In sbt the update task resolves all dependencies for all configurations. Sbt makes use of Ivy, which promotes a very interesting "configuration" aspect to be able to separately resolve disparate classpaths at the same time.
Sbt is not only resolving your test classpath, but also runtime, the scala-tools (compiler, scaladoc, repl) and more.
Please read: https://ant.apache.org/ivy/history/latest-milestone/terminology.html for more information on the design of Ivy, which is why sbt attempts to do all resolution at once for all configurations.

Proguard Plugin for SBT Not Working?

[info] [SUCCESSFUL ] org.scala-sbt#xsbt-proguard-plugin;0.1.3!xsbt-proguard-plugin.jar (425ms)
[info] downloading http://repo1.maven.org/maven2/net/sf/proguard/proguard-base/4.8/proguard-base-4.8.jar ...
[info] [SUCCESSFUL ] net.sf.proguard#proguard-base;4.8!proguard-base.jar (1346ms)
[info] Done updating.
I got these messages after adding
resolvers += Resolver.url("sbt-plugin-releases-scalasbt", url("http://repo.scala-sbt.org/scalasbt/sbt-plugin-releases/"))(Resolver.ivyStylePatterns)
addSbtPlugin("org.scala-sbt" % "xsbt-proguard-plugin" % "0.1.3")
to my .sbt/plugins/build.sbt file, which makes me think proguard and it's library are installed just fine. But trying to use proguard or checking min-jar-path just gives me an error
[error] Not a valid command: proguard (similar: reload)
or
[error] Not a valid key: min-jar-path (similar: ivy-paths)
I've also tried putting the same thing into the (proj-directory)/project/build.sbt and still no luck. Also tried putting it at ~/.sbt/plugins/plugins.sbt with the same result. If I try about at the SBT prompt it tells me
[info] Available Plugins: ProguardPlugin
And yet I can't seem to run it at all. What am I doing wrong?
The step "Injecting the Plugin into desired project" is missing: https://github.com/adamw/xsbt-proguard-plugin#injecting-the-plugin-into-desired-project

Squeryl - "CustomTypesMode is not a member of package org.squeryl.customtypes"?

I've built Squeryl framework with SBT and am trying to use it with Scala 2.8 and NetBeans 6.9. I've defined an entity model as it is desctibed in Squeryl intro, but the IDE and compiler complain that "CustomTypesMode is not a member of package org.squeryl.customtypes". What might the reason be?
You don't have to build Squeryl, you can download the jar from http://github.com/max-l/Squeryl/downloads.
If you use sbt, you can drop the jar in the lib directory (I just tried and was able to compile the example using import org.squeryl.customtypes.CustomTypesMode._.)
Alternately you should be able to this line to your sbt project definition:
val squeryl = "org.squeryl" % "squeryl_2.8.0" % "0.9.4beta8"
Then run update:
$ sbt
[info] Recompiling project definition...
[info] Source analysis: 1 new/modified, 0 indirectly invalidated, 0 removed.
[info] Building project test 1.0 against Scala 2.8.0
[info] using MainProject with sbt 0.7.4 and Scala 2.7.7
> update
[info]
[info] == update ==
[info] downloading http://scala-tools.org/repo-releases/org/squeryl/squeryl_2.8.0/0.9.4beta8/squeryl_2.8.0-0.9.4beta8.jar ...
[info] [SUCCESSFUL ] org.squeryl#squeryl_2.8.0;0.9.4beta8!squeryl_2.8.0.jar (1425ms)
[info] downloading http://repo1.maven.org/maven2/cglib/cglib-nodep/2.2/cglib-nodep-2.2.jar ...
[info] [SUCCESSFUL ] cglib#cglib-nodep;2.2!cglib-nodep.jar (909ms)
[info] :: retrieving :: test#test_2.8.0 [sync]
[info] confs: [compile, runtime, test, provided, system, optional, sources, javadoc]
[info] 2 artifacts copied, 0 already retrieved (1268kB/60ms)
[info] == update ==
[success] Successful.