Anzime said:
...
Figure out what the makefile(s) is/are doing, then do the same using
Ant. You'll have to read the ant docs to figure out how to use Ant.
http://ant.apache.org
Strangely enough. I find subtle wisdom in that answer, eventhough it might
seem a bit obvious.
If you have a Java project that uses make, then it is most likely written
quite some time ago and/or it is written by someone with a C background and
a limited Java understanding. Either case you would want to completely
review your project's build process. Do not translate the make file(s)
line-by-line into a ant file.
As the poster wrote. You need to figure what the makefiles are doing (from a
top-down perspective), and then do (approximately) same thing with ant. But
be very critical of how the source code and built files are organised in the
original make environment, very likely it will be done in a way that is
uncommon and unconstructive in a Java environment.
I have pasted in a build file from one of my own projects. As an example of
some of the things you can very easily using ant. The build file compiles
sources from the src directory into classes using a classpath with all jars
in the lib directory, then packages the classes with ressources from res and
metainformation from etc into a single jar file. There is an additional test
target that runs a test class using the generated classpath.
Also beware many deployment tasks such as servlet container control and file
transfer can be automated using specialised ant tasks.
-- Christian
http://vredungmand.dk
<project name="octopod" default="dist" basedir=".">
<!-- set global properties for this build -->
<property name="project" value="lightweight"/>
<property name="src" value="src"/>
<property name="build" value="classes"/>
<property name="build.compiler" value="jikes"/>
<property name="doc" value="javadoc"/>
<property name="lib" value="lib"/>
<property name="dist" value="."/>
<property name="etc" value="etc"/>
<property name="res" value="res"/>
<property name="project-class-id" refid="project.class.id"/>
<!-- throw everything inside lib in the classpath -->
<path id="project.class.id">
<pathelement path="${classpath}"/>
<fileset dir="${lib}">
<include name="**/*.jar"/>
</fileset>
</path>
<target name="init">
<!-- Create the time stamp -->
<tstamp/>
<!-- Create the build directory structure used by compile -->
<mkdir dir="${build}"/>
</target>
<target name="compile" depends="init">
<!-- Compile the java code from ${src} into ${build} -->
<javac srcdir="${src}" destdir="${build}" nowarn="on">
<classpath refid="project.class.id"/>
</javac>
</target>
<target name="test" depends="dist">
<exec executable="java">
<arg line="-cp ${project}.jar:${project-class-id} test.Main"/>
</exec>
</target>
<target name="dist" depends="compile">
<mkdir dir="${dist}" />
<jar manifest="etc/manifest.mf" jarfile="${project}.jar">
<fileset dir="${build}"/>
<fileset dir="${res}"/>
</jar>
</target>
<target name="clean">
<!-- Delete the ${build} and ${dist} directory trees -->
<delete dir="${build}"/>
<delete dir="${test}"/>
</target>
<target name="javadoc">
<delete dir="${doc}"/>
<mkdir dir="${doc}"/>
<javadoc packagenames="*.*" sourcepath="${src}"
excludepackagenames="test.*" defaultexcludes="yes"
destdir="${doc}" author="true"
version="true" use="true" windowtitle="Octopod">
<doctitle><![CDATA[<h1>Octopod</h1>]]></doctitle>
<bottom><![CDATA[<i>2004 by Christian Hvid.</i>]]></bottom>
<link
href="
http://developer.java.sun.com/developer/products/xml/docs/api/"/>
</javadoc>
</target>
</project>