Skip to content

Instantly share code, notes, and snippets.

@muzimka
Created January 21, 2016 22:10
Show Gist options
  • Save muzimka/95d91ab49de05e83dd55 to your computer and use it in GitHub Desktop.
Save muzimka/95d91ab49de05e83dd55 to your computer and use it in GitHub Desktop.
<target name="util" description="Compile ./mindview/util">
<mkdir dir="bin"/>
<echo>Compile "${srcdir}"</echo>
<javac
includeantruntime="false"
destdir = "${destdir}"
classpath="${classpath}"
srcdir="${src_util}">
<compilerarg value="-Xmaxerrs"/>
<compilerarg value="10"/>
</javac>
<echo>Compiling './mindview/util' succeeded</echo>
</target>
<target name="atunit" depends="util" description="Compile ./mindview/atunit" >
<mkdir dir="bin"/>
<echo>Compile "${srcdir}"</echo>
<javac
includeantruntime="false"
destdir = "${destdir}"
classpath="${classpath}"
srcdir="${src_atunit}">
<compilerarg value="-Xmaxerrs"/>
<compilerarg value="10"/>
</javac>
<echo>Compiling './mindview/atunit' succeeded</echo>
</target>
<target name="simple" depends="atunit"
description="Compile ./mindview/simple"
>
<fail message="J2SE5 required" unless="version1.8"/>
<fail
Unless="javassist"
message="You must install the Javassist library from http://sourceforge.net/projects/jboss/"/>
<javac
classpath="${classpath}"
srcdir="${src_simple}"
destdir="${destdir}"
includeantruntime="false"
>
<compilerarg value="-Xmaxerrs"/>
<compilerarg value="10"/>
</javac>
<echo message="Build 'simple' succeeded"/>
</target>
@williamdunstanmorris
Copy link

Hello -

I have been linked this from a comment you made on installing TIJ4-Solutions with IntelliJ. I am trying to follow your tutorial! Thank you so far. Everything has worked. However, i am confused about what to do when you say this, and link to this page. What should I do to 'create a target'?

'Create targets for compiling util simple and so on See the following link with code Code with targets '

Wheb i procude with the next step, I get this error from Temrinal CMD:

BUILD FAILED
Target "simple" does not exist in the project "Thinking in Java, 4th Edition Solution Guide (chapter: net)".

Total time: 8 seconds

Can you possibly tell me what i should do to create the target and what i should do with this code?

Many thanks

Will

@selsej
Copy link

selsej commented Apr 14, 2020

I would second Wills question, since I am stuck at this step as well (Create targets for compiling util simple and so on See the following link with code Code with targets
You can modify exists targets not to write all the code).

@taylors1512
Copy link

This is what I had to get it working:


<?xml version="1.0" ?>

