AIOTrade Is Migrating to Scala

Caoyuan Blog - - April 10, 2009

Finally, 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

anonymous avatar

i hope you can finish this dude
gelinlik
yarış oyunları

Posted by haven on 01 Sep 2009 at 16:10



 


Add comment

Name:

Email:

URL:

Smileys

Remember my personal information

Notify me of follow-up comments?