Basically I have packages...
com.me.application
com.me.application.thing
com.me.library
I want to enforce the rule that nothing in com.me.application
can include com.me.library
, except things in com.me.application.thing
.
Is this possible at the level of Java code, Maven, classpath, or any other layer of Java that would be roughly equivalent to linking in C?
Instead of trying to force the compiler to do it, why not use source code analysis instead?
I would recommend using the architecture rules engine that is now embedded in Sonar. Combine this with the build breaker plugin and you can trigger a build failure, if developers breach your hierarchy rules.
You can enforce the checks with Checkstyle's import control rule. Configure the Maven Checkstyle plugin into your pom.xml, and any violations can be set to cause the build to fail.
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