I need to use Scala's XML processing capabilities, but the XML library has been removed from Scala 2.11.x. On Scala's website, it shows instructions on how to get the library using SBT. I don't use SBT -- I use their Eclipse editor (the Scala IDE). How / where do I get the XML libraries when using the Scala IDE?
You can download required version from Scala site. In extracted archive find
scala/scala-2.11.4/lib/scala-xml_2.11-1.0.2.jar
Just add this jar to your Eclipse project Build Path.
Related
I have a Eclipse project (Xtext) and want to use Scala code in the project.
The Scala code also need to use a Scala library which uses sbt.
That will be the best way to perform this integration in 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.
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.
I have configured a project to use scala/maven/Eclipse. Because I need a scala library on the build path and scalatest also uses its own scala library I receive this warning :
More than one scala library found in the build path, all with
compatible versions. This is not an optimal configuration, try to
limit to one scala library in the build path.
I don't think I can remove this warning as I need both libraries - one for Maven, the other for Eclipse. This doesn't seem to be causing any problems so will I just have to accept it? Is there an alternate configuration which uses just one scala library for Maven & Eclipse?
If I remove the scala library from the project I receive the error:
Cannot find Scala library on the classpath. Verify your build path!
For some reason Eclipse requires the scala library to be on the build path even though it is already available as a Maven dependency.
There is nothing to worry about. Eclipse warns you that you have several scala-library.jars on your classpath, but as long as they are the same version, it doesn't matter.
If one of them diverged (for instance, by bumping the Scala version number in your pom file), you'd be in trouble: depending on the classpath order, the IDE will pick up classes from one or the other, and you might get different results when building on the command line.
Coming back to your setup, you could
remove the Scala Library classpath container from your Eclipse projects, leaving just the jar that maven adds.
ignore the warning
Venturing a guess here, are you using the Eclipse Indigo pre-installed with Scala 2.9 and the corresponding Scala plugin? If that's the reason you need to use that library, perhaps consider using Eclipse Juno? That's what I use and it works quite well with both the milestone and the nightly builds
What's the recommended way of getting Scala IDE for Eclipse to reference the scala-compiler.jar?
I encountered this issue while trying to develop a custom DSL that gets translated into Scala at runtime.
Using Scala parser combinators has been a sheer pleasure so far.
So now I have some generated Scala code that I need to compile and run. Scala supports this through the scala.tools.nsc.* package set.
However, the scala.tools.nsc package is not part of scala-library.jar, but rather a part of scala-compiler.jar.
As far as I can tell, the scala-compiler.jar is not installed as part of the bundle of Scala IDE for Eclipse (though it is part of the plug in), and I can't find any simple way to add support for it.
The only way around this seems to be manually adding a reference to the compiler jar, either from the Eclipse plugin directory or from a version downloaded directly from the web. Even if that works, however, it seems like a great way to run into problems down the road.
So, what's the best way to do this?
Cheers,
Or
You're right that it's best to manually add the dependency rather than use the one that is bundled with Eclipse. If you're not using one already, look at a build system which does dependency resolution such as maven or ivy, or more in the Scala vein, sbt.
If you're not developing a plugin, then just use the normal dependency resolution in maven, or ivy or whatever. This is what you need for maven:
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-compiler</artifactId>
<version>2.9.1</version>
</dependency>
If you are developing a plugin, then you can use a similar dependency resolution, but if you're using maven, you'll probably want to look at Tycho.
It's simple: The Scala IDE for Eclipse comes with a Library called "Scala Compiler". Just select "Build Path > Add Libraries ..." from your Scala project's context menu and select the "Scala Compiler" library from the dialog.