ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Prashant Reddy <prash...@pramati.com>
Subject Re: Javac task query
Date Wed, 27 Jun 2007 05:56:57 GMT
No 'javac' task by itself will not delete class file whose source java
file has been deleted, and rightly so. 

I do not think you would really want other source files to *not* compile
when you have deleted a dependent source file. 

Imagine class A uses class C and you deleted class C (manually, and not
using a modern IDE). Even though the time stamp for class A did not
change, you would want to recompile both A, and C.

You could have a cleancompile target in your build.xml 

<target name="cleancompile" depends="remove.classes.dir, compile, jar"/>

The "remove.classes.dir" target would remove all the class files from
the ${dest} directory.

In the sited Phase 2, you would run the cleancompile target, instead of
simple 'jar' target. This would remove C.class along with other class
files from ${dest} directory. During the next compilation since C.java
is deleted C.class will not be generated, and you jar will not have
c.class.

Hope this helps.

-Prashant
On Wed, 2007-06-27 at 10:10 +0800, Yadav, Akshat Kumar wrote:
> Thanks Steve! It worked.
> 
> But lets say if I have executed compile target on a.java, b.java ,c.java
> it generates a.class, b.class, c.class and then I made jar of these
> class files. Later if I deleted c.java from source and its class file is
> present is in dest dir. And when I will make jar it will contain c.class
> also, that I don't want to be persent in jar file as its corresponding
> java file is deleted from source dir.
> 
> Reference:
> Phase 1:
> Source: a.java, b.java, c.java
> Dest: a.class, b.class, c.class
> Jar: JTQ.jar (contains a.class, b.class, c.class) 
> 
> Phase 2 (when I deleted c.java from source dir)
> Source: a.java, b.java
> Dest: a.class, b.class, c.class
> Jar: JTQ.jar (contains a.class, b.class, c.class) 
> 
> But I don't want c.class should not be presend in jar. It there any
> option or method to counter with such situation.
> 
> Any help appreciated. If my query is not clear, then let me know...
> 
> Thanks,
> 
> -----Original Message-----
> From: Steve Loughran [mailto:stevel@apache.org] 
> Sent: Tuesday, June 26, 2007 7:04 PM
> To: Ant Users List
> Subject: Re: Javac task query
> 
> Yadav, Akshat Kumar wrote:
> >  
> > Hi Prashant,
> > 
> > I had executed ANT in verbose and debug mode and it shows
> > 
> >  [javac] HelloWorlApp.java added as HelloWorlApp.class doesn't exist.
> > 
> > Whereas the class file exist in dest dir. I tried adding/deleting dest
> 
> > dir in classpath, but no luck in both the situation.
> > 
> > I would appreciate, If you could try this in your environment. I had 
> > tried this with ANT 1.6.5/1.7 and java 1.4/1.5.
> > 
> > P.S: Other member's can also suggest me something.
> > 
> > Thanks,
> 
> could be the classname in the .java file has a different spelling or
> case from the source file itself
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org For additional
> commands, e-mail: user-help@ant.apache.org
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message