<project
 basedir="."
 default="simple"
 name="Thinking in Java, 4th Edition by Bruce Eckel (chapter: net)">

  <description>
    build.xml for the source code for the net chapter of
    Thinking in Java, 4th Edition by Bruce Eckel
    Source code available at http://www.MindView.net
    See copyright notice in CopyRight.txt

    Ant available from: http://jakarta.apache.org/ant

    To see options, type: ant -p

    This file was automatically generated by AntBuilder
  </description>

  <property name = "classpath" value="./;./javassist.jar"/>
  <property name = "src_util" value="./mindview/util"/> 
  <property name = "src_simple" value="./mindview/simple"/> 
  <property name = "src_atunit" value="./mindview/atunit"/> 
  <property name = "destdir" value="bin"/>

  <condition property="version1.15">
    <equals arg1="1.15" arg2="${ant.java.version}"/>
  </condition>

  <available
    classname="javassist.bytecode.ClassFile"
    classpath="${classpath}"
    property="javassist"/>

    <target name="util" description="Compile ./mindview/util">

      <mkdir dir="bin"/>
      <echo>Compile "${srcdir}"</echo>
      <javac includeantruntime="false" destdir="${destdir}" classpath="${classpath}" srcdir="${src_util}">

        <compilerarg value="-Xmaxerrs"/>
        <compilerarg value="10"/>
      </javac>

      <echo>Compiling './mindview/util' succeeded</echo>
    </target>

    <target name="atunit" depends="util" description="Compile ./mindview/atunit">

      <mkdir dir="bin"/>
      <echo>Compile "${srcdir}"</echo>
      <javac includeantruntime="false" destdir="${destdir}" classpath="${classpath}" srcdir="${src_atunit}">

        <compilerarg value="-Xmaxerrs"/>
        <compilerarg value="10"/>
      </javac>

      <echo>Compiling './mindview/atunit' succeeded</echo>

    </target>

    <target name="simple" depends="atunit" description="Compile ./mindview/simple">

      <fail Unless="javassist" message="You must install the Javassist library from http://sourceforge.net/projects/jboss/"/>

      <javac classpath="${classpath}" srcdir="${src_simple}" destdir="${destdir}" includeantruntime="false">
        <compilerarg value="-Xmaxerrs"/>
        <compilerarg value="10"/>
      </javac>
      <echo message="Build 'simple' succeeded"/>
    </target>

  <target name="net_mindview_util">
    <javac
     classpath="${basedir}/.."
     srcdir="${basedir}/../net/mindview/util/">
      <compilerarg value="-Xmaxerrs"/>
      <compilerarg value="10"/>
    </javac>
  </target>

  <target
   depends="net_mindview_util"
   description="Build all classes in this directory"
   name="build">
    <fail message="J2SE5 required" unless="version1.15"/>
    <fail
     Unless="javassist.bytecode.ClassFile"
     message="You must install the Javassist library from http://sourceforge.net/projects/jboss/"/>
    <echo message="Building 'net'"/>
    <javac
     classpath="${basedir}/.."
     debug="true"
     srcdir="${basedir}">
      <compilerarg value="-Xmaxerrs"/>
      <compilerarg value="10"/>
    </javac>
    <echo message="Build 'net' succeeded"/>
  </target>

  <target name="AtUnit">
    <java
     classname="net.mindview.atunit.AtUnit"
     classpath="${java.class.path};${basedir};${basedir}/.."
     dir="../net/mindview/atunit/"
     failonerror="true"
     fork="true"/>
  </target>

  <target name="AtUnitRemover">
    <java
     classname="net.mindview.atunit.AtUnitRemover"
     classpath="${java.class.path};${basedir};${basedir}/.."
     dir="../net/mindview/atunit/"
     failonerror="true"
     fork="true">
      <arg line=".."/>
    </java>
  </target>

  <target name="ClassNameFinder">
    <java
     classname="net.mindview.atunit.ClassNameFinder"
     classpath="${java.class.path};${basedir};${basedir}/.."
     dir="../net/mindview/atunit/"
     failonerror="true"
     fork="true"/>
  </target>

  <target name="Test">
    <java
     classname="net.mindview.atunit.Test"
     classpath="${java.class.path};${basedir};${basedir}/.."
     dir="../net/mindview/atunit/"
     failonerror="true"
     fork="true"/>
  </target>

  <target name="TestObjectCleanup">
    <java
     classname="net.mindview.atunit.TestObjectCleanup"
     classpath="${java.class.path};${basedir};${basedir}/.."
     dir="../net/mindview/atunit/"
     failonerror="true"
     fork="true"/>
  </target>

  <target name="TestObjectCreate">
    <java
     classname="net.mindview.atunit.TestObjectCreate"
     classpath="${java.class.path};${basedir};${basedir}/.."
     dir="../net/mindview/atunit/"
     failonerror="true"
     fork="true"/>
  </target>

  <target name="TestProperty">
    <java
     classname="net.mindview.atunit.TestProperty"
     classpath="${java.class.path};${basedir};${basedir}/.."
     dir="../net/mindview/atunit/"
     failonerror="true"
     fork="true"/>
  </target>

  <target name="List">
    <java
     classname="net.mindview.simple.List"
     classpath="${java.class.path};${basedir};${basedir}/.."
     dir="../net/mindview/simple/"
     failonerror="true"
     fork="true"/>
  </target>

  <target name="Vector">
    <java
     classname="net.mindview.simple.Vector"
     classpath="${java.class.path};${basedir};${basedir}/.."
     dir="../net/mindview/simple/"
     failonerror="true"
     fork="true"/>
  </target>

  <target name="BasicGenerator">
    <java
     classname="net.mindview.util.BasicGenerator"
     classpath="${java.class.path};${basedir};${basedir}/.."
     dir="../net/mindview/util/"
     failonerror="true"
     fork="true"/>
  </target>

  <target name="BinaryFile">
    <java
     classname="net.mindview.util.BinaryFile"
     classpath="${java.class.path};${basedir};${basedir}/.."
     dir="../net/mindview/util/"
     failonerror="true"
     fork="true"/>
  </target>

  <target name="CollectionData">
    <java
     classname="net.mindview.util.CollectionData"
     classpath="${java.class.path};${basedir};${basedir}/.."
     dir="../net/mindview/util/"
     failonerror="true"
     fork="true"/>
  </target>

  <target name="ContainerMethodDifferences">
    <java
     classname="net.mindview.util.ContainerMethodDifferences"
     classpath="${java.class.path};${basedir};${basedir}/.."
     dir="../net/mindview/util/"
     failonerror="true"
     fork="true"/>
  </target>

  <target name="ConvertTo">
    <java
     classname="net.mindview.util.ConvertTo"
     classpath="${java.class.path};${basedir};${basedir}/.."
     dir="../net/mindview/util/"
     failonerror="true"
     fork="true"/>
  </target>

  <target name="CountingGenerator">
    <java
     classname="net.mindview.util.CountingGenerator"
     classpath="${java.class.path};${basedir};${basedir}/.."
     dir="../net/mindview/util/"
     failonerror="true"
     fork="true"/>
  </target>

  <target name="CountingIntegerList">
    <java
     classname="net.mindview.util.CountingIntegerList"
     classpath="${java.class.path};${basedir};${basedir}/.."
     dir="../net/mindview/util/"
     failonerror="true"
     fork="true"/>
  </target>

  <target name="CountingMapData">
    <java
     classname="net.mindview.util.CountingMapData"
     classpath="${java.class.path};${basedir};${basedir}/.."
     dir="../net/mindview/util/"
     failonerror="true"
     fork="true"/>
  </target>

  <target name="Countries">
    <java
     classname="net.mindview.util.Countries"
     classpath="${java.class.path};${basedir};${basedir}/.."
     dir="../net/mindview/util/"
     failonerror="true"
     fork="true"/>
  </target>

  <target name="DaemonThreadFactory">
    <java
     classname="net.mindview.util.DaemonThreadFactory"
     classpath="${java.class.path};${basedir};${basedir}/.."
     dir="../net/mindview/util/"
     failonerror="true"
     fork="true"/>
  </target>

  <target name="DaemonThreadPoolExecutor">
    <java
     classname="net.mindview.util.DaemonThreadPoolExecutor"
     classpath="${java.class.path};${basedir};${basedir}/.."
     dir="../net/mindview/util/"
     failonerror="true"
     fork="true"/>
  </target>

  <target name="Deque">
    <java
     classname="net.mindview.util.Deque"
     classpath="${java.class.path};${basedir};${basedir}/.."
     dir="../net/mindview/util/"
     failonerror="true"
     fork="true"/>
  </target>

  <target name="Directory">
    <java
     classname="net.mindview.util.Directory"
     classpath="${java.class.path};${basedir};${basedir}/.."
     dir="../net/mindview/util/"
     failonerror="true"
     fork="true"/>
  </target>

  <target name="Enums">
    <java
     classname="net.mindview.util.Enums"
     classpath="${java.class.path};${basedir};${basedir}/.."
     dir="../net/mindview/util/"
     failonerror="true"
     fork="true"/>
  </target>

  <target name="FiveTuple">
    <java
     classname="net.mindview.util.FiveTuple"
     classpath="${java.class.path};${basedir};${basedir}/.."
     dir="../net/mindview/util/"
     failonerror="true"
     fork="true"/>
  </target>

  <target name="FourTuple">
    <java
     classname="net.mindview.util.FourTuple"
     classpath="${java.class.path};${basedir};${basedir}/.."
     dir="../net/mindview/util/"
     failonerror="true"
     fork="true"/>
  </target>

  <target name="Generated">
    <java
     classname="net.mindview.util.Generated"
     classpath="${java.class.path};${basedir};${basedir}/.."
     dir="../net/mindview/util/"
     failonerror="true"
     fork="true"/>
  </target>

  <target name="Generator">
    <java
     classname="net.mindview.util.Generator"
     classpath="${java.class.path};${basedir};${basedir}/.."
     dir="../net/mindview/util/"
     failonerror="true"
     fork="true"/>
  </target>

  <target name="Hex">
    <java
     classname="net.mindview.util.Hex"
     classpath="${java.class.path};${basedir};${basedir}/.."
     dir="../net/mindview/util/"
     failonerror="true"
     fork="true"/>
  </target>

  <target name="MapData">
    <java
     classname="net.mindview.util.MapData"
     classpath="${java.class.path};${basedir};${basedir}/.."
     dir="../net/mindview/util/"
     failonerror="true"
     fork="true"/>
  </target>

  <target name="New">
    <java
     classname="net.mindview.util.New"
     classpath="${java.class.path};${basedir};${basedir}/.."
     dir="../net/mindview/util/"
     failonerror="true"
     fork="true"/>
  </target>

  <target name="Null">
    <java
     classname="net.mindview.util.Null"
     classpath="${java.class.path};${basedir};${basedir}/.."
     dir="../net/mindview/util/"
     failonerror="true"
     fork="true"/>
  </target>

  <target name="OSExecute">
    <java
     classname="net.mindview.util.OSExecute"
     classpath="${java.class.path};${basedir};${basedir}/.."
     dir="../net/mindview/util/"
     failonerror="true"
     fork="true"/>
  </target>

  <target name="OSExecuteException">
    <java
     classname="net.mindview.util.OSExecuteException"
     classpath="${java.class.path};${basedir};${basedir}/.."
     dir="../net/mindview/util/"
     failonerror="true"
     fork="true"/>
  </target>

  <target name="Pair">
    <java
     classname="net.mindview.util.Pair"
     classpath="${java.class.path};${basedir};${basedir}/.."
     dir="../net/mindview/util/"
     failonerror="true"
     fork="true"/>
  </target>

  <target name="ProcessFiles">
    <java
     classname="net.mindview.util.ProcessFiles"
     classpath="${java.class.path};${basedir};${basedir}/.."
     dir="../net/mindview/util/"
     failonerror="true"
     fork="true"/>
  </target>

  <target name="RandomGenerator">
    <java
     classname="net.mindview.util.RandomGenerator"
     classpath="${java.class.path};${basedir};${basedir}/.."
     dir="../net/mindview/util/"
     failonerror="true"
     fork="true"/>
  </target>

  <target name="Range">
    <java
     classname="net.mindview.util.Range"
     classpath="${java.class.path};${basedir};${basedir}/.."
     dir="../net/mindview/util/"
     failonerror="true"
     fork="true"/>
  </target>

  <target name="Sets">
    <java
     classname="net.mindview.util.Sets"
     classpath="${java.class.path};${basedir};${basedir}/.."
     dir="../net/mindview/util/"
     failonerror="true"
     fork="true"/>
  </target>

  <target name="Stack">
    <java
     classname="net.mindview.util.Stack"
     classpath="${java.class.path};${basedir};${basedir}/.."
     dir="../net/mindview/util/"
     failonerror="true"
     fork="true"/>
  </target>

  <target name="SwingConsole">
    <java
     classname="net.mindview.util.SwingConsole"
     classpath="${java.class.path};${basedir};${basedir}/.."
     dir="../net/mindview/util/"
     failonerror="true"
     fork="true"/>
  </target>

  <target name="TaskItem">
    <java
     classname="net.mindview.util.TaskItem"
     classpath="${java.class.path};${basedir};${basedir}/.."
     dir="../net/mindview/util/"
     failonerror="true"
     fork="true"/>
  </target>

  <target name="TaskManager">
    <java
     classname="net.mindview.util.TaskManager"
     classpath="${java.class.path};${basedir};${basedir}/.."
     dir="../net/mindview/util/"
     failonerror="true"
     fork="true"/>
  </target>

  <target name="TextFile">
    <java
     classname="net.mindview.util.TextFile"
     classpath="${java.class.path};${basedir};${basedir}/.."
     dir="../net/mindview/util/"
     failonerror="true"
     fork="true"/>
  </target>

  <target name="ThreeTuple">
    <java
     classname="net.mindview.util.ThreeTuple"
     classpath="${java.class.path};${basedir};${basedir}/.."
     dir="../net/mindview/util/"
     failonerror="true"
     fork="true"/>
  </target>

  <target name="Tuple">
    <java
     classname="net.mindview.util.Tuple"
     classpath="${java.class.path};${basedir};${basedir}/.."
     dir="../net/mindview/util/"
     failonerror="true"
     fork="true"/>
  </target>

  <target name="TwoTuple">
    <java
     classname="net.mindview.util.TwoTuple"
     classpath="${java.class.path};${basedir};${basedir}/.."
     dir="../net/mindview/util/"
     failonerror="true"
     fork="true"/>
  </target>

  <target name="TypeCounter">
    <java
     classname="net.mindview.util.TypeCounter"
     classpath="${java.class.path};${basedir};${basedir}/.."
     dir="../net/mindview/util/"
     failonerror="true"
     fork="true"/>
  </target>

  <target
   depends="build"
   description="Compile and run"
   name="run">
    <touch file="failures"/>
    <antcall target="AtUnitRemover"/>
    <antcall target="ClassNameFinder"/>
    <antcall target="ContainerMethodDifferences"/>
    <antcall target="CountingIntegerList"/>
    <antcall target="CountingMapData"/>
    <antcall target="Countries"/>
    <antcall target="Directory"/>
    <antcall target="Hex"/>
    <antcall target="New"/>
    <antcall target="ProcessFiles"/>
    <antcall target="TextFile"/>
    <echo
     message="* net.mindview.atunit.AtUnit must be run by hand *"/>
    <delete file="failures"/>
  </target>

  <target description="delete all byproducts" name="clean">
    <delete>
      <fileset dir="${basedir}" includes="**/*.class"/>
      <fileset dir="${basedir}" includes="**/*Output.txt"/>
      <fileset dir="${basedir}" includes="**/log.txt"/>
      <fileset dir="${basedir}" includes="failures"/>
    </delete>
    <echo message="clean successful"/>
  </target>

</project>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment