Skip to main content

Scope

Scopes in Java build systems are used to achieve different compile and deployment strategies. It's very important to know the distinction to ensure we use the available options for different use cases.

  1. compile - This is the default scope and this means the mentioned dependency is added to the compile classpath.
  2. runtime - This means the dependency isn't part of the compile classpath but will be added to the final jar that will be used in the runtime.
  3. provided - This means the dependency is available only at compile and test time and will be provided during the runtime by other sources.
How runtime dependencies are used

We can use it in case of independent applications that needs to run in the same JVM or in cases where we only integrate with the APIs and the implementation is kept out during the compile time.