Re: Java and 'make'



On Sat, 02 Jun 2007 23:38:03 +0100, <veegnu@xxxxxxxxx> wrote:

Hello,

I have a question about using make as the build-utilitiy for Java
programs. Please point me to a more appropriate news group if this is
not the group to discuss this.

The obvious first question is why make and not Ant (http://ant.apache.org)?

Here is the context of my question:
------------------------------------------
A 'Node' contains NetworkPackets. NetworkPackets have a source Node.
My makefile captures this as:

...
Node.class: Node.java NetworkPacket.class
javac Node.java

NetworkPacket.class: NetworkPacket.java Node.class
javac NetworkPacket.java
...

First issue:
------------
With this, make discovers a cyclic dependency and drops it. I am sure
that per the design of make, this is expected behavior. The question
is, how should I represent the dependency in my program in a makefile?

Generally you would not compile individual source files. You should compile both files at the same time because javac cannot resolve the dependency otherwise:

javac Node.java NetworkPacket.java

Or
javac *.java


Second issue:
-------------
I believe make will not have problems of this kind in the context of C/
C++ programs. Because of a clear seperation of declarations in a
header file and definitions in object files, the dependencies will
form 'trees' instead of 'cycles' as in the makefile snipped above. Is
makefile not the appropriate (or the best) tool to capture
dependencies in Java programs where we don't have a seperate header
and source files? My experience with make is limited to relatively
uncomplicated scenario and I would like to have the opinion of more
knowledgeable people on this point.

Use Ant unless you have a compelling reason not to.

Dan.

--
Daniel Dyer
http//www.uncommons.org
.



Relevant Pages

  • Re: Java and make
    ... My makefile captures this as: ... make discovers a cyclic dependency and drops it. ... I believe make will not have problems of this kind in the context of C/ ... dependencies in Java programs where we don't have a seperate header ...
    (comp.lang.java.programmer)
  • Java and make
    ... I have a question about using make as the build-utilitiy for Java ... Please point me to a more appropriate news group if this is ... My makefile captures this as: ... make discovers a cyclic dependency and drops it. ...
    (comp.lang.java.programmer)
  • Re: javac vs Makefile problem ...
    ... In order to compile everything easily, I did a Makefile. ... You don't want 1 execution of javac for each .java file in your project; instead, what you want to do is invoke javac once on *all* .java files in your project -- all at one go. ...
    (comp.lang.java.programmer)
  • Re: javac vs Makefile problem ...
    ... I spent some time looking for some other Java tools and I ... >> In order to compile everything easily, I did a Makefile. ... here is my compilation chain: ... > There is no way to disable the javac automatic dependency resolution. ...
    (comp.lang.java.programmer)
  • Re: Separate Compilation in Programming Languages
    ... It might indicate a problem with the GNAT implementation, ... with Ada. ... However, I have not programmed any large-scale programs in Java, ... the dependency problems become more ...
    (comp.lang.ada)