Java Mailing List Archive

http://www.ant-tasks.com/

Apache Ant Archive

» Ant Users List
» Ant Developers List
Javac task query

Javac task query

2007-06-27       - By Yadav, Akshat Kumar
Reply:     1     2     3     4     5     6     7     8     9     10     >>  


Thanks Prashant for reply.

I am talking for the situation where a.java, b.java and c.java are
independent java code files.

Thanks,

-----Original Message-----
From: Prashant Reddy [mailto:prashant@(protected)]
Sent: Wednesday, June 27, 2007 1:57 PM
To: Ant Users List
Subject: Re: Javac task query

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@(protected)]
> 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@(protected) For additional

> commands, e-mail: user-help@(protected)
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@(protected) For additional

> commands, e-mail: user-help@(protected)


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@(protected) For additional
commands, e-mail: user-help@(protected)


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@(protected)
For additional commands, e-mail: user-help@(protected)


©2008 ant-tasks.com - Jax Systems, LLC, U.S.A.