Maven or SBT with Scala? - scala

We're a small shop attempting to work mostly in Scala. Wondering about what some of the more experienced developers found to be a comfortable dev and build environment. Our product is centered around an HTTP server built in Scala/Lift and distributed as a War file. Our biggest concern today is SBT: we constantly run into bugs and a complete lack of responsiveness from SBT developers. Should we switch to Maven? (We already use Maven with the Java components of our product.) Is there an alternative to both?

I have used a lot both Maven and Sbt in Scala projects. And I think both could play well with Scala. Main advantage of sbt is that it works with scala environment out of the box (when in maven you need to write a lot of xml before it will properly compile scala and run scalatest). And it is much easier to extend sbt than maven if you need specific(non-standard) build tasks.
But maven is much more stable, of course, and have a more plugins. And with tools like zinc it could make your development with Scala nearly as convenient as with sbt.
But for myself I prefer sbt at this moment, mainly because I have tired of maven's verbosity not because it do something bad.

I've had generally positive experiences working in a small dev team with Scala and SBT. That said, I see that there are over 500 open issues on github! It seems counterproductive for the Scala community for teams to revert back to maven. Instead I think the best solution is for more of us to contribute to the ongoing development of SBT.

Related

How do I run SBT from within Eclipse?

So far I've been running IntelliJ IDEA Community Edition for my Scala projects, but as my projects are expanding in complexity, I stumble upon more and more roadblocks with the IDE.
Like for example the simple fact that IDEA doesn't allow for web-development or Java EE development what so ever, which means using the Play Framework or TomEE in Community Edition leads to nothing but dead ends and frustration.
The only reason I switched to IDEA in the first place, is because of its excellent plugin system, allowing me to run SBT seamlessly as the primary scala compiler and library downloading tool with ease.
Searching around on Google, however I can only seem to find mentions about the eclipse plugin for sbt, that makes an sbt project Eclipse friendly, which is the exact opposite of what I'm really looking for.
I'm not willing to spend €89 per year for a student licence after all the pain it's put me through so far...
So my question is; is there a plugin for Eclipse that allows me to use SBT the same way as in IDEA? Or am I forced to go through the console?
There may be some movement in this direction in the future, but for now there is no such plugin.
Currently there is no Sbt plugin for Eclipse. Depending on your use-case, you could:
use the Eclipse builder
Pros: proper integration (error markers in Problems and editors, cancelation, progress reporting)
Cons: may get out-of-sync with the Sbt build file (when adding a dependency, for example), doesn't handle anything other than Java and Scala (like Play templates or route files)
use Sbt on the command line (make sure to disable auto-building in Eclipse)
Pros: can handle complex builds, classpath is always up to date
Cons: no integration (see above)
use Activator
Same Pros and Cons as Sbt, but with a pretty UI
We are working on an sbt-server plugin for Eclipse, which will delegate the build to an external Sbt process without giving up the convenience of integration. We hope to have something out towards the end of this year.
I think the main problem you are trying to solve for is too have sbt jar dependencies show up and get used natively by your eclipse project. You can do that with the IvyIDE plugin (which is found in the eclipse marketplace).
If you have that installed (and the eclipse plugin for sbt) then this closes the gap between systems.
To enable:
type the {sbt deliver-local} command from your terminal. This adds an ivy xml in your project's target directory
right click on your project. Choose the Ivy -> enable Ivy dependency management option
go into your projects properties. Highlight the Ivy property. Click the new button and navigate to the ivy xml file in your projects target directory.
Now your eclipse compiles off of your sbt managed dependencies and now you are doing everything you want except actually running sbt from within eclipse (which you only have to do now when you are changing dependencies)

Is it possible to use gradle to develop scala projects?

