Scala system scripts support in Eclipse plugin
Currently it is very inconvenient to use Eclipse plugin for system Scripting with Scala. There are few reason for it.
I will try to enumerate them from most important:
1. Scala plugin does not support shebang (!#) syntax for scala files. (see also scala tool description -> reference below). Because of that syntax highlighting and syntax checking doesn't work, as file is not recognized as scala file.
2. It's not possible to execute such a file from Eclipse
3. Eclipse Scala Project is in my opinion too heave weight for Scala system scripting. You have to create whole project project which clutter script directory with /bin /src /.cache /.classpath /.project.
In case of system scripting I would rather not clutter scripts directories with anything else than .project file. /bin directory should be somewhere in internal path and ./src directory should be directory where .project exists. All files and dependencies (other source files and *.jar files) should be added manually to such a project.
My current workarounds:
1. I copy body of scala code from <name>.sh file into <name>.scala file
2. I have to add:
into *.scala file as script files does not have to be in any object
3. in *.sh file I import script object and execute main()
Well, I am right now fiddling with this solution and it doesn't work as I would like to... It's really difficult to get it right...
I enumerated all enhancements, which would ease working with system scripts in Eclipse. But really important are just 1) and 2). It would be really great if only this two could be implemented.
Related pages:
http://stackoverflow.com/questions/1502110/using-scala-as-a-scripting-language-from-eclipse
http://www.scala-lang.org/docu/files/tools/scala.html --> Description part
I will try to enumerate them from most important:
1. Scala plugin does not support shebang (!#) syntax for scala files. (see also scala tool description -> reference below). Because of that syntax highlighting and syntax checking doesn't work, as file is not recognized as scala file.
2. It's not possible to execute such a file from Eclipse
3. Eclipse Scala Project is in my opinion too heave weight for Scala system scripting. You have to create whole project project which clutter script directory with /bin /src /.cache /.classpath /.project.
In case of system scripting I would rather not clutter scripts directories with anything else than .project file. /bin directory should be somewhere in internal path and ./src directory should be directory where .project exists. All files and dependencies (other source files and *.jar files) should be added manually to such a project.
My current workarounds:
1. I copy body of scala code from <name>.sh file into <name>.scala file
2. I have to add:
object MyScript {
def main(args: Array[String]) {
<code>
}
}
into *.scala file as script files does not have to be in any object
3. in *.sh file I import script object and execute main()
import scripts.MyScript
object Script {
def main(args: Array[String]) { MyScript.main(args) }
}
Well, I am right now fiddling with this solution and it doesn't work as I would like to... It's really difficult to get it right...
I enumerated all enhancements, which would ease working with system scripts in Eclipse. But really important are just 1) and 2). It would be really great if only this two could be implemented.
Related pages:
http://stackoverflow.com/questions/1502110/using-scala-as-a-scripting-language-from-eclipse
http://www.scala-lang.org/docu/files/tools/scala.html --> Description part
Leave a comment
The scala-worksheet (https://github.com/scala-ide/scala-worksheet/) should fit well for this type of usage.