Andy Malakov software blog

Thursday, June 12, 2008

Ant task for IKVMC

Submitted Ant task for IKVMC - ant-ikvmc. I found multiple FileSet elements in Ant more convenient in defining source classes than -recurse:mask command line argument provided by IKVMC.

Example of task:

<ikvmc target="library" out="${dotnet.out}/uhfclient.dll" home="${ikvm.home}" version="" debug="true"  verbose="true">
<reference path="${dotnet.out}/uhfc-3rd-party.dll"/>
<fileset dir="${classes}" includes="${uhfdll.resources}">
<exclude name="**/*.vpp"/>
<exclude name="**/*.txt"/>
<fileset dir="${jars}">
<include name="**/*.jar"/>
<exclude name="foo.jar"/>

Bonus: Java doclet that generates IKVMC mapping file. Among other things mapping file can specify parameter names in methods and constructors translated by IKVMC. Since Java parameter names are not available from Java class files, IKVMC needs this hint to preserve original Java names. This is handy if you generate API libraries that will be used by .NET developers.

Here is an example of javadoc task to generate IKVM mapping file for selected packages:

 <javadoc sourcepath="${src}" classpath="${javac.classpath}" defaultexcludes="yes">
   <doclet name="" path="${classes}">
     <param name="-out" value="${mapfile}"/>
   <package name="com.acme.api"/>
   <package name="com.acme.util"/>