JavaDeps Usage

We assume you are using the supplied jdeps script in all examples below. Most of the options are not needed in the typical case. Usually the command you want is

          jdeps *.java > .deps
or
          jdeps -d classes *.java > .deps

JavaDeps parses a set of java source files to determine their inter-dependencies. It does not include dependencies on classes not built from the source files specified on the command line. Hence, you must run it on all the sources in your project.

By default, build rules are emitted for every class file built from your sources, though this can be suppressed. The default build rule is to run $(JAVACOMPILE) on the java file for that class. This allows you to set the exact form of the command elsewhere in the main makefile, by setting the JAVACOMPILE variable. If you prefer, the build rule may be specified with the -b option when JavaDeps is run.

A makefile variable -- named CLASSES by default, but can be changed using the -C option -- will hold the names of all the class files that can be built from your sources. This list is sorted so that no class file depends on a class later in the list, so it is useful for a compilation target. The example makefile below shows this.

The resulting build and dependency rules are written to standard output, so you'd typically re-direct it to a file included by the main makefile.

The prototypical makefile would be something like the following:

          JAVACOMPILE = javac

	  default: all
          include .deps
          all: $(CLASSES)

          .deps: Makefile
                  jdeps *.java > .deps

If you're wondering about the default/include/all sequence, here is the reason it is thus. The target to build all the classes, all, uses the variable CLASSES, defined in the .deps file. Hence, it must appear after the inclusion. However, the included file defines lots of targets of its own. Typing make (without specifying a target) will build the first target encountered. If you don't put some other target, say default in front of the inclusion, this target will be an arbitrary .class file (the one that appears first in the CLASSES list). This is unlikely to be what what you want :-)

Usage: jdeps [options] [java-file ... | -f FILE ]

The options and their meanings are:

-b CMD, --build=CMD
Set the command used in the makefile's build rules. The default is $(JAVACOMPILE), letting you set it in the makefile.
-C VARNAME, --classvar=VARNAME
Set the name of the variable to hold all the classfile names. The default is CLASSES.
-d DIR, --dir=DIR
You must specifiy this if you use the corresponding -d option for the compiler. This changes the way classfile names are generated since they will all be in destination-dir, or subdirectories thereof.
--debug
Turns on debugging; may be useful if you are investigating a bug in JavaDeps.
-f FILE
Read the source files to process from FILE, rather from command line arguments. FILE should list java source files, separated by whitespace, (space or newline characters) for JavaDeps to process. If used, this overrides any list of java files on the command line. You may use only one -f option.
-h, --help
Display helpful info!
-j, --jmk
Generate rules for use with "Make in Java" (jmk), rather than GNU Make.
-n
Do not output the commands to build anything. With this flag, only the dependencies are output.
--native, --native=stubs
Emit commands to generate C header files, for classes with native methods. Using the second form, both header and stub files are made. Experimental.
-o FILE, --output=FILE
Write output to FILE, rather than stdout.
--silent
Suppress the informational comments in the output.
-v, --verbose
Be a little verbose. Currently this will announce filenames as they are processed, and suchlike.
--version
Display version info.
Please let me know your opinions on the usefulness of the diagnostics, the information generated by the verbose flag, etc.