Reputation: 3058
Is there a code analysis tool for Java for asserting package dependencies/non-dependencies?
I have a project where dependencies have crept in between packages that should not know about each other - in particular back-dependencies, which should have been one way.
I'd like to specify which pairs of packages (in which direction) are allowed to be dependent. Alternatively, specifying packages that are NOT allowed to depend on each other - or not both ways - would help. Ideally this would be something that could run as part of an Ant build and/or JUnit run and fail the build if new dependencies, in violation of the rules, are introduced. We'd then add this to our CI process.
It would also be useful to be able to specify dependencies at the level of groups of packages (for example, all packages and sub-packages in 'web' CAN depend on any package in 'api' or its sub-packages).
Some specifics in case relevant, for my particular project:
Upvotes: 0
Views: 160
Reputation: 18459
You need a solution like Jdepend. There is an example on how to use with junit
Upvotes: 1