- About Scala
- Documentation
- Code Examples
- Software
- Scala Developers
Scala 2.9.1 or 2.9.0.RC3 feature request; include parts of scala lib as option
Thu, 2011-04-28, 13:39
scala -save -addlib Foo.scala
Should generate a Jar with the needed classes of the Scala lib.
This would be very nice especially for small scripts that use the new
process package that comes from sbt into 2.9.0.RC1.
I test the new Scala runner in RC2.
create Hello.scala:
println("Hello")
> scala -save Hello.scala
generates Hello.jar
This includes 4 files and is less then 2kb.
>scala Hello.jar
shows Hello
This is very cool.
However
>java -jar Hello.jar
NoClassDefFoundError: scala/ScalaObject
...
I start Beyond Compare comparing my Hello.jar and scala-library.jar.
Then I add the missing class to my jar. Retry, add again ...
I end up with a jar with 69 kb and 32 files.
Now java -jar HelloPimpedWithScalaLib.jar
shows
Hello
This would make the deployment in an organization very easy.
The message "you must have java installed" is easier to understood
then
"you must have Scala 2.9.0 installed and please be sure that you don't
install Scala 2.8.1 or Scala 2.9.1. "
I guess the same function can be archived with ProGuard
http://proguard.sourceforge.net/manual/examples.html#scala
However this is an extra tool that the beginner must learn.
On 4/28/11 5:39 AM, Fusion wrote:
> scala -save -addlib Foo.scala
> Should generate a Jar with the needed classes of the Scala lib.
> This would be very nice especially for small scripts that use the new
> process package that comes from sbt into 2.9.0.RC1.
I like the idea, but it's a slippery slope all the way to proguard and
other bytecode manipulation tools. (Trust me, were we to take that
first step, there is no feature of proguard we would not see a ticket
for.) I would categorize this as a "bring the tools together in a nice
package" kind of project, and if you haven't noticed that is not exactly
our primary expertise. Probably better if one of you guys take this one
so we can fix more compiler bugs.