← All notes

Maven dependency scopes decide which classpath a library joins

Answer: Maven includes transitive dependencies automatically by reading the project files of your dependencies. Dependency scope is used to limit the transitivity also of a dependency and to determine when a dependency is included in a classpath. Maven documents 6 scopes, starting with compile.

Compile, provided, and runtime

compile is the default scope, used if none is also specified. Compile dependencies are available in all classpaths of a project and are propagated to dependent projects. provided is like compile, but you expect the JDK or a container to provide the dependency at runtime. A provided dependency is added to the classpath used for compilation and test, but not the runtime classpath, and it is not transitive. runtime means the dependency is not required for compilation, but is for execution. Maven includes a runtime dependency in the runtime and test classpaths, but not the compile classpath.

Test, system, and import

test means the dependency is only available for the test compilation and also execution phases. This scope is not transitive. Typically this is used for test libraries such as JUnit and Mockito. system is required for compilation and execution, but Maven will not download it; it looks for a jar at a specified local path. import is only supported on a dependency of type pom in the dependencyManagement section, where it is replaced with that POM's managed dependencies.

See also

Claims

Sources

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: Maven site, Introduction to the Dependency Mechanism, Apache-2.0 (https://www.apache.org/licenses/LICENSE-2.0.txt); apache/maven-site (GitHub), Introduction to the Dependency Mechanism, Apache-2.0 (https://www.apache.org/licenses/LICENSE-2.0.txt). Text was condensed and changed from the originals.

License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: Maven site, Introduction to the Dependency Mechanism, Apache-2.0 (https://www.apache.org/licenses/LICENSE-2.0.txt); apache/maven-site (GitHub), Introduction to the Dependency Mechanism, Apache-2.0 (https://www.apache.org/licenses/LICENSE-2.0.txt).

Cite this

Permanent ID: iil:note:2aa5ga61

iinventedlight. 2026. "Maven dependency scopes decide which classpath a library joins." iinventedlight Library, iil:note:2aa5ga61, version of 2026-11-16. https://iinventedlight.com/library/notes/maven-dependency-scopes/. License: CC-BY-4.0.

@misc{iil_note_2aa5ga61,
  author = {{iinventedlight}},
  title = {{Maven dependency scopes decide which classpath a library joins}},
  howpublished = {iinventedlight Library},
  year = {2026},
  date = {2026-11-16},
  url = {https://iinventedlight.com/library/notes/maven-dependency-scopes/},
  note = {Permanent ID iil:note:2aa5ga61. License: CC-BY-4.0.},
}

Markdown

Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).

Extra files beside this note

These files use this note's license, shown below. Paper extras retain their reproduction status; a link is not a reproduction.

All artifact files (JSON index)

For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/maven-dependency-scopes.md.