This page is no longer maintained — Please continue to the home page at www.scala-lang.org

Compiling with eclipse plugin

1 reply
Niels Boldt
Joined: 2008-12-26,
User offline. Last seen 42 years 45 weeks ago.
Hi

I'm trying to embed the scala compiler into scala so scala can be used as a scripting language and has succesfully compiled the following piece using 'scalac'

package dk

 import scala.tools.nsc.{Global, Settings}
 import scala.tools.nsc.reporters.ConsoleReporter

object Hello {

    def main(args: Array[String]) {

             // called in the event of a compilation error
             def error(message: String): Unit = println("imaginary part: ")

             val settings = new Settings(error)
             //settings.outdir.value = classesDir.getPath
             settings.deprecation.value = true // enable detailed deprecation warnings
             settings.unchecked.value = true // enable detailed unchecked warnings

             val reporter = new ConsoleReporter(settings)

             val compiler = new Global(settings, reporter)
             (new compiler.Run).compile("")

    }



}

However, if I use the eclipse plugin for scala and creates a project I cannot get the above code compiled, because I can't make the project reference the scala-compiler.jar. I have tried to add the jar, but how do I get it added as a scala dependency.

Best Regards
Niels





--
BinaryConstructors ApS
Vestergade 10a, 4th
1456 Kbh K
Denmark
phone: +4528138757
web: http://www.binaryconstructors.dk
mail: nb [at] binaryconstructors [dot] dk
skype: nielsboldt
Sean McDirmid
Joined: 2008-12-17,
User offline. Last seen 42 years 45 weeks ago.
Re: Compiling with eclipse plugin
Just use the Java build manager to add a reference to scala-compiler.jar. 
Alternatively, you can use SVN to check the scala/plugin project out and follow the instructions for building the plugin (just work backwords from the plugin project).

On Sat, Dec 27, 2008 at 6:32 AM, Niels Boldt <nielsboldt [at] gmail [dot] com> wrote:
Hi

I'm trying to embed the scala compiler into scala so scala can be used as a scripting language and has succesfully compiled the following piece using 'scalac'

package dk

 import scala.tools.nsc.{Global, Settings}
 import scala.tools.nsc.reporters.ConsoleReporter

object Hello {

    def main(args: Array[String]) {

             // called in the event of a compilation error
             def error(message: String): Unit = println("imaginary part: ")

             val settings = new Settings(error)
             //settings.outdir.value = classesDir.getPath
             settings.deprecation.value = true // enable detailed deprecation warnings
             settings.unchecked.value = true // enable detailed unchecked warnings

             val reporter = new ConsoleReporter(settings)

             val compiler = new Global(settings, reporter)
             (new compiler.Run).compile("")

    }



}

However, if I use the eclipse plugin for scala and creates a project I cannot get the above code compiled, because I can't make the project reference the scala-compiler.jar. I have tried to add the jar, but how do I get it added as a scala dependency.

Best Regards
Niels





--
BinaryConstructors ApS
Vestergade 10a, 4th
1456 Kbh K
Denmark
phone: +4528138757
web: http://www.binaryconstructors.dk
mail: nb [at] binaryconstructors [dot] dk
skype: nielsboldt

Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland