ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jason Pringle <>
Subject RE: <javac> support for tree without package names?
Date Tue, 27 Feb 2001 18:29:59 GMT
I think everything's relative to the basedir value for the <project> tag.  I
guess if you use '.', then it's set to the directory the build.xml file is
in rather than the directory you invoked from.

You could try this....set basedir for the project to point to /samples, and
define src.dir like so:

<property name="src.dir" value="${cwd}"/>

Then when you invoke from some subdirectory, pass -Dcwd="Topic1/sample1" (I
don't think the shell will expand "." out for you, and you'd be back at
square one).  Since all directories are relative to the basedir (which is
/samples) it should work.  To protect against invoking without passing a
value for cwd you could add an "if" element to an init target - then ant
will error out gracefully if cwd has not been set.

Doesn't quite solve the problem of compiling everything from one go, but
might be a start.


-----Original Message-----
From: Bill Burton []
Sent: Monday, February 26, 2001 5:52 PM
To: Ant User Mailing List
Subject: <javac> support for tree without package names?


I'm confronted with trying to compile a directory tree of sample code
where the .java files don't use packages.  Like this:

My <java> looks like this:
    <javac srcdir="${src.dir}"
           classpathref="classpath" />
where src.dir is set to "."

If I cd into a subdirectory like Topic1/sample1 and run ant -find
build.xml, it finds the build.xml in the samples root directory but runs
javac with a -d option pointing to the samples root directory instead of
the current directory.  It seems the destdir is relative to the build.xml
and not the current directory.  I verified Ant 1.2 also works this way. 
The end result is that all the files under samples are compiled and the
.class files written to the root samples directory itself instead of the
relative directory.  The end result is it appears there needs to be one
<javac> task per subdirectory so the srcdir and destdir can be specified
appropriately for each one.

The only reasonable way I've been able to get Ant (1.3beta3) to work under
this configuration is by having one build.xml at each of the Topic1,
Topic2 levels, etc. subdirectories.  Instead of defining one <javac> task
for each subdirectory, I'm using a series of <antcall>'s to call a
"compile_template" target for each subdirectory containing one or more
.java files.

At the moment, converting these samples to use packages doesn't seem
feaseable due to other unrelated issues.

Does anyone have any suggestions?


View raw message