What is the best way to create/build Scala Project - eclipse

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)

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.

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.

Build Maven Scala Project with Akka

Usually, I am using SBT to build Scala Projects.
Lately, I have been asked to integer an existing project, they use Maven as development tool.
I wanna work with Maven to build an Akka-Scala Project. I couldn't find any tool to build that.
I tried to make a new Maven project from Eclips (New Project ==> Maven Project), then Add actor library (Proprieties => Build Path => Add Akka Library from external Libraries). But it didn't work.
Can you recommend any IDE/Tool to do that ?
You will need scala-maven-plugging at least for maven to know about Scala. Scala archetype looks like good solution, but I haven't used it. This also may help http://scala-ide.org/docs/tutorials/m2eclipse/index.html