Project configuration redesign [OUTDATED INFO]
A lot of feedback (tracker, forum, twitter, blogs) suggest that the legacy (facet-based) way of configuring Scala in IDEA is too confusing for most new users. Moreover, such approach has several inherent shortcomings.
The following limitations were discovered:
- there’s no natural connection to Scala distribution (that is the only “Scala” most novices know),
- initial wizard doesn’t download sources and API docs (so it’s a disservice),
- duplication is required (module needs both Scala facet and Scala library attached),
- possible mismatch between compiler and libraries versions (because of the separation),
- facet can’t be referenced (so there’s no way to share the same compiler configuration between modules).
Having regard to the above-listed problems, we decided to re-design Scala configuration. The new method assumes the following:
- Scala "SDK" is a special library that includes scala-library*.jar. It unites jars, sources, API docs and compiler.
- Scala "SDK" can be automatically created from Scala distribution (with all jars, sources and API docs). Distribution directory may be automatically located using SCALA_HOME or PATH environment variables (see Getting Started With Scala). API docs are expected to be placed to “docs” directory inside distribution home (SCALA_HOME/docs/api should exists).
- Any module that includes such "SDK" library in "Dependencies" is meant to be compiled using Scala compiler associated with attached library.
- Compiler is discovered implicitly, either in the same directory that holds scala-library*.jar, or in the Maven repository (still, relatively to attached scala-library*.jar). Scala compiler library may (or may not) be explicitly attached to Scala SDK.
- Scala "SDK" can be shared between modules. Global, project-level and module-level SDKs are allowed. Each module may use its own version of Scala.
- Scala "SDK" can be created manually.
Here's an example of library creation wizard (project or new module creation):
Facets are now obsolete and may be deleted (using “Delete” button below “Error loading facets” message).
Don't forget that "Scala SDK" is not a real SDK in IDEA, it's a library, for all that.
The solution isn't perfect (because we somehow limited by IDE configuration primitives), but it seems to be the lesser evil. We hope that the new approach will make project configuration more straightforward (as well as it will simplify initial IDEA + Scala setup for newcomers).
P.S. Bugs happen, you know... Please, report them to our tracker.
Please sign in to leave a comment.
i assume there should be an image on your post?
I don't know about "should be," but "is" definitely applies.
RRS
firefox 4 doesn't show one. anyway, i cannot create a scala module using the current nightly build and cannot add a scala sdk, just the usual java ones.
> cannot add a scala sdk, just the usual java ones
"Scala SDK" is not an "SDK", it's a library that includes Scala's jar.
Real Idea SDKs are system-wide (no project- or module-level SDKs) and excluded from artifacts element list, so we can't use them as configuration primitives.
> i cannot create a scala module using the current nightly build
Please, clarify what exactly goes wrong with module creation?
found it, had to click "next" a few more times
When I started 9.0.3 with build 1888, it said it could not load my Scala facets and they disappeared. So I searched the forum and found this thread.
I would like to specify that everything appears to still work, but from the perspective of someone with multiple existing Scala modules that manage their dependencies using Maven, I don't understand what happened or what I should do.
As an aside, I never found the Scala facet confusing, and found it in fact very useful to explicitly highlight that some of my Scala modules were migrating from 2.7.7 to various RCs of 2.8.0. Like a lot of developers who went through this change, I have 2.7.7 final, various RCs of 2.8.0, and 2.8.0 final knocking around in locations which the Scala plugin might conceivably be resolving.
Now that my Scala facets are gone, an explicit configuation has been replaced with something implicit that leaves me to wonder - are my modules now using:
I have no idea where or how to add this "Scala SDK" - in IDE settings? In project settings? I'm going crazy trying to find it in module settings, where all my libs are Maven deps anyway. Do I need to add one?
Could someone please provide step-by-step instructions for creating this Scala SDK? The screenshot of the wizard would be useful if I could figure out how to get to the wizard in the first place. Thanks!
I'm not criticizing anyone's rationale for the change, which is probably good, but I'm finding it a bit opaque in actual use.
> Now that my Scala facets are gone, an explicit configuation has been replaced with something implicit that leaves me to wonder - are my modules now using:
There's just one option - each module uses a compiler associated with attached Scala library.
> Could someone please provide step-by-step instructions for creating this Scala SDK?
Create a library that contains "scala-library" jar, attach it to a module, "scala-compiler" jar should be in the same directory (or in the maven repository).
> I'm not criticizing anyone's rationale for the change, which is probably good, but I'm finding it a bit opaque in actual use.
So do I ;) - explicit configuration will be back soon.
The info above is outdated, please, don't refer to it (facets returned).
Hooray! That's great news.
Where can I find some info on the new facet system, particularly on the following
- How to make a library be recognised as a valid Scala compiler?
- What is a plugin in the Scala facet? Is that a Scala compiler plugin?
- Confirmation that the compiler classpath does not leak into the project classpath.
In any case, I am sure that all the IDEA users in the Scala development team will join me to thank you for rethinking the redesign.
Thanks, Pavel, I was so happy to see the facets back!
Gilles, I set up my facets last night and everything seems to be working.
Here what I did:
My project uses Maven to manage dependencies, so Idea shows a Maven library called "Maven: org.scala-lang.scala-compiler:2.8.0".
I went into the project settings and added a Scala facet for each project. In the Compiler dropdown, I saw it had detected the Maven library "Maven: org.scala-lang.compiler:2.8.0". However, when I tried to run Scala console, it gave me a cryptic error about a missing option.
So I referred back to what Pavel said earlier in the thread. I opened the project structure, went to the global library section, and created a library called "Scala-2.8.0-final" and clicked the attach classes button to add all the jars from scala-2.8.0-final/lib directory. Then I clicked Apply at the bottom.
Then I went back to my modules and saw that the Scala facet Compiler dropdown had detected the new "Scala-2.8.0-final" global library. So I selected it for each module. For some reason, one of my modules still only showed "Maven: org.scala-lang.scala-compiler:2.8.0" in the Compiler dropdown, but after closing and restarting Idea I was able to select "Scala-2.8.0-final" for this module too.
I am using build 1957, the latest nightly. The past few nightly builds seem to be rather slow on my machine for some reason (no idea why, the 18xx builds were speedy), but hopefully whatever performance issues there are will be solved soon.
Hope this helps!
Here's a brief clarification.
(the latest nightly build adds some UI improvements but may require re-selection of compiler library in facets)