Eclipse Scala IDE: How to build standalone Scala app? - eclipse

I am writing an app that uses AnormCypher (Cypher-oriented Scala library for Neo4j Server https://github.com/AnormCypher). I write my code in Eclipse Scala IDE. Using sbteclipse plugin I have imported AnormCypher sbt project into Eclipse. Next I have added it to Java build pass as external project. Everything compiles and works from Eclipse now.
Question: How in Eclipse build a standalone Scala program with all necessary dependencies including external Scala project imported in Eclipse?
Trying to create'executable jar' from Eclipse does not work in this case because to do so Eclipse requests "Select a 'Java Application' launch configuration to use to create a runnable JAR." Alas Eclipse here has no idea about Scala launch configuration.

There is not currently a feature of the Scala IDE.
However, it's easy to write a simple build file for your project using sbt. Once there, you can use one of the numerous available plugins to create a distribution for it. Sbt has its own sbt-assembly and sbt-oneJar to create standalone JARs, and there is twitter's sbt-package-dist, with more varied publishing options.

Related

Scala build process

First some context:
My aim is to use scala alongside a testing environment, preferably in an ide.
At first I installed scala (v. 2.10.1) and sbt and it worked. I used emacs and a shell.
Then I wanted to use eclipse and installed the sbt plugin. But when I tried the FlatSpec example of the scalatest website together with the scalatest lib, it did compile but 0/0 tests did run.
In intellij I tried the same example but although I gave my sdk location, the collection package wasn't found.
My problem:
I don't understand what I have to tell my ide or what I have to write (maybe files for maven or make etc.) or where I can learn all that.
My question:
What has the ide to know if I want to run a scala project?
- location of sdk, jdk, sbt, my_project, ...
- versions of scala, java etc.
What else must it know?
IntelliJ has build in support for sbt projects. My work flow is the following :
Create a project (in the shell) using sbt. Basically you have to create a build.sbt and the necessary directory structure
`src/main/scala`
`src/main/resources`
`src/test/`
The in IntelliJ just do Open -> select build.sbt.
Also check auto-import checkbox.
Everything should work after this.
NOTE: You may have to install the Scala and sbt plugin for the above to work.

Can NetBeans 8.0 with Scala and sbt plugins installed create sbt project?

I had previously used Scala-IDE, and I thought I'd give NetBeans IDE 8.0 a try.
I created Java/Maven projects successfully, but I don't seem to be able to create an sbt project. I have all the Scala plugins loaded as far as I can see, including the sbt plugin. Platform is Win 8.1 and Java 8.
Creating an NetBeans native project for Scala works, but there seems to be no option to create an sbt project. Is that expected?
Iff the plugin you use is nbscala-1.6.3.1 it appears from the documentation that the supported features are:
Recognize sbt project and open in NetBeans
Open sbt console in NetBeans (Right click on sbt project, choose "Open Sbt")
Jump to/Open compile error lines
I conclude that there's no support for creating a new sbt project using the plugin.
You'd have to create a sbt project using Typesafe Activator and only then use NetBeans with the plugin to open it and start hacking right in the environment.

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 generate Scaladocs from Eclipse project

I want to start generating scaladocs from my Eclipse project. I don't use SBT, but am willing to import my eclipse project to sbt if it is needed.
How do I generate Scaladocs from an eclipse Scala project?
As far as I know, there is no direct method supported by the Scala plugin for Eclipse without using SBT or Maven.
As a workaround, you can go to Run -> External Tools -> External Tools Configurations... and setup the scaladoc tool there as a Program. This way you would have a one-click solution for generating Scaladocs.

How to add dependencies in Eclipse which sbt and Play 2.0 can see

I am working on a Scala library in Eclipse (proj1).
This library I would like to test in a Play 2.0 Scala web app.
So I have run the eclipse command from the cmd line and imported the project into Eclipse (proj2).
So I have two eclipse projects side by side. I can add the first project (proj1) to the build path of proj2 in Eclipse.
This way I can import the library and write the code.
But when Play compiles it can't see library I've added to the build path.
If I run the eclipse command again the library is removed from the build path.
Is there any way to reference the project? I would prefer not to build a jar and import that via sbt.
I simply add them via sbt and regenerate the eclipse project from the Play console.