Move your ant script to the classes directory.  Change your src and dest "."
the current directory.

Since all of your pagackages begin with defects, then your src directory
compile then in the directory above defects.  Otherwise your .class files
will be located some place else.
To accomplish this:
classes/defects/controller/ClassA.java
                          /ClassA.class
classes/defects/model/ClassD.java
                     /ClassD.class
BOTH src and dest have to be at the classes directory.  You should run Ant
from this directory also.  Then your src and dest are going to be . for the
current directory.  

-----Original Message-----
From: Tina Armstrong [mailto:[EMAIL PROTECTED]]
Sent: Thursday, January 25, 2001 6:49 AM
To: '[EMAIL PROTECTED]'
Cc: '[EMAIL PROTECTED]'
Subject: Ant/javac/recompiling every time


Hi Kevin, 

I was not sure who to really reply to...

I included the previous emails at the bottom of this email.


However, I am still confused. 
again my build.xml looks like:

----------------------------------------------------------------------------
---------------
<project default="compile" basedir=".">
   <target name="init">
      <tstamp/>
      <property name="build.compiler" value="modern"/>
      <property name="src" value="."/>
      <property name="classes" value="."/>
      <property name="classpath" value="."/>
   </target>

   <target name="prepare" depends="init">
   </target>

   <target name="compile" depends="prepare">
      <javac
         srcdir="${src}"
         destdir="${classes}/classes"
         classpath="${classpath}"
         debug="true"
         deprecation="true"
         includes="**"
         />
   </target>
</project>
----------------------------------------------------------------------------
---------------


I did try to change it like the suggestion below, I changed it to look like:

----------------------------------------------------------------------------
---------------
<project default="compile" basedir=".">
   <target name="init">
      <tstamp/>
      <property name="build.compiler" value="modern"/>
      <property name="src" value="."/>
      <property name="classes" value="."/>
      <property name="classpath" value="."/>
   </target>

   <target name="prepare" depends="init">
   </target>

   <target name="compile" depends="prepare">
      <javac
         destdir="${classes}/classes"
         classpath="${classpath}"
         debug="true"
         deprecation="true"
         includes=="${src}"
         />
   </target>
</project>
----------------------------------------------------------------------------
---------------


I then got an error saying that SRCDIR was not defined and the build failed.


This is how my directory structure is laid out, 
I have C:\prism\web-inf\classes\defects          (this is where I am sitting
when I am running ant)
in this defects directory, I have util.java which has the following package
definition: package defects;
below the defects directory I have two folders, 
controller -- in here the six  .java files have the following package
definitions in them : package defects.controller;
 and
model -- in here the three .java files have the following package
definitions in them: package defects.model;

and what was happening originally was when I was in 
c:\prism\web-inf\classes\defects and I was running ant, all 10 source files
were being recompiled everytime. 

Maybe I am not doing this correctly... ? should I be attempting the compile
for each package individually or something?



-----Original Message-----
From: Kevin Mukhar [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, January 24, 2001 5:29 PM
To: [EMAIL PROTECTED]
Subject: Re: Ant/javac


Tina Armstrong wrote:
> 
> however, it re-compiles everything everytime, and I thought that the
following should apply:
> The source and destination directory will be recursively scanned for Java
source files to compile. 

Here's the answer from Douglas Bitting <[EMAIL PROTECTED]>
Subject: RE: javac always recompiles all files
Date: Mon, 22 Jan 2001 15:35:33 -0800

> Change:
>
>     <target name="compile" depends="prepare">
>        <javac srcdir="com" destdir="${build.dir}/classes" debug="on"
>           deprecation="off" optimize="off"/>
>     </target>
> 
> To:
> 
>     <target name="compile" depends="prepare">
>        <javac destdir="${build.dir}/classes" debug="on"
>           deprecation="off" optimize="off"
>           includes="com"/>
>     </target>
> 
> By setting 'srcdir="com"', you are telling javac that package names should
be
> resolved relative to "com", which is probably not what you want.
> Instead specify 'includes="com"' to tell the javac task to look within the
'com'
> directory for source files.
> 
> For example, assume you have a file located at "com/foo/bar.java", with a
package
> declaration of "package com.foo".  When bar.java is compiled, the
> compiler will place it within the 'com.foo' package.  However, according
to your
> build.xml, when the javac task does its dependency sweep, it will be
> looking for 'bar' within the package 'foo' (not 'com.foo').  Not finding
it, the
> javac task will think it needs to be recompiled.
> 
> Wow, that explanation sure looks overly complicated to me.  I hope you can
make
> sense of it!  :-)
>




Reply via email to