Version 0 of automating itclproxy from ant

Updated 2016-04-29 22:55:19 by kurtseel

This is a follow on for http://wiki.tcl.tk/43983 . It is a 'work in progress'.

I wanted to add some build/test-ing automation for wrapping some java classes in JACL/JTCL. Doing some research for this I discovered Tom Poindexter's excellent itclproxy package within AEjaks that does all the hard work of mapping a javaclass to an Itcl class so I added some ant (-contrib) stuff.

Set up classpath (build.xml). I did this on freebsd, so system installed jars are in /usr/local/share/java/classes/. I threw any extra jars I was concerned with into ./lib/.

<path id="java.classpath">
        <fileset dir="${basedir}/lib/">
                <include name="*/**.jar"/>
        </fileset>
        <fileset dir="/usr/local/share/java/classes/">
                <include name="*.jar"/>
        </fileset>
        <filelist dir="${env.HOME}/.ant/lib/lang/">
                <file name="jtcl-2.8.0.jar"/>
                <file name="jtcl-engine.jar"/>
        </filelist>
</path>

I used a fileset and the ant-contrib for loop to automate processing template files. I picked the extension .gen to differentiate them.

<!-- ....................................................................... -->
<!-- generate Itcl proxies -->
<target name="gen">
        <for param="genfile">
                <path>
                        <fileset dir="./src/" includes="**/*.gen"/>
                </path>
                <sequential>
                        <echo>Running @{genfile}</echo>
                        <script language="jtcl" classpathref="java.classpath">
                                lappend auto_path ./library/ 
                                if \
                                { 
                                        [catch { source @{genfile} 
                                } ERR] } { puts "\t ERR is $ERR"; exit }
                        </script>
                </sequential>
        </for>
</target>

I pulled out the itclproxy.tcl from a recent distribution of AEjaks and put it in ./library/itclproxy/. A simple .gen file looks like :

package require itclproxy

itclproxy::mkItclProxy \
        ::utcorp::org::jdom2::attribute \
        org.jdom2.Attribute \
        -file src/utcorp/org/jdom2/attribute.tcl \
        -create y