scalaからjarを作る。

OSはLinuxと言うことでメモがわりに。まずは、対象となる定番のHello World
HelloWorld.scala

object HelloWorld { 
  def main(args: Array[String]):Unit = println("Hello World!!!")
}

Manifest.mf

Manifest-Version: 1.0
Main-Class: HelloWorld
Class-Path: scala-library.jar  

Makefile

TARGET=HelloWorld

SCALA_LIB_PATH=/usr/local/scala/lib

MANIFEST=Manifest.mf
SRCS=HelloWorld.scala
OBJS=${SRCS:.scala=.class}

%.class: %.scala
	scalac $<

$(TARGET).jar: $(OBJS) $(MANIFEST)
	jar -cfm $@ $(MANIFEST) *.class 
	jar -i $@ $(SCALA_LIB_PATH)/scala-library.jar

all: $(TARGET).jar

clean:
	rm -rf *.class $(TARGET).jar *~