Is there a way (built-in or via plugin) to restrict access to a Java package from other packages in Eclipse?
Example:
Packages (in same project):
com.my.project.common
com.my.project.serviceV1
com.my.project.serviceV2
Now I want to restrict access to serviceV1 and serviceV2 from common. But of course those services should be allowed to access the common package
Edit: If all you are looking for is simple package level protection that can be achieved using the private/protected/public/default package scopes, then I agree with the comment from @AlexisPigeon – that’s the simplest route. Otherwise, I would consider the jdepend solution I proposed below.
No, this is not possible. I recommend looking at JDepend. It can produce a report of the package dependencies. You could write a script to parse the output and then fail your build (there are jdepend plugins for maven, ant and gradle) if one of your dependency constraints are violated.