I keep getting confused about which artifact scope to use: compile, test, or runtime? So here’s a little algorithm to help me (it’s a conservative algorithm, trying to depend on libraries only to the extent necessary):
- If the artifact is not not needed by the production code but only by tests, use test scope.
- Otherwise, if production code needs the artifact at runtime but does not need to code against its classes and interfaces (for instance, if all references to the artifact in production code are in Spring bean files), use runtime scope.
- Otherwise, if the production code needs to code against the artifact’s classes and interfaces, use compile scope.
So in my algorithm you consider test scope first, and open it up to runtime or compile scope only if necessary.