ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "YAWN,MICHAEL (HP-Cupertino,ex1)" <>
Subject Completely confused about directories
Date Tue, 05 Mar 2002 19:18:43 GMT
I'm having no luck navigating through directories in order to build and
package my application.

I want it to be portable (freely downloadable and buildable by users who
may place it in any arbitrary directory), so I'm trying to make all the
directory paths relative.

Here's the structure:

   nfl             - root directory of my hierarchy.   
                     build.xml goes in this directory
      application  - most classes are here
      presentation - UI code is here
      persistence  - JDBC code is here

The build.xml is located at nfl/build.xml.  All classes
are part of nfl package; most are part of one of the 
three subpackages.

Here's the snippet which attempts to compile the classes:

<target name="compile">
  <javac srcdir="." classpath=".." >
    <include name=""/>
    <!-- other files omitted for brevity -->
  <javac srcdir="application" classpathref="classpath">
     <!-- files omitted for brevity -->
  <!-- persistence, presentation subdirs omitted -->

If I try to compile using this, the compile
fails on the import of nfl.application.*.  I originally tried
with no classpath setting; after failing, I tried creating a
classpath of "..", and then of ".:..".  All fail.  What is
the interaction between the project basedir (set to "."), the
javac srcdir, and the classpath?  What combination must I use
in order for my classes to compile?  (If I continue on into
the subdirectory, any classes that need to be included from
non-local directories also fail, so I'm completely failing
to get javac to recognize a classpath beginning with the
nfl directory)

I have a similar problem trying to jar up the results.  To be
loadable, my classfiles in the .jar file must be saved with the
full package name.  The following code seems to be working:

<target name="jar" depends="compile">
   <jar jarfile="layered.jar" manifest="Manifest" 
        basedir=".." includes="nfl" >
      <zipfileset dir="." prefix="nfl"
                          excludes="MakeListing.class" />
      <zipfileset dir="application" prefix="nfl/application"
          includes="Conference.class, Division.class,
            Game.class, Games.class, Messaging.class,
            Standings.class, Team*.class, Basic*.class" />
      <zipfileset dir="persistence" prefix="nfl/persistence"
          includes="*Data.class, Basic*.class" />
      <zipfileset dir="presentation" prefix="nfl/presentation" 
          includes="Console.class" />

But I was a little surprised to have to use the 'zipfileset' 
within the 'jar' target.  Perhaps I'm just too hung up on the
naming mismatch (jar != zip), but is this the expected way to
do this?  

Also, by trying to move the 'base' directory above the package
root, so that classes would be stored with full package-name
prefixes, I caused the scanner to start searching all sorts of
directories that aren't part of my project.  So I had to 
point the scanner to the right place with the includes="nfl"
attribute.  Again, this seems to be working, but I'm feeling
the syntax is awkward and wonder if I've missed an obvious, 
easier way to do this.

Thanks for any pointers that can help me create 'less stupid'
build files.  This is intended for publication, so I really want
to show best practices and not just something that happens to work.


To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message