ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Steve Loughran <>
Subject Re: Java source files not part of any package
Date Wed, 28 Oct 2009 10:51:52 GMT
Dianne Yumul wrote:
> Hello Everyone,
> I'm learning to use Ant 1.7.0 as part of Xcode 3.1.2 on Mac OS X 10.6.  
> We have a separate directory called Common/ where we keep common java 
> source files. These files need to get included, not all at the same time 
> though, when compiling our Java applications.  What would be the best 
> way to do this?
> If I add Common/ to srcdir, it compiles everything inside when I only 
> need a one or two.  The FAQ mentions that "If you have Java source files 
> that aren't declared to be part of any package, you can still use the 
> <javac> task to compile these files correctly - just set the srcdir and 
> destdir attributes to the actual directory the source files live in and 
> the directory the class files should go into, respectively."  But how to 
> do this exactly? Do I need two separate javac tasks like the following?
> <javac srcdir="../../../Common/src" destdir="../../../Common/bin" 
> classpathref="lib.path" debug="on"/>
> <javac srcdir="src" destdir="bin" classpathref="lib.path" debug="on"/>

that's not going to help, ant will still compile everything in common/

Two options

* <copy> only the files you need to somewhere (like build/src and 
include that in the compile

* use the nested <fileset file> elements in <src> inside javac

<property name="common.dir" location="../../../Common" />

<javac destdir="${build.classes.dir}">
  <fileset file="${common.dir}/" />
  <fileset file="${common.dir}/" />

Know that Javac will pull in extra java source files if imported, it may 
compile more than you expect.


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

View raw message