AIOTrade Is Migrating to Scala
Caoyuan Blog - - April 10, 2009Finally, after evaluated Erlang, Scala etc, wrote IDE tools for these languages, I began to migrate AIOTrade from Java to Scala, with the help of Scala for NetBeans of course.
The first step is re-writting basic modules to Scala smoothly, with little functional style code; Then, I’ll re-design the APIs by Scala’s advanced features, including function, trait, actors etc.
Since AIOTrade is a NetBeans suite project, with several NetBeans style modules integrated, I need a general purpose build.xml to get Scala based modules working. Here are build.xml and scala-build.xml, which can be used to write Scala based NetBeans platform modules.
First, you should create a regular NetBeans module project, then put/replace these ant files under your project’s base director. You also need to create 2 NetBeans lib wrapper modules, one is for scala-library.jar, another is for scala-compile.jar as parts of your NetBeans suite project (or, check them out from AIOTrade’s source repository)
build.xml:
<?xml version="1.0" encoding="UTF-8"?> <project name="lib.math" default="netbeans" basedir="."> <import file="scala-build.xml"/> </project>
scala-build.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project name="scala-module" default="netbeans" basedir="."> <import file="nbproject/build-impl.xml"/> <target name="scala-taskdef" depends="init"> <property name="scala.library" value="${cluster}/modules/ext/scala-library.jar"/> <property name="scala.compiler" value="${cluster}/modules/ext/scala-compiler.jar"/> <property name="scala.libs" value="${scala.library}:${scala.compiler}"/> <echo message="cluster: ${cluster}"/> <echo message="Compiling scala sources via ${scala.library}, ${scala.compiler}"/> <taskdef resource="scala/tools/ant/antlib.xml"> <classpath> <pathelement location="${cluster}/modules/ext/scala-library.jar"/> <pathelement location="${cluster}/modules/ext/scala-compiler.jar"/> </classpath> </taskdef> </target> <property name="jar-excludes" value="**/*.java,**/*.form,**/package.html,**/doc-files/,**/*.scala"/> <target name="compile" depends="init,up-to-date,scala-taskdef" unless="is.jar.uptodate"> <!-- javac's classpath should include scala.library and all these paths of "cp" --> <path id="javac.cp"> <pathelement path="${scala.libs}"/> <pathelement path="${module.classpath}"/> <pathelement path="${cp.extra}"/> </path> <!-- scalac will check class dependencies deeply, so we can not rely on public package only which is refed by ${module.classpath} --> <path id="scalac.cp"> <pathelement path="${scala.libs}"/> <pathelement path="${module.run.classpath}"/> <pathelement path="${cp.extra}"/> </path> <mkdir dir="${build.classes.dir}"/> <depend srcdir="${src.dir}" destdir="${build.classes.dir}" cache="build/depcache"> <classpath refid="scalac.cp"/> </depend> <!-- scalac --> <scalac srcdir="${src.dir}" destdir="${build.classes.dir}" encoding="UTF-8" target="jvm-${javac.target}"> <classpath refid="scalac.cp"/> </scalac> <!-- javac --> <nb-javac srcdir="${src.dir}" destdir="${build.classes.dir}" debug="${build.compiler.debug}" debuglevel="${build.compiler.debuglevel}" encoding="UTF-8" deprecation="${build.compiler.deprecation}" optimize="${build.compiler.optimize}" source="${javac.source}" target="${javac.target}" includeantruntime="false"> <classpath refid="javac.cp"/> <compilerarg line="${javac.compilerargs}"/> <processorpath refid="processor.cp"/> </nb-javac> <!-- Sanity check: --> <pathconvert pathsep=":" property="class.files.in.src"> <path> <fileset dir="${src.dir}"> <include name="**/*.class"/> </fileset> </path> </pathconvert> <fail> <condition> <not> <equals arg1="${class.files.in.src}" arg2=""/> </not> </condition> You have stray *.class files in ${src.dir} which you must remove. Probably you failed to clean your sources before updating them. </fail> <!-- OK, continue: --> <copy todir="${build.classes.dir}"> <fileset dir="${src.dir}" excludes="${jar-excludes}"/> </copy> </target> <target name="do-test-build" depends="projectized-common.do-test-build"> <scalac srcdir="${test.unit.src.dir}" destdir="${build.test.unit.classes.dir}" excludes="${test.excludes}" encoding="UTF-8"> <classpath refid="test.unit.cp"/> </scalac> </target>
</project>
BTW, the new source code of AIOTrade is controlled under Mercurial version control system on sourceforge.net, you can clone or brows the code at: AIOTrade source repository
Note: The whole project can not be successfully built yet.
Categories: Blogs Caoyuan Blog
Comments
Add comment
Erlang on Twitter
» dessyrosalia (♡pesek mancung♥ ): Erlang ke rumahku donk kangen nih
» si_erlang (Erlangga Adhitya): 75% dalane jahanam
» GeekDani (Dani Kim): @charsyam 그렇군용. :-) 여긴 서늘한데. 크크. Erlang Meetup 준비는 잘 하시나요. ㅋㅋ
» syahlafatimahA (LalaTik(ʃ⌣ƪ) ): Waaa?! Si erlang suka cherrybelle(?) wkwkwkwk ngakak aih xD
» yosukehara (Yosuke Hara): I’ll be a simple test for benchmarking JSX and Jiffy together. #erlang
» Debbyvheumen (Debby van Heumen): @elisaaa15 @kleingeld_ haha okee succes :) blijven jullie erlang
» ovatsus (Gustavo Guerra): RT @martintrojer: Just *blogged “Distributed Actors in Clojure” on http://t.co/WcKBpNBR #Clojure #Akka #Erlang #in
» larshesel (Lars Hesel): ...or rather: 4 days of Erlang hacking coming up!
» hongye_erlang (紅葉): とりあえずチャイナ。
» Erlang_ABNIC (Erlangga .A): RODOK !!! Dtakok"I genah” jawabane malah ngelantur! (N)
Statistics
Number of aggregated posts: 10498
Number of comments: 2115
Most recent article: May 15, 2012
Latest comments
» cheap soccer jerseys on Memory Models in Erlang vs Java: Nice discussion here,you are doing a great job. i was looking for this information. i found it on your page…
» mandesejohn on Couchbase Meetup at new HQ: Thanks for sharing experience. It should be really a great post. It should be knowledgeable and informative. Keep it up. flower delivery columbus ohio
» vermaseo on Scale means Skills: I’m surprised people are still commenting about this. George has been moved on to bigger and better things with the president for awhile now.ledikanten