Updated 2016-04-30 00:57:13 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 dir="/usr/local/share/java/classes/">
                <include name="*.jar"/>
        <filelist dir="${env.HOME}/.ant/lib/lang/">
                <file name="jtcl-2.8.0.jar"/>
                <file name="jtcl-engine.jar"/>

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">
                        <fileset dir="./src/" includes="**/*.gen"/>
                        <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 }

I pulled out the itclproxy.tcl from a recent distribution of AEjaks and put it in ./library/itclproxy/ along with a simple pkgIndex.tcl. 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 

As a side point, you can get to swank too (I compiled 3.0.0 against jtcl 2.8.0, it seems to work ...). This 'goes around' the apache BSF system. It should be possible through some incantation of 'import org.apache.ant.' to access the ant project that calls it.
<target name="wisk">
                <arg line="-swkcon"/>