You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Anders Janmyr <an...@movearound.com> on 2000/07/27 11:45:43 UTC

Possible bugs in task javac

Hello,

I have just downloaded ant 1.1 and I have some problems.
When I use the deprecated option in javac it does not work. No deprecation
information is printed.
Also when I use ant from inside emacs I am not able to automatically move to
the next error in the erroneous file. Instead emacs is trying to look for
the build.xml file.

This did not happen before. Is this a bug or is it supposed to be like this?

Anders

-----Original Message-----
From: Conor MacNeill [mailto:conor@m64.com]
Sent: den 27 juli 2000 11:30
To: ant-user@jakarta.apache.org
Subject: RE: New user with cyclic dependencies


> At 12:55  27/7/00 -0500, you wrote:
> >I know that if I ask javac to compile some files, and I include
> the source
> >directory as part of the classpath then javac will automatically compile
> >the imported classes as it encounters them.  It seems that ant's
> javac is
> >not doing this.
>
> hmmm - that so. I never knew that. In that case it may be possible to use
> this hack by specifying classpath attribute in javac that includes
> alternate source directories.
>

Javac, the compiler, will try to resolve class dependencies. If a class file
cannot be found, javac will look for a .java file in the same location in
the sourcepath package space and compile it.

> >I guess one solution is to include all classes with cyclic
> dependencies as
> >a single target?  I am not sure how to specify multiple
> directories for a
> >single javac task.
>
> well you can't and that is a design choice. I have never had to specify
> multiple source directories and am not sure it is needed thou if you could
> describe a use case where it is needed it may be possible to alter javac
> task. Ant makes a few assumptions about layout - namely that all source
> comes from one directory and that they are all in their respective package
> directories. So if you have the class in package com.biz.a then the src
> directory layout should be

Peter, there is no such design choice (at least, not anymore). Ant supports
multiple source paths. It does not make any assumptions about source tree
layouts. There are two ways to specify the source paths

1. Use a path in the src attribute

<javac src="../blah:..\hello;goodbye/for\now">

As I have shown here you can use either : or ; for the path separators and
either / or \ as the file separators. Ant will work out the path for your
platform.

2. Use a nested <src> element - this would be the preferred way

  <javac destdir="${build}"
         classpath="xyz.jar"
         debug="on">
    <src path="${src}" />
    <src path="${src2}" />
  </javac>

All of this is included in the documentation for the javac task.

Also note that ant will compile a file even if it is not in its proper
package space location. It will place the resulting class file in the proper
package space location in the destination build directory. I strongly
recommend against this practice. It means ant will always recompile the file
even if it is not out of date. Javac will also  not be able to determine the
source file if it is necessary to compile the file for a missing class.

Conor


Re: Possible bugs in task javac

Posted by Stefan Bodewig <bo...@bost.de>.
>>>>> "AJ" == Anders Janmyr <an...@movearound.com> writes:

 AJ> Also when I use ant from inside emacs I am not able to
 AJ> automatically move to the next error in the erroneous
 AJ> file. Instead emacs is trying to look for the build.xml file.

I've added an entry to the FAQ but as this hasn't been released by the
maintainer yet:

(require 'compile)
(setq compilation-error-regexp-alist
      (append (list 
               ;; works for jikes
               '("^\\s-*\\[[^]]*\\]\\s-*\\(.+\\):\\([0-9]+\\):\\([0-9]+\\):[0-9]+:[0-9]+:" 1 2 3)
               ;; works for javac 
               ;; thanks to Barrie Treloar <Ba...@camtech.com.au>
               '("^\\s-*\\[[^]]*\\]\\s-*\\(.+\\):\\([0-9]+\\):" 1 2))
      compilation-error-regexp-alist))

in .emacs should help for all combinations of jikes/javac and GNU/X
Emacs.

Newer versions of Ant have the -emacs switch Pete mentioned.

Stefan

Re: Possible bugs in task javac

Posted by Peter Donald <do...@mad.scientist.com>.
At 11:45  27/7/00 +0200, you wrote:
>I have just downloaded ant 1.1 and I have some problems.
>When I use the deprecated option in javac it does not work. No deprecation
>information is printed.

could you run ant -verbose and send output of what parameters are sent to
commandline for that particular target ????

>Also when I use ant from inside emacs I am not able to automatically move to
>the next error in the erroneous file. Instead emacs is trying to look for
>the build.xml file.

the emacs thing is well known and has been changed in latest cvs version by
allowing you to specify -emacs on commandline. Alternatively there is some
elisp in Ant FAQ to make it detect the lines even in new environment.

(BTW you wouldn't happen to be anders who wrote font-locking ??)

Cheers,

Pete

*------------------------------------------------------*
| "Nearly all men can stand adversity, but if you want |
| to test a man's character, give him power."          |
|       -Abraham Lincoln                               |
*------------------------------------------------------*