I want to be sure that my project doesn't contain unnecessary dependencies among packages. For example, I want to be sure that the project has layered structure. I.e. model is below everything, business logic depend on model, view dependes on business logic and model. Each of the layers is place in its own package.
Could you recommend any, preferably open source tools which allow me to specify these constraint and check them as a part of continuous integration?
P.S. I know that I can separate the project in separate maven modules. Unfortunately, my real world case is more complex than 3-layered system. If I used maven modules, I would have several dozens of quite small modules.
Although I am not sure if it is possible to enforce a build failure on layer dependency violation, there is at least a tool that can check and visualize these layers: Sonar. You can integrate it with your maven and jenkins builds as well as with eclipse (and maybe other IDEs).
Sonar features a dependency matrix view which visualized the interdependencies of packages.
EDIT: it seems to be possible to configure sonar to force the build to fail triggered by a violation: the build breaker plugin
This is a very valid question, since lots of projects enforce dependencies through Maven modules, which is a huge waste of productivity and flexibility.
After spending a lot of time researching on this subject I could recommend two tools:
Both tools are not evolving much last years, but are working well. Macker has XML-based syntax, but Classycle has neat DSL. Classycle is more high-level specialized tool and has concept of layers. These tools allow you to enforce strict barriers between packages and certain class types. This tools should be configured in build process to fail upon any constraint immediately.
Check the layering example here (http://innig.net/macker/example/layering/src/macker.xml) and here (http://classycle.sourceforge.net/ddf.html#layer).
There is still a niche for a good open source tool, which would hook into compiler and would give you errors while you are in IDE rather than in build tool. Structure101 is much more feature rich, but also heavy and relies on Eclipse plugin.
Update
These is also JQAssistant, which is very powerful, but can take quite some time to learn and setup.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With