ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From v...@trilogy.com
Subject Re: filesets referenced by <javac>'s <src> element
Date Tue, 28 Aug 2001 18:01:47 GMT
The way it appears to me, your explanation can be only partially correct:

- first of all, certain supported compilers ("jvc") don't have -sourcepath 
option. Thus, the list of files to be compiled needs to be specified in 
the command line in the traditional way, i.e. as a whitespace-separated 
list.  It also appears that the Jvc compiler adapter will also use an 
@-file when such a  list is large. 

- even if the target compiler supports -sourcepath option, it is not 
enough to specify the complete list of files to be compiled -- the same 
whitespace-separated list must be given either on the command line or 
through an @-file [JDK 1.2+] argument.

I believe this is what you meant by saying "In effect the <javac> task is overloading
the <src> element to specify the 
sourcepath AND the files to be compiled."
I ask you then  -- what is this compile file list if not a genuine 
'fileset'. It still escapes me why <javac> could not take a fileset 
reference through <src>. Anyway, I guess "for historical reasons" is a 
pretty good explanation :)...

Thanks for your response,
Vlad.

BTW, the Jvc adapter adds Ant's own JDK classes to the compile classpath 
-- this is a BAD THING, IMHO.



Please respond to ant-user@jakarta.apache.org
To:     <ant-user@jakarta.apache.org>
cc: 

Subject:        Re: filesets referenced by <javac>'s <src> element


The <src> identifies sources of java files - not the files themselves. To
understand this, you need to realize that the <src> elements are combined
to become the javac -sourcepath option. Here is the documentation for
the -sourcepath attribute (from
http://java.sun.com/j2se/1.3/docs/tooldocs/win32/javac.html)

-sourcepath sourcepath
Specify the source code path to search for class or interface definitions.
As with the user class path, source path entries are separated by
semicolons (;) and can be directories, JAR archives, or ZIP archives.

So, the files you put in the <src> path element must be jars/zips - not
individual java files.

While it is true that a path can contain a nested fileset, possibly
specifiying jars/zips, the <javac> task really expects these to be
directories. What <javac> then does is apply the <include/exclude> 
patterns
to all the source directories. In effect the <javac> task is overloading
the <src> element to specify the sourcepath AND the files to be compiled.
That behaviour isn't actually bad in most instances, but is probably the
root of your problems..

Note that the implementation of the <javac> task predates <fileset>s and 
so
that is why the documentation refers to an implicit fileset. Actually even
that is not quite true, it is more like an implicit patternset applied to
each source dir. As you can imagine introducing an explicit fileset for 
the
source selection may not be all that easy. :-)

So how to think of it. Think of <javac> as having an implicit patternset
applied over the source directories. Is that logical? Maybe not, but that
is the result of <javac>'s history and evolution.

Conor

----- Original Message -----
From: <vlad@trilogy.com>
To: <ant-user@jakarta.apache.org>
Sent: Tuesday, August 28, 2001 2:13 PM
Subject: filesets referenced by <javac>'s <src> element


> I've been using things like the following [ant v1.4beta2]:
>
> <javac destdir="..." >
>         <src refid="idA" />
>         <classpath refid="idB" />
> </javac>
>
> where if "idA" points to something like
>
> <!-- option A -->
> <path id="idA" >
>     <fileset dir="${core.src.dir}" >
>       <include name="**/*.java" />
>       <exclude name="**/*.html" />
>       ... and so on ...
>     </fileset>
> </path>
>
> then <javac> barfs with a message that some file in my ${core.src.dir} 
is
> not a directory [the first file it finds during a recursive directory
> traversal, it appears]. Obviously, it tries to recurse into that file 
and
> that does not work, of course.
>
> However, if I change my idA path such that it contains no nested
> <fileset>'s and only straightforward path elements, like:
>
> <!-- option B -->
> <path id="idA" >
>     <pathelement path="${core.src.dir}" />
>     ...
> </path>
>
> then it works. This forces me to move my includes and excludes into the
> <javac> task itself, while I 'd rather group my inclusion/exclusion
> patterns together with my path strucutres and reference it through a
> refid. After all, I'd like to think about my <javac> operatin on a
fileset
> and I'd like to form such filesets elsewhere so I could re-use them
> throughout the file.
>
> I don't understand why the option A does not work. According to <javac>
> documentation, "srcdir" is a path-like structure and is settable via
> nested <src> elements. This is what I am doing in both cases. Also, per
> documentation path-like structures are allowed to contain nested
<fileset>
> elements, which is what I am doing in option A. Yet it does not work --
> could someone explain why?
>
> It appears to me that I should change my way of thinking: instead of
> <javac> being a target working with 2 filesets (srcdir, classpath, and
> bootclasspath) I am supposed to think of it as a source fileset (srcdir)
> that works with other filesets (classpath and bootclasspath). I don't
> quite see why the latter would be more logical.
>
> Thanks in advance,
> Vlad




Mime
View raw message