What is a "build manager" for scala in the scala ide extensions for Eclipse? - 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.

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)

When creating a maven module project, how to set language to 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.

Scala, Maven, Sbt and Eclipse

I am wondering what is the most efficient way to use Sbt and Eclipse together? There seems to be a Sbt Eclipse plugin but what is the generally recommended workflow post generating the eclipse config? It seems kind of wrong to then add dependencies via the Eclipse Maven plugin in Eclipse? Is that what people usually do though?
Kind of new to the ecosystem so maybe I'm missing something here.
I add maven dependencies in via the sbt config files. Then regenerate the eclipse project after each modification, keeping the sbt config as the definitive project specification. I suspect it's the only sane way to run the setup.
I use the IvyDE plugin for eclipse with sbt deliver-local.
The advantage here is it can give you separate classpath containers for different configurations easily and you don't need to blat your eclipse project settings regularly.
It'd be really nice if scala-ide supported tighter integration with sbt.

Working with a Scalatra application in an Eclipse workspace? (i.e. build path)

I am experimenting with a small Scalatra web application, which I have imported as a project into Eclipse.
I have used Eclipse to manage a few Lift applications before. With a Lift project, SBT copies all the dependency JAR's to a /lib_managed directory. I can therefore add those JAR's to Eclipse's build path, and it co-exists with SBT just fine without complaining about missing classes.
With Scalatra, however, the dependency JAR's don't seem to get copied anywhere helpful during the development cycle. If you build a WAR file, then the dependencies get bundled up into that... but there doesn't seem to be anything like Lift's /lib-managed directory.
Assuming that anyone else uses Eclipse in developing Scalatra projects, how might I easily set up Eclipse's build path? I suppose that I could manually create entries that point my local Ivy repository one-by-one, although that seems a bit ugly. Perhaps there's an easy way through SBT to setup something similar to Lift's /lib-managed subdirectory inside the project directory.
It looks like the best approach for this is using the SBT plugin for Eclipse.
This is not an "Eclipse plugin" for managing SBT. Rather, it's an "SBT plugin", for generating the .project and .classpath files used by Eclipse. The Maven world used to deal with Eclipse in a similar manner, before the m2eclipse Eclipse plugin reached maturity over the past couple years.
With this plugin installed (I installed it globally so I wouldn't have to change my project's files), you just type sbt eclipse after any changes to your dependencies. SBT will then update your Eclipse project files to match.
You could also use my Maven prototype, then simply import the maven project into Eclipse. Quite nice and you're not forced to use SBT.
https://github.com/fancellu/scalatra-maven-prototype

synchronising / maintaining ant and eclipse classpaths

I'd be interested to find out about any automated processes that people have for ensuring that the project classpaths for the ant and eclipse configurations are in synch. In my case, I want the classpath defined in the ant build file to be the master configuration, since its used for our production builds. As part of the build i'd like to add an ant target that will verify that the eclipse classpath is up to date, or at least indicate differences between the two classpaths.
I'm aware of ant4eclipse but its focus is in the opposite direction, ensuring that the eclipse classpath is master and that the ant build reuses the eclipse path. I like the idea behind AntAndEclipse but am wondering are their ant other tools in this space that i'm not aware of.
You solution at a previous company was to have ant invoke Eclipse to do the compiles as described here:
http://www.eclipse.org/articles/Article-PDE-Automation/automation.html
I'm not aware of any ant tools which can do this but I've switched from ant to Maven a few years ago and never looked back. You can use the "Maven integration for Eclipse" to make Eclipse use the Maven classpath.
As of today, I'm not 100% happy with the Eclipse plugin, though. It's a bit slow and due to the different philosophy of Eclipse and Maven, some operations behave strange. For example, Eclipse doesn't differentiate between a "production" and "test" classpath, so you can get compile errors in Maven when everything looks great in Eclipse.
My solution was to use the plugin to keep the classpath in sync and compile from the commandline.
there is an ant task to do xml transformations, we used that task to create the classpath in our build file. It was a little trick to get the XSL right but once it worked it was great
Did you evaluate Apache IVY? Currently I am building a Continuous Integration environment at our place and we use IVY to handle our dependencies. There is a eclipse plugin that takes the dependency configuration of eclipse and uses it as eclipse classpath.
Currently this solution looks quite promising.
My team wrote an Eclipse plug-in to add a new type of library to the Java Build Path->Add Library option in the project settings. This custom library type allowed both Eclipse and ANT to reference the same canonical list of dependencies.
Nowadays, I'd probably look at IVY for doing the same thing if I was locked into using ANT, rather than writing my own.
You need Ant2Eclipse.