Tuesday, January 29, 2013
Maven Package/Class Restrictor Plug-In
I just wrote simple access restriction maven plug-in which you can use to break your maven build if a certain package/class/method is referenced by a certain class or package in your source code or in any jar/war/ear dependency even if you do not have it's source code.
It is useful if you do not have access to the pom of the dependencies you use. PMD can allows such controls too but you have to have it's source code and you must build them. With this plug-in; bytecodes of dependencies are checked against rules.
Details are in the github wiki.
The purpose for this artifact is to restrict access to some packages. As a architectural team, we require all teams to use only the API's we provide. Here is an excerpt from our current usage. This will evolve with time:
This plug-in produces a report named "restrict-maven-plugin.txt" under target folder. We disabled breaking the build by setting continueOnError to "true" for now. We e-mail this output to let everyone take appropriate action before we start to break maven builds. Also I wrote simple Ruby script; which re-renders the output in html. I use this output to e-mail: