I have a complex Java project that ultimately boils down to 3 major packages:

```
com.myapp.client --> client-side classes
com.myapp.shared --> client- and server-side utility classes
com.myapp.server --> server-side classes

```

I would like to write an Ant task that checks that no `com.myapp.client` classes show up as dependencies for `com.myapp.server` classes, and vice versa. I call this concept "drawbridging", because you're putting up a drawbridge between client and server code. The Ant task would fail the build if such violating dependencies are found.

For the life of me I can't figure out how to do this. Preferably, something already exists out there, however Google didn't turn back anything.

Short of an existing open source solution, my next guess would be to loop through all the client classes and check their imports for server classes; however according to [this SO question](https://stackoverflow.com/questions/5701305/how-to-get-all-imports-defined-in-a-class-using-java-reflection) the Java compiler throws away import references at compile-time.

So, I'm at a loss here. Any ideas? Thanks in advance!