ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joel Riedesel <jried...@jnana.com>
Subject Re: newbie - dependency question
Date Mon, 31 Jul 2000 12:06:13 GMT

One more tidbit.

As Conor points out, javac uses packages to find source files.
Fine and dandy.  It also uses the destination dir to tell it
where to put things.

So, when compiling files in a subpackage, it seems that
the only thing that makes sense for ANT is to have
srcdir and destdir be the roots of your source and compiled trees.

Then, if you are just trying to compile that module, you
have to put the path to all your <include> statements
in the javac command:

    <javac srcdir="${source}"
           destdir="${codebase}"
           classpath="${classpath}">
      <include name="/com/jnana/alert/AlertMain.java"/>
      <include name="/com/jnana/alert/Alert.java"/>
      <include name="/com/jnana/alert/ActionEvent.java"/>
      <include name="/com/jnana/alert/AlertFireEvent.java"/>
      <include name="/com/jnana/alert/AlertData.java"/>
      <include name="/com/jnana/alert/RemoteAlertData.java"/>
      <include name="/com/jnana/alert/LAlert.java"/>
      <include name="/com/jnana/alert/AlertEditor.java"/>
      <include name="/com/jnana/alert/AlertSetNode.java"/>
      <include name="/com/jnana/alert/AlertNode.java"/>
    </javac>

Of course; doing this means that ANT scans *all* subdirectories.
And all of a sudden the performance benefit I had been hoping for
is shot.


For some perspective, I'm trying to have a modular build setup
such that one can add a new build and a build.xml for it quite
independently.

Does anyone have other suggestions?  Am I just going about this
all wrong?

Thanks,

Joel



Joel Riedesel wrote:
> 
> I guess I need to be more explicit.
> 
> My source is in:
>   source/com/jnana/alert/
> Destination is in:
>   codebase/com/jnana/alert/
> 
> I'm sitting in source/com/jnana/alert when I do the
> ant make... perhaps that's the problem?  I should be up above
> the com directory and set the srouce to the source path
> instead of "."?
> 
> Is that what you are trying to say?
> 
> Joel
> 
> Conor MacNeill wrote:
> >
> > Joel,
> >
> > Put your source in a tree that corresponds to its package name
> > ./com/jnana/alert/AlermMain.java, etc
> >
> > This has two advantages
> > ant will work correctly
> > javac, the compiler, will work correctly
> >
> > ant will work because it can match up the destination class files and the
> > source java files to see if it needs to do a compile. The ant javac task
> > does not parse the input java files to figure out the corresponding class
> > files.
> >
> > javac, the compiler, not the task, can figure out the source file needed to
> > satisfy a missing class file if that source file is in the correct location
> > in the package space.
> >
> > For these two reasons it is stringly recommended that you set up your source
> > directory structure to match your package structure. Take a look at the ant
> > source code itself to see what I mean.
> >
> > Conor
> >
> > --
> > Conor MacNeill
> > conor@cortexebusiness.com.au
> > Cortex eBusiness
> > http://www.cortexebusiness.com.au
> >
> > > -----Original Message-----
> > > From: Joel Riedesel [mailto:jriedese@jnana.com]
> > > Sent: Monday, 31 July 2000 6:03
> > > To: ant-user@jakarta.apache.org
> > > Subject: newbie - dependency question
> > >
> > >
> > >
> > > We've got a fairly straightforward build process where
> > > optional modules are all in their own directories (and
> > > own java packages).
> > >
> > > So, in one module, I might have a build target like this
> > > (forgive me if I'm being verbose):
> > >   <target name="dev">
> > >
> > >     <javac srcdir="."
> > >            destdir="${codebase}"
> > >            classpath="${classpath}">
> > >       <include name="AlertMain.java"/>
> > >       <include name="Alert.java"/>
> > >       <include name="ActionEvent.java"/>
> > >       <include name="AlertFireEvent.java"/>
> > >       <include name="AlertData.java"/>
> > >       <include name="RemoteAlertData.java"/>
> > >       <include name="LAlert.java"/>
> > >       <include name="AlertEditor.java"/>
> > >       <include name="AlertSetNode.java"/>
> > >       <include name="AlertNode.java"/>
> > >     </javac>
> > >
> > >     <copydir src="." dest="${codebase}/com/jnana/alert"
> > >              includes="*.gif,alerts.xml"/>
> > >
> > >   </target>
> > >
> > >
> > > This happens to be in the java package:  com.jnana.alert
> > > And my codebase is then some path:  c:\foo\codebase
> > > Thus, when java compiles Alert.java, it gets compiled to
> > > c:\foo\codebase\com\jnana\alert\Alert.class
> > > since I am using a different dest dir than source dir.
> > >
> > > But, everytime I run Ant from this directory, it recompiles
> > > everything; obviously because it doesn't find Alert.class directly
> > > in the destination directory - it doesn't seem to use the
> > > necessary java package name to know this.
> > >
> > > I'm sure there must be a way to do this right, and I probably
> > > just don't know what it is.
> > >
> > > Would anyone please suggest how to do this?
> > >
> > > Thanks,
> > >
> > > Joel
> > >
> > >
> > > --
> > > Joel Riedesel
> > > Jnana Technologies Corporation
> > > mailto:jriedese@jnana.com
> > >
> 
> --
> Joel Riedesel
> Jnana Technologies Corporation
> mailto:jriedese@jnana.com

-- 
Joel Riedesel
Jnana Technologies Corporation
mailto:jriedese@jnana.com

Mime
View raw message