Graham King

Solvitas perambulum

jUse

software
Summary
I created a Python program called _jUse_ that analyzes Java projects to display package dependencies. It helps me ensure that my model code doesn’t depend on controllers. The program consists of two files, `jUse.py` and `model.py`, which can be run by typing `python jUse.py -r /path/to/javaProject`, where the specified path should contain the package's starting directory. This will analyze Java files in all subdirectories and generate a `jUse.cache` file. To query dependencies of a specific package like `net.darkcoding.myproject.model`, use `python jUse.py -q net.darkcoding.myproject.model`, and to narrow the results to only your project’s dependencies, run `python jUse.py -q net.darkcoding.myproject.model -n net.darkcoding.myproject`. The tool is licensed under the GPL, and I’d love to hear about any interesting uses you find for it.

I’ve written a small Python program I’m calling jUse which I’m placing here in the hope that someone might find it useful. It analyses a Java project and shows the dependencies of a particular package. I use it to check that my model code doesn’t depend on my controllers, for example.

In the tar.gz (linked at the end) there are two python files: jUse.py and model.py. To run jUse type:

python jUse.py -r /root/of/my/javaProject

The path given should be where your package starts – i.e. there should be a ‘com’, ‘org’, etc directory directly underneath that one. It will analyse the java files in all subdirectories and write a ‘jUse.cache’ file in the current directory.

To Query the dependencies of the ‘net.darkcoding.myproject.model’ package run:

python jUse.py -q net.darkcoding.myproject.model

This will print all the dependencies, including the ‘java’ packages. To Narrow to only the dependencies in your current project use:

python jUse.py -q net.darkcoding.myproject.model -n net.darkcoding.myproject

That’s it. I hope you find it useful. It’s licensed under the GPL. If you do anything cool with it let me know.

Download jUse