When creating a maven module project, how to set language to scala? - scala

I have intellij 11 ultimate.
When creating a new maven module project, how do I set the project to use scala as the default language?
Is there a way to run multiple versions of scala in intellij? (not at the same time, but for different projects).

I think you can create a normal java project and then go to project structure -> modules-> facets and add the scala facet if you have the scala plugin installed.
The version of scala your project will use depends on the scala runtime selected in the facet, so yes it's possible to have different scala versions in different projects.

When importing a Maven project into IntelliJ, as long as you have installed the Scala plugin for IntelliJ, I think it should recognise the project as Scala and add the Scala Facet to the Module.
Here is an example https://github.com/adamretter/Skullfuck/blob/master/pom.xml of a simple Maven POM that I use that includes the better of the two Maven Scala Plugins. If you also install Zinc, you can have Maven use the Zinc compiler to speed up Scala compilation.
If IntelliJ does not recognise the Scala'ness of the imported Maven project, simply go to 'Module Settings' by right-clicking on the project, go to 'Facets' and then click the '+' and add the Scala facet. If it complains about not finding the compiler you should be able to select it from the down as it is a dependency of the Maven project anyway.

Related

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.

Eclipse Scala IDE: How to build standalone Scala app?

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.

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

What is a "build manager" for scala in the scala ide extensions for Eclipse?

In Eclipse in Preferences -> Scala -> Compiler -> Build manager, I can select a "buildmanager." What is the difference between "refined" and "sbt"?
Also, is this some method to integrate an sbt build file into the Eclipse IDE?
ScalaIDE has two build managers, basically they are interfaces between the eclipse model and the scala compiler, they have to do things like work out which resources need re-compiling and how that affects dependent code. Refined is a refined version of the original interface and sbt is, well, sbt.
SBT is the default now, and I expect refined will go away at some point.
Unfortunately the build manager is very much under the hood. There is no real eclipse project->sbt integration yet. There is an eclipse plugin for sbt which allows you to generate eclipse project files but no tight integration from an eclipse project to sbt akin to IvyDE or m2e.
You can use sbt deliver-local to create an ivy file of dependencies, and use IvyDE to keep your classpath containers up to date - that's about as good as it gets at the moment.
I wouldn't be surprised to see this situation improve though - check out the roadmap.

Is there any way to avoid Scala libraries appearing twice in an Eclipse/Scala/Maven project?

I have
Eclipse 3.5.2
Scala 2.8.0 final (inc latest Scala IDE for Eclipse)
Maven integration for Eclipse
Maven 2.2.1
.project and .classpath files generated by maven-eclipse-plugin
I'm using Scala to write Specs BDD tests for my Java code and the setup above is working very nicely so far. However, I have one puzzling problem and I would like to know whether anyone knows how to resolve it.
The Scala libraries are appearing in my project twice.
in the M2 ClassPath (as a Maven Dependency)
as an Eclipse System Library (in the same manner as the JRE System Libraries)
Consequently, when I Ctrl-Shft-T every Scala class appears twice.
Can this be avoided without breaking my Scala project in either the command line or the Workspace?
The best place for questions like this is the Scala IDE user mailing list.
The most up to date documentation on using the Scala tooling for Eclipse with Maven via m2eclipse can be found here.
To answer my own question,
it appears (as hinted at by all above) that maven-eclipse-plugin is essentially obsolete. When I
deleted my old eclipse project
removed all eclipse files (ie .settings and .project from my project directory)
removed all references to maven-eclipse-plugin from my pom
installed the m2eclipse-scala plugin
re-imported the project as a maven project
all settings were detected correctly and I no longer saw the double entry of scala classes in my classpath.