Enforcing a specific package structure or architecture is very important. Especially in Java, where some things must be public to work correctly or actually be available outside their package. ArchUnit is an open-source library that will help you whenever the compiler is not enough.
All of the code examples from this article are available in my GitHub repo.