[sword-devel] Build file for jsword

Bobby Nations sword-devel@crosswire.org
Sun, 09 Dec 2001 23:47:04 -0600


This is a multi-part message in MIME format.
--------------9D39843776BBF61A314249F4
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

"Troy A. Griffitts" wrote:
> 
> Bobby,
>         Just grabbed and installed ant 1.4.1 and tried out your build.xml.
> Seems to work great.  I've added it to the project.
> Thank you!
> 
>         A few questions.  Is there a way we could output classes to the
> jsword/classes directory, javadocs to jsword/doc/api, and .jar to the
> jsword/jars directory?  That way we can keep things consistent with the
> makefiles.  I don't want to remove the makefiles just yet.  They are
> nice to use when you don't want to install a new build system on a box,
> but need to quickly make a change and rebuild.

Sure, I've attached a new version that does just the thing.

> 
>         A few ant questions:
> 
>         As you're developing in say, jsword/src/org/crosswire/sword/mgr/, and
> make a change to SWConfig.java, and want to try out your compile and see
> the errors... what do you do?  

Run for the hills :-)

> Right now, I just type 'make', or in vim,
> ':make' and get taken to my compile error.  

I don't think that vim is as hooked into ant as it is make (but I could
easily be wrong), so, it probably won't take you to your compile error. 
I haven't really used vi(m) in that way, so someone please correct me if
it will do a similar thing for ant as it does for make.

As for how I do things, when working on a file (usually in vim :-), deep
in the src tree.  Generally, I keep two terminals up, one for editing,
and the other for compiling and building.  I know, I know, that's old
fashioned, but it works for me.  You can run ant from any directory and
simply specify which build file to use (useful if you want to segragate
portions of your build scripts into several files ... such as
database.xml or modules.xml, etc.).  The '-buildfile' command line
option lets you specify another build file.  

So from, jsword/src/org/crosswire/sword/mgr, you would just type

% ant -buildfile ../../../../../build.xml

That's a bit long, hence the reason that I like to keep two terminals
up.  Of course, I believe that you would have the same issue with a
top-level make file as well.  It might be possible to put build.xml
files at all levels and have them reference the top-level build file,
but I've never seen it done.  Ant recurses directories pretty
painlessly, and so generally there's not a lot needed beyond the top
level build files.

> Help familiarize me with
> standard ant development practices.

It works pretty similarly to make (in fact it was developed as an
alternative to make).  The online documentation is pretty
straightforward and easy to digest
(http://jakarta.apache.org/ant/manual/index.html), and they even give
some hints about directory structures to use.  Probably the two key
advantages to using ant over make for Java development are it's
portability written in Java but most importantly speed.  When using make
files, every javac call results in a separate instance of the JVM being
created.  Since ant is a java application, it just uses the currently
running JVM to do the dirty work.  

Cheers,

Bobby

BTW, how do you prefer to receive new code?  As patches or just the
complete file(s)?  If patches, what command line options do you usually
use when creating them?



> 
>         Thanks again!
> 
>                 -Troy.
--------------9D39843776BBF61A314249F4
Content-Type: text/plain; charset=us-ascii;
 name="build.xml"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="build.xml"

<?xml version="1.0" encoding="iso-8859-1"?>
<project name="jsword" default="jar" basedir=".">

    <!-- Set the project wide classpath -->
    <path id="project.classpath">
        <pathelement path="${java.class.path}/"/>
        <pathelement location="./"/>
        <fileset dir="lib">
            <include name="**/*.jar"/>
        </fileset>
    </path>

    <target name="init">
        <property name="src.dir" value="./src" />
	<property name="build.dir" value="./classes" />
	<property name="dist.dir" value="./jars" />
	<property name="javadoc.dir" value="./docs/api" />
	<property name="build.compiler" value="modern" />
        <tstamp/>
    </target>

    <target name="createDir" depends="init">
        <mkdir dir="${build.dir}"/>
        <mkdir dir="${dist.dir}"/>
        <mkdir dir="${javadoc.dir}"/>
    </target>

    <target name="compile" depends="createDir">
        <javac srcdir="${src.dir}"
            destdir="${build.dir}" optimize="on"
            classpathref="project.classpath"/>
    </target>

    <target name="jar" depends="compile">
        <jar jarfile="${dist.dir}/sword.jar" basedir="${build.dir}"/>
    </target>

    <target name="javadoc" depends="createDir">
        <javadoc destdir="${javadoc.dir}"
	         sourcepath="${src.dir}/"
		 packagenames="SwordMod, sword, org.crosswire.sword.*, 
                                org.crosswire.utils">
            <classpath refid="project.classpath"/>
        </javadoc>
    </target>

    <target name="clean" depends="init">
        <delete dir="${build.dir}/org"/>
        <delete dir="${build.dir}/sword"/>
        <delete dir="${build.dir}/SwordMod"/>
        <delete dir="${javadoc.dir}"/>
	<delete file="${dist.dir}/sword.jar"/>
    </target>

    <!-- This thing will work one day, but for now it breaks my ant
    <target name="modedit" depends="createDir">
        <javac srcdir="apps/ModEdit/${src.dir}"
               destdir="${build.dir}" optimize="on"
               classpathref="project.classpath"/>
    </target>
    -->

</project>     
     

--------------9D39843776BBF61A314249F4--