Is it possible to use gradle to develop scala projects? - scala

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.

Related

Intellij IDEA - Cannot add framework support for Scala

I have sbt 0.13.16 and Scala 2.10.6 running with Intellij 2018.2.1, working with those recommended sbt and Scala settings for Odersky's coursera course on Scala (I'm guessing their automated submission grader depended on old SBT?).
When creating new sbt + scala projects, I choose the above sbt and Scala versions, then after all the dependencies have downloaded, when I right-click New -> ... I see options for Java class but nothing for Scala. I have the Scala plugin already there according to the plugin settings.
So I try to Add Framework Support after right-clicking on the project, I select Scala, but then everything is disabled except Cancel.
I looked through previous forums, found one but that seemed relevant only for git projects.
Anyone else run into this issue? Do I need to update to more recent Scala and SBT? Any help would be very appreciated.
Please check https://plugins.jetbrains.com/plugin/1347-scala/versions for a compatibility table.
You can manage plugins in IntelliJ Preferences. Your versions seem to be too old to still be supported, already. It may help to upgrade IntelliJ and then go to preferences and get the latest Scala and SBT plugins.

Maven or SBT with 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.

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)

IntelliJ 404 scala lang

Ok, I need some help in setting up a Scala project with IntelliJ, I have download and installed the project successfully, but i have had issues when it comes to installing the Scala compiler itself, WHen i go to configure a new Scalaa project and choose to set the Scala home, I choose the download Scala option and i get the following error "downloading failed, connection failed with error 404: http://www.scala.lang.org/downloads.distrib/files/scala2.10.0+RC2.tgz" i have tried downloading the things, such as primefaces and jSF through intelij, and they all work fine, any suggestions?
Download Scala manually and just select proper directory in new project window.
http://www.scala-lang.org/download/
You should be using SBT to define and build your project. Among other things, it handles retrieving the Scala compiler and libraries. IDEA is similarly self-contained as far as its Scala plug-in's internal Scala compiler is concerned. By using SBT and IDEA (see below for connecting the two), the only thing not covered is a Scala REPL for use outside of either SBT or IDEA. If you're using a Mac, Homebrew includes a Scala formula. Because SBT retrieves the Scala compiler and libraries for the version of Scala you specified, everything is self-contained.
By far the best way to build and maintain IDEA project definitions for Scala projects is with the sbt-idea plug-in for SBT. Once you install that plug-in, which is trivial, you simply use the gen-idea SBT task it provides. When your dependencies change, you run gen-idea again to update the project.

How to use just one scala library for maven/eclipse/scala

I have configured a project to use scala/maven/Eclipse. Because I need a scala library on the build path and scalatest also uses its own scala library I receive this warning :
More than one scala library found in the build path, all with
compatible versions. This is not an optimal configuration, try to
limit to one scala library in the build path.
I don't think I can remove this warning as I need both libraries - one for Maven, the other for Eclipse. This doesn't seem to be causing any problems so will I just have to accept it? Is there an alternate configuration which uses just one scala library for Maven & Eclipse?
If I remove the scala library from the project I receive the error:
Cannot find Scala library on the classpath. Verify your build path!
For some reason Eclipse requires the scala library to be on the build path even though it is already available as a Maven dependency.
There is nothing to worry about. Eclipse warns you that you have several scala-library.jars on your classpath, but as long as they are the same version, it doesn't matter.
If one of them diverged (for instance, by bumping the Scala version number in your pom file), you'd be in trouble: depending on the classpath order, the IDE will pick up classes from one or the other, and you might get different results when building on the command line.
Coming back to your setup, you could
remove the Scala Library classpath container from your Eclipse projects, leaving just the jar that maven adds.
ignore the warning
Venturing a guess here, are you using the Eclipse Indigo pre-installed with Scala 2.9 and the corresponding Scala plugin? If that's the reason you need to use that library, perhaps consider using Eclipse Juno? That's what I use and it works quite well with both the milestone and the nightly builds