Suppose you have a source tree, where the source for
each top-level class is in a directory hierarchy that
reflects the class's package, so the class MyApp
in the package com.example
is defined in a source file
com/example/MyApp.java. Jardeps supports multiple source trees,
each with a user-defined name. You define a tree called
core (say) by placing it in your working
directory under the name src/core/. Source
for the class com.example.MyApp
would then go in
src/core/com/example/MyApp.java.
Define the contents of tree core, either by whitelisting the root classes:
# In Makefile roots_core += com.example.MyApp
…or by finding all source files, and optionally blacklisting some:
# In Makefile roots_core=$(found_core) exroots_core += com.example.IncompleteClass exroots_core += com.example.RedundantClass
If you now run make out/core.jar in the working directory, the selected classes will be compiled to form the requested jar. Other classes in the source tree, even excluded ones, will be compiled if they are referenced directly or indirectly by the root classes. These are the implicit classes.
If you run make out/core.jar again without changing any sources, no action will be taken, because re-compilation is unnecessary. However, if you modify any of the source files used in the previous compilation, or alter the set of root classes, the whole source tree is recompiled, and the jar rebuilt.
Blacklisting has the following advantages:
-
You don't have to maintain the list as much, as excluding classes is rare, while adding and removing classes is quite common.
-
All root classes get annotation-processed. (Excluded classes will only get compiled as implicit classes, if at all.)
Note that you always list fully-qualified top-level class names, not filenames.