I'm using sbt to build scala projects, but it always seems too complex(unfamiliar) and heavy to me. I'm also using gradle to build java projects, and which makes me happy.
I wonder is it possible to use gradle to build scala projects? Is there any big scala projects that uses gradle?
Some of my friends just tell me "Never ever think of using gradle for scala project", but refused to tell me the reason.
It's quite easy to use Gradle with Scala.
We did it for a long time (a mixed team of Java, Groovy and Scala developers) and have been quite happy with it.
Most things work quite well out of the box.
More about Gradle with Scala:
http://www.gradle.org/docs/current/userguide/scala_plugin.html
There are some problems/downfalls though:
Mixed code compilation when depending on Scala code from Java in mixed code projects. (Some configuration and it will work, but not out of the box)
More configuration for Scala-specific tools needed than with sbt
Integration of some Scala tools like Scalastyle or scct is not possible yet
no sbt console (Gradle console has not been working properly since the last time I checked)
adding the Scala version number to artifacts has to be added manually each time (no %% as in sbt)
It's definitely possible. Gradle's Scala support is documented in the "Scala plugin" chapter in the Gradle User Guide. The plugin is used by big companies on big projects, and can be configured to use the same incremental Scala compiler as sbt. So best try for yourself and see if it fits your requirements.

What is the best way to create/build Scala Project

I started learning Scala lately. I find it extremely difficult to -productively- add new project. I was using Visual Studio for years as I am coming from .net development environment.
However, SBT is great tool to build Scala project, but you have to make everything from scratch by your own. It's sometime non productive to make a project that respect the guide lines of Scala () add plugins.build,
I found many alternatives, but I am not sure if these projects are updated:
1- jrebel
http://www.scalatra.org/2.2/getting-started/jrebel.html
2- TypeSafe Templates:
http://typesafe.com/activator/templates
3- Using giter8
github.com/n8han/conscript
IDEs lack some feature such as supporting Akka, in addition to that:
for Eclipse, in the project folder, type sbt eclipse,
for Intellij IDEA, in the project folder, type sbt gen-idea
What is the best way to create and build Akka projects in an interactive way, respecting the guideline of the scala (You can see here the project's architecture www.scalatra.org/2.2/getting-started/project-structure.html)

How can I manage multiple versions of Scala & SBT in my dev environment?

I just finished the awesome Coursera Scala course and am eager to continue learning more about Scala by exploring some existing open source projects. I've hit a snag while trying to get some of them running locally, though.
I come from a background in Ruby, where we use tools such as rvm or rbenv to manage multiple Ruby interpreters/versions on one system. What is the approach that Scala users take for working with projects that use different versions of Scala/SBT?
I suspect that I'm missing something big since this doesn't seem to be a popular issue.
Please note that I'm pretty new to the world of Java and the JVM in general.
I suggest you take a look at paulp's excellent sbt-extras script. This will enable you to pick which version of sbt you want to use on a per-project basis, and sbt will allow you to pick which version(s) of Scala you want on a per-project basis.
I always use the latest sbt from Homebrew (OS X) and then control the Scala version and libraries from within the build.sbt.
More recently (Dec. 2016), you can try and check out sdkman.io, The Software Development Kit Manager.
It is a tool for managing parallel versions of multiple Software Development Kits on most Unix based systems. It provides a convenient Command Line Interface (CLI) and API for installing, switching, removing and listing Candidates.
It installs Software Development Kits for the JVM such as Java, Groovy, Scala, Kotlin and Ceylon. Activator, Ant, Gradle, Grails, Maven, SBT, Spring Boot, Vert.x and many others also supported.

How to use a Scala IDE (Eclipse or NetBeans based) to develop a Scala Lift web application with SBT?

I've switched to a plain text editor and console SBT from NetBeans because the last was enforcing Ant and used to have some other troubles with Scala. Now, as I have to explore others code (Lift examples for now) instead of just writing my own from scratch, I feel I miss debug, refactoring and definition/type lookup facilities of a good IDE.
So I am looking forward to go with some Scala IDE (Eclipse or NetBeans based) again, but I still want to use SBT as a build and dependency management tool (not Maven/Ant instead) and only use the IDE as an advanced code editor.
How to achieve this?
No personal experience, but looks like Scala-IDE keeps improving their SBT support.
http://scala-ide-portfolio.assembla.com/spaces/scala-ide/wiki/Changelog
Release 2.0.0-beta11 (released: 2011-10-03) makes a few mentions of using SBT.
Also, the docs at http://scala-ide-portfolio.assembla.com/spaces/scala-ide/wiki/SBT-based_build_manager show how to use SBT.