Clone and build Scalala with Eclipse/IntelliJ - scala

I am trying to import Scalala into Eclipse.
I had tried using the sbt-eclipse plugin by adding the lines
addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "2.0.0-M2")
to my plugins.sbt
and I ran ./sbt update from the root of the Scalala dir which is cloned from github,
I am getting the below error
==================================================
[warn]
[warn] Note: Some unresolved dependencies have extra attributes. Check that these dependencies exist with the requested attributes.
[warn] com.typesafe.sbteclipse:sbteclipse-plugin:2.0.0-M2 (sbtVersion=0.11.0, scalaVersion=2.9.1)
[warn]
[error] {file:/home/tutysra/Scalala/project/plugins/}default-ffe360/*:update: sbt.ResolveException: unresolved dependency: com.typesafe.sbteclipse#sbteclipse-plugin;2.0.0-M2: not found
Project loading failed: (r)etry, (q)uit, (l)ast, or (i)gnore? i
[warn] Ignoring load failure: no project loaded.
==================================================
Had anyone successfully built Scalala's source with Eclipse and can share the steps they followed?
I can also give IntelliJ a try if that is the preferred method and used by many devs.
If there are some tweaking necessary for running on IntelliJ please provide them as well.

sbteclipse requires sbt 0.11.2. I have created a pull request with the necessary changes to upgrade Scalala to sbt 0.11.2. Meanwhile, you can make the same changes locally.
You'll still need to add sbteclipse to project/plugins.sbt:
addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "2.0.0-M2")
EDIT: The changes have been merged, and Scalala now uses sbt 0.11.2. Grab the latest Scalala, add the config line above, and you should be good to go.

Related

Using berkeley hardfloat

I am using Chisel3 in my project. I tried to import hard float library as folow:
import chisel3._
import hardfloat._
but unfortunately, I am getting:
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: UNRESOLVED DEPENDENCIES ::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: edu.berkeley.cs#hardfloat_2.11;1.2: not found
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn]
I went through couple of repositories that used hardfloat and found out that I was missing this line in my build.sbt:
libraryDependencies ++= Seq("edu.berkeley.cs" %% "hardfloat" % "1.2")
but unfortunately I am still getting the error. I then tried to compile projects that use hardfloat without any modification (for example soundkit) but I still get the same error. I used both terminal and InteliJ to compile my project and got the same result. For some reason, the hardfloat library is not even shows up in the External Libraries in IntelliJ .
I would really appreciate it if someone let me know what might be the issue.
pedrofurla was right. After talking to folks at RISC-V, I got to know that, as you said, the hardfloat is not published to somewhere that sbt can download it. In order to use the library, one has to build and publish it locally:
git clone https://github.com/ucb-bar/berkeley-hardfloat.git hardfloat
cd hardfloat
sbt publish-local
Note: the library works with chisel2

How to download sbt plugin source jars in a common sbt project?

It's nature to download the dependencies source jars in a sbt project, using sbt gen-idea or idea's autoimport feature
but how can I download the sbt plugin source jars which I declared in project/plugins.sbt
IDEA
IDEA should already do this*.
When you import a project and have Download sbt sources checked in Preferences > Build, Execution, Deployment > Build Tools > sbt then it will run the updateSbtClassifiers sbt task.
* Read the Troubleshooting section as there are several known issues with this.
sbt
As mentioned above, you can run the following sbt task:
sbt> updateSbtClassifiers
This command is somewhat special in that it knows to resolve the classifiers for the plugins. It also uses settings that are scoped to that task. See the caveat about sbt/sbt#3432.
Longer way
It is important to understand that sbt is recursive.
Dependencies declared in build.sbt will be for the proper build.
Dependencies declared in project/plugins.sbt will be for the meta-build.
When you just run updateSbtClassifiers it is running this on the proper build, however the dependencies are actually for the meta-build. That is why I said that this task is a little special.
Another way (which can achieve different results) is to run the updateClassifiers task directly on the meta-build.
First switch over to the meta-build:
sbt> reload plugins
Now that you are in the meta-build run:
sbt:project> updateClassifiers
This will retrieve the src and doc for your dependencies (it may not actually do this for some plugins). Run libraryDependencies to see the dependencies of the meta-build.
To get back to the proper
sbt:project> reload return build run:
Troubleshooting
Download failed
You may see in the sbt logs that it failed to download either the src or doc. For example:
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: FAILED DOWNLOADS ::
[warn] :: ^ see resolution messages for details ^ ::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: rocks.muki#sbt-graphql;0.5.0!sbt-graphql.jar(doc)
[warn] :: rocks.muki#sbt-graphql;0.5.0!sbt-graphql.jar(src)
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
If you look just above you will see all the resolvers that it tried. You should see one for sbt-plugin-releases which is where most sbt plugins are published to. See predefined resolvers for more details.
If you do not see that it tried sbt-plugin-releases then chances are you have encountered sbt/sbt#3432.
updateSbtClassifiers does not use the correct resolvers. Add the following to your build.sbt file:
updateSbtClassifiers / dependencyResolution := IvyDependencyResolution((updateSbtClassifiers / ivyConfiguration).value)
Sources not attaching
Even if the updateSbtClassifiers successfully downloads and resolves the src and doc IDEA may not attach them.
This seems to be a bug in the sbt-structure plugin. See SCL-13619 for details.
No attempt at downloading
If for some reason this doesn't download the sources (there is no failed download message) then have a look in your .ivy2/exclude_classifiers file. I'm not entirely sure what this file is for but I do know that sbt will exclude anything that is in here.
In my case it had a whole lot of things that I didn't want excluded so I deleted it and then it worked. Delete at your own risk.
You can use reload plugins to go into the project that contains the plugins. If you type libraryDependencies you can (for example) see the list of plugin dependencies. Use reload return to return to your normal sbt console.
More information here: Commands for managing the build definition

Lift - Setting it up

Today I started with scala and lift and I am currently reading though the docs. I managed to get it started with the help of the cookbook.
However I want to read though some bigger examples, especially this example because it uses mongodb + authentication https://github.com/eltimn/lift-mongo.g8/tree/master/src/main/g8
I didn't use g8 nor cs because I had some errors with cs and I was to lazy to investigate them.
So I just cloned the repo to my hard drive. I think that is what g8 is doing.
So some files are missing, I added them
sbt
sbt.bat (I am using windows)
sbt-launch.jar
But I get the following errors:
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: UNRESOLVED DEPENDENCIES ::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: org.scala-sbt#sbt-closure;0.1.3: not found
[warn] :: com.github.siasia#xsbt-web-plugin_2.9.1;0.11.2
ound
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
I tried to fix the sbt-closure but I could not find it in with the maven search
http://search.maven.org/#search%7Cga%7C1%7Csbt-closure
the plugins.sbt looks like this
resolvers += Resolver.url("sbt-plugin-releases",
new URL("http://scalasbt.artifactoryonline.com/scalasbt/sbt-plugin-releases/"))(
Resolver.ivyStylePatterns)
addSbtPlugin("org.scala-sbt" % "sbt-closure" % "0.1.3")
addSbtPlugin("me.lessis" % "less-sbt" % "0.1.10")
libraryDependencies <+= sbtVersion(v => "com.github.siasia" %% "xsbt-web-plugin" % (v+"-0.2.11.1"))
Any idea what went wrong?
SBT plugins need to be re-published for each new version of SBT. My guess is that the template you downloaded was based on an older version of SBT (0.11 maybe?) and that the versions of the plugins you are referencing haven't been published for the latest SBT (0.12). You could try to find an older version of SBT to download, but you're probably better off either getting g8/conscript working, or using one of these templates: https://github.com/lift/lift_24_sbt.

How to use scala-time?

somebody know scala-time? (https://github.com/jorgeortiz85/scala-time)
Have no idea how to use it. I can download it (on linux) and run sbt but theres always the same errormessage:
git clone git://github.com/jorgeortiz85/scala-time
cd scala-time
sbt
Getting org.scala-tools.sbt sbt_2.9.1 0.7.4 ...
:: problems summary ::
:::: WARNINGS
module not found: org.scala-tools.sbt#sbt_2.9.1;0.7.4
==== local: tried
/home/ll/.ivy2/local/org.scala-tools.sbt/sbt_2.9.1/0.7.4/ivys/ivy.xml
-- artifact org.scala-tools.sbt#sbt_2.9.1;0.7.4!sbt_2.9.1.jar:
/home/ll/.ivy2/local/org.scala-tools.sbt/sbt_2.9.1/0.7.4/jars/sbt_2.9.1.jar
==== Maven2 Local: tried
file:///home/ll/.m2/repository/org/scala-tools/sbt/sbt_2.9.1/0.7.4/sbt_2.9.1-0.7.4.pom
-- artifact org.scala-tools.sbt#sbt_2.9.1;0.7.4!sbt_2.9.1.jar:
file:///home/ll/.m2/repository/org/scala-tools/sbt/sbt_2.9.1/0.7.4/sbt_2.9.1-0.7.4.jar
==== typesafe-ivy-releases: tried
http://repo.typesafe.com/typesafe/ivy-releases/org.scala-tools.sbt/sbt_2.9.1/0.7.4/ivys/ivy.xml
-- artifact org.scala-tools.sbt#sbt_2.9.1;0.7.4!sbt_2.9.1.jar:
http://repo.typesafe.com/typesafe/ivy-releases/org.scala-tools.sbt/sbt_2.9.1/0.7.4/jars/sbt_2.9.1.jar
==== Maven Central: tried
http://repo1.maven.org/maven2/org/scala-tools/sbt/sbt_2.9.1/0.7.4/sbt_2.9.1-0.7.4.pom
-- artifact org.scala-tools.sbt#sbt_2.9.1;0.7.4!sbt_2.9.1.jar:
http://repo1.maven.org/maven2/org/scala-tools/sbt/sbt_2.9.1/0.7.4/sbt_2.9.1-0.7.4.jar
==== Scala-Tools Maven2 Repository: tried
http://scala-tools.org/repo-releases/org/scala-tools/sbt/sbt_2.9.1/0.7.4/sbt_2.9.1-0.7.4.pom
-- artifact org.scala-tools.sbt#sbt_2.9.1;0.7.4!sbt_2.9.1.jar:
http://scala-tools.org/repo-releases/org/scala-tools/sbt/sbt_2.9.1/0.7.4/sbt_2.9.1-0.7.4.jar
==== Scala-Tools Maven2 Snapshots Repository: tried
http://scala-tools.org/repo-snapshots/org/scala-tools/sbt/sbt_2.9.1/0.7.4/sbt_2.9.1-0.7.4.pom
-- artifact org.scala-tools.sbt#sbt_2.9.1;0.7.4!sbt_2.9.1.jar:
http://scala-tools.org/repo-snapshots/org/scala-tools/sbt/sbt_2.9.1/0.7.4/sbt_2.9.1-0.7.4.jar
::::::::::::::::::::::::::::::::::::::::::::::
:: UNRESOLVED DEPENDENCIES ::
::::::::::::::::::::::::::::::::::::::::::::::
:: org.scala-tools.sbt#sbt_2.9.1;0.7.4: not found
::::::::::::::::::::::::::::::::::::::::::::::
huh? Any other options?
To actually use it (as compared to building scala-time yourself), just add
libraryDependencies += "org.scala-tools.time" % "time_2.9.1" % "0.5"
to the build.sbt of the project you want to use it in.
Addition:
Current versions may want to use
libraryDependencies += "org.scalaj" %% "scalaj-time" % "0.6"
This is an sbt version problem, and you might be able to work around it by using a different sbt-launch or by changing the build a bit. I get a similar error if I use sbt-launch-0.10.1.jar for this code, but it works fine if I use sbt-launch-0.7.7.jar.
I'd suspect you're using sbt-launch-0.11.0, and this is causing sbt to look for a compiled version of sbt that doesn't in fact exist.
Possible fixes are:
Just use sbt-launch-0.7.7 for this code.
Edit the build.properties file to use a different version of sbt.
Get source for sbt-0.7.4, compile with scala 2.9.1 and stash the result in your local ivy repository with the name and location that's being searched.
Options 1 and 2 worked for me.
I haven't done #3 for this, but have done similar things for other code. It can be a bit painful...
You can have multiple versions of sbt-launch and flip between them depending on the needs of a particular codebase.
Perhaps someone who knows sbt better than I will post a real solution, but I'm hoping this is at least a little helpful.
Update or remove the sbt version(0.7.4) line from build.properties
That means there's no public version of SBT 0.7.4 compiled against Scala 2.9.1 by the looks of it.

scala-redis requires sbt 0.10.1 (other versions don't work) - is that normal?

While trying out the Scala bindings for Redis, I followed the instructions in the README file (clone the repo, cd into it, type sbt) and I got this:
$ sbt
Getting org.scala-tools.sbt sbt_2.9.1 0.10.1 ...
:: problems summary ::
:::: WARNINGS
module not found: org.scala-tools.sbt#sbt_2.9.1;0.10.1
==== local: tried
/Users/noah/.ivy2/local/org.scala-tools.sbt/sbt_2.9.1/0.10.1/ivys/ivy.xml
-- artifact org.scala-tools.sbt#sbt_2.9.1;0.10.1!sbt_2.9.1.jar:
/Users/noah/.ivy2/local/org.scala-tools.sbt/sbt_2.9.1/0.10.1/jars/sbt_2.9.1.jar
==== Maven2 Local: tried
file:///Users/noah/.m2/repository/org/scala-tools/sbt/sbt_2.9.1/0.10.1/sbt_2.9.1-0.10.1.pom
-- artifact org.scala-tools.sbt#sbt_2.9.1;0.10.1!sbt_2.9.1.jar:
file:///Users/noah/.m2/repository/org/scala-tools/sbt/sbt_2.9.1/0.10.1/sbt_2.9.1-0.10.1.jar
==== typesafe-ivy-releases: tried
http://repo.typesafe.com/typesafe/ivy-releases/org.scala-tools.sbt/sbt_2.9.1/0.10.1/ivys/ivy.xml
-- artifact org.scala-tools.sbt#sbt_2.9.1;0.10.1!sbt_2.9.1.jar:
http://repo.typesafe.com/typesafe/ivy-releases/org.scala-tools.sbt/sbt_2.9.1/0.10.1/jars/sbt_2.9.1.jar
==== Maven Central: tried
http://repo1.maven.org/maven2/org/scala-tools/sbt/sbt_2.9.1/0.10.1/sbt_2.9.1-0.10.1.pom
-- artifact org.scala-tools.sbt#sbt_2.9.1;0.10.1!sbt_2.9.1.jar:
http://repo1.maven.org/maven2/org/scala-tools/sbt/sbt_2.9.1/0.10.1/sbt_2.9.1-0.10.1.jar
==== Scala-Tools Maven2 Repository: tried
http://scala-tools.org/repo-releases/org/scala-tools/sbt/sbt_2.9.1/0.10.1/sbt_2.9.1-0.10.1.pom
-- artifact org.scala-tools.sbt#sbt_2.9.1;0.10.1!sbt_2.9.1.jar:
http://scala-tools.org/repo-releases/org/scala-tools/sbt/sbt_2.9.1/0.10.1/sbt_2.9.1-0.10.1.jar
==== Scala-Tools Maven2 Snapshots Repository: tried
http://scala-tools.org/repo-snapshots/org/scala-tools/sbt/sbt_2.9.1/0.10.1/sbt_2.9.1-0.10.1.pom
-- artifact org.scala-tools.sbt#sbt_2.9.1;0.10.1!sbt_2.9.1.jar:
http://scala-tools.org/repo-snapshots/org/scala-tools/sbt/sbt_2.9.1/0.10.1/sbt_2.9.1-0.10.1.jar
::::::::::::::::::::::::::::::::::::::::::::::
:: UNRESOLVED DEPENDENCIES ::
::::::::::::::::::::::::::::::::::::::::::::::
:: org.scala-tools.sbt#sbt_2.9.1;0.10.1: not found
::::::::::::::::::::::::::::::::::::::::::::::
:: USE VERBOSE OR DEBUG MESSAGE LEVEL FOR MORE DETAILS
unresolved dependency: org.scala-tools.sbt#sbt_2.9.1;0.10.1: not found
Error during sbt execution: Error retrieving required libraries
(see /Users/noah/.sbt/boot/update.log for complete log)
Error: Could not retrieve sbt 0.10.1
This was using sbt 0.7.4. I tried downloading the latest version of sbt (0.11.0) and I got the same problem. Then I manually downloaded sbt-launcher.jar from the 0.10.1 release of sbt, and that worked.
My question is: is sbt supposed to automatically download the required version of itself, or am I going to have to manually download & run different versions of sbt for packages which require different versions?
The error message seems unrelated to Redis.
Yes, SBT is supposed to download the appropriate version of itself. You can find out what versions of SBT are available by pointing your browser to: http://repo.typesafe.com/typesafe/ivy-releases/org.scala-tools.sbt/ You will see that Scala 2.8.1 is tied to SBT versions <= 0.10.1, whereas Scala 2.9.1 is (currently) compatible with SBT 0.11.0 only.
You're getting this error message because somehow you're trying to get SBT 0.10.1 for Scala 2.9.1, which is an invalid combination. Not sure how you did this.. maybe you edited some internal SBT config files in the directory ~/.sbt/? If you want to get a "virgin" SBT, you can delete ~/.sbt/ and download the latest sbt-launch.jar. If you want to use a previous version of SBT, you can edit the project/build.properties file, as described on the Wiki.