alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Ant example source code file (rmic.xml)

This example Ant source code file (rmic.xml) is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - Ant tags/keywords

failingrmicadapter, failingrmicadapter, xnew, xnew

The rmic.xml source code

<?xml version="1.0"?>
<project name="rmic" default="teardown" basedir=".">

  <property name="rmic.dir" location="." />
  <property name="src.dir" location="${rmic.dir}/src"/>
  <property name="build.dir" location="${rmic.dir}/build"/>

  <target name="teardown">
    <delete dir="${build.dir}"/>
  </target>

  <!-- init builds the java source -->
  <target name="init" depends="probe-rmic">
    <mkdir dir="${build.dir}"/>

    <javac
      destdir="${build.dir}"
      srcdir="${src.dir}"
      includes="Remote*.java">
    </javac>

    <presetdef name="base-rmic">
      <rmic
        base="${build.dir}"
        verify="true"
        includes="**/*.class"/>
    </presetdef>

    <presetdef name="rmic-bad-class">
      <rmic
        base="${build.dir}"
        verify="false"
        classname="unimplemented.class"
        />
    </presetdef>

    <macrodef name="assertFileCreated">
      <attribute name="file" />
      <sequential>
        <fail>Not found : ${build.dir}/@{file}
          <condition>
            <not>
          </condition>
        </fail>
      </sequential>
    </macrodef>

    <macrodef name="assertFileAbsent">
      <attribute name="file" />
      <sequential>
        <fail>Expected to be missing : ${build.dir}/@{file}
          <condition>
            <available file="${build.dir}/@{file}"/>
          </condition>
        </fail>
      </sequential>
    </macrodef>

    
    <macrodef name="assertStubCompiled">
      <sequential>
        <assertFileCreated file="RemoteTimestampImpl_Stub.class"  />
      </sequential>
    </macrodef>

    <macrodef name="assertSkelCompiled">
      <sequential>
        <assertFileCreated file="RemoteTimestampImpl_Skel.class"  />
      </sequential>
    </macrodef>

    <macrodef name="assertSkelAbsent">
      <sequential>
        <assertFileAbsent file="RemoteTimestampImpl_Skel.class"  />
      </sequential>
    </macrodef>
    
    <macrodef name="assertBaseCompiled">
      <sequential>
        <assertStubCompiled />
        <assertSkelCompiled />
      </sequential>
    </macrodef>

    
    <macrodef name="assertAntStubCompiled">
      <sequential>
        <assertFileCreated file="AntTimestamp_Stub.class"/>
      </sequential>
    </macrodef>
    
    <macrodef name="assertAntSkelCompiled">
      <sequential>
        <assertFileCreated file="AntTimestamp_Skel.class"/>
      </sequential>
    </macrodef>

    <macrodef name="assertAntCompiled">
      <sequential>
        <assertAntStubCompiled />
        <assertAntSkelCompiled />
      </sequential>
    </macrodef>

  </target>
  
  <target name="probe-rmic">
    <available property="kaffe.present" classname="jkaffe.rmi.rmic.RMIC"/>
    <available property="rmic.present" classname="sun.rmi.rmic.Main"/>
    <available property="wlrmic.present" classname="weblogic.rmic"/>
    <condition property="rmic5.present">
      <and>
        <isset property="rmic.present"/>
        <available classname="java.net.Proxy"/>
      </and>
    </condition>
    <condition property="rmic6.present">
      <and>
        <isset property="rmic.present"/>
        <available classname="java.util.Service"/>
      </and>
    </condition>
  </target>

  <target name="testDefault" depends="init">
    <base-rmic compiler="default"/>
    <assertBaseCompiled/>
  </target>

  <target name="testEmpty" depends="init">
    <base-rmic compiler=""/>
    <assertBaseCompiled/>
  </target>

  <target name="testVersion11" depends="init">
    <base-rmic compiler="default" stubversion="1.1" />
    <assertBaseCompiled/>
  </target>

  <target name="testVersion12" depends="init">
    <base-rmic compiler="default" stubversion="1.2" />
    <assertStubCompiled/>
    <assertSkelAbsent/>
  </target>
  
  <target name="testVersionCompat" depends="init">
    <base-rmic compiler="default" stubversion="compat" />
    <assertBaseCompiled/>
  </target>
  
  <target name="testRmic" if="rmic.present" depends="init">
    <base-rmic compiler="sun"/>
    <assertBaseCompiled/>
  </target>

  <target name="testKaffe" if="kaffe.present" depends="init">
    <base-rmic
      compiler="kaffe"
      />
    <assertBaseCompiled/>
  </target>

  <target name="testWlrmic" if="wlrmic.present" depends="init">
    <base-rmic
      compiler="weblogic"
      />
  </target>

  <target name="testForking" if="rmic.present" depends="init">
    <base-rmic
      compiler="forking"
      />
    <assertBaseCompiled/>
  </target>

  <target name="testBadName" if="rmic.present" depends="init">
    <base-rmic
      compiler="no-such-compiler"
      />
  </target>

  <target name="testExplicitClass" if="rmic.present" depends="init">
    <base-rmic
        compiler="org.apache.tools.ant.taskdefs.rmic.SunRmic"
        />
    <assertBaseCompiled/>
  </target>
  
  <target name="testWrongClass" if="rmic.present" depends="init">
    <base-rmic
      compiler="org.apache.tools.ant.BuildException"
      />
  </target>

  <target name="testNoBase" depends="init">
    <rmic
      verify="true"
      includes="**/*.class"/>
  </target>

  <target name="testBaseDoesntExist" depends="init">
    <rmic
      base="${build.dir}/classes"
      verify="true"
      includes="**/*.class"/>
  </target>

  <target name="testBaseIsntDir" depends="init">
    <rmic
      base="${ant.file}"
      verify="true"
      includes="**/*.class"/>
  </target>

  <target name="testFailingAdapter" depends="init">
    <base-rmic
      compiler="org.apache.tools.ant.taskdefs.rmic.RmicAdvancedTest$FailingRmicAdapter"
      />
  </target>
  
  <target name="compileAntTimestamp" depends="init">
    <javac
      destdir="${build.dir}"
      srcdir="${src.dir}"
      includes="Ant*.java">
    </javac>
  </target>

  <target name="testAntClasspath" depends="compileAntTimestamp">
    <base-rmic
      compiler="default"
      />
    <assertAntCompiled/>
  </target>

  <target name="testForkingAntClasspath" if="rmic.present" depends="compileAntTimestamp">
    <base-rmic
      compiler="forking"
      />
    <assertAntCompiled />
  </target>

  <target name="testDefaultBadClass" depends="init">
    <rmic-bad-class compiler="default"/>
  </target>

  <target name="testMagicProperty" depends="init">
    <property name="build.rmic" value="no-such-adapter"/>
    <base-rmic
      />
  </target>

  <target name="testMagicPropertyOverridesEmptyString" depends="init">
    <property name="build.rmic" value="no-such-adapter"/>
    <base-rmic compiler=""
      />
  </target>

  <target name="testMagicPropertyIsEmptyString" depends="init">
    <property name="build.rmic" value=""/>
    <base-rmic />
    <assertBaseCompiled/>
  </target>

  <target name="testXnew" if="rmic5.present" depends="init">
    <base-rmic compiler="sun">
      <compilerarg value="-Xnew"/>
    </base-rmic>
    <assertBaseCompiled/>
  </target>

  <target name="testXnewForked" if="rmic5.present" depends="init">
    <base-rmic compiler="forking">
      <compilerarg value="-Xnew"/>
    </base-rmic>
    <assertBaseCompiled/>
  </target>

  <target name="testXnewCompiler" if="rmic5.present" depends="init">
    <base-rmic compiler="xnew">
    </base-rmic>
    <assertBaseCompiled/>
  </target>

  <target name="testIDL" depends="init">
    <base-rmic compiler="default" idl="true"/>
    <assertFileCreated file="RemoteTimestamp.idl"/>
  </target>

  <target name="testIIOP" depends="init">
    <base-rmic compiler="default" iiop="true"/>
    <assertFileCreated file="_RemoteTimestamp_Stub.class"/>
    <assertFileCreated file="_RemoteTimestampImpl_Tie.class"/>
  </target>

</project>

Other Ant examples (source code examples)

Here is a short list of links related to this Ant rmic.xml source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.