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
- id: C1 claim: Maven includes transitive dependencies automatically. source: S1 evidence: "including transitive dependencies automatically."
- id: C2 claim: compile is the default scope when none is specified. source: S1 evidence: "This is the default scope, used if none is specified."
- id: C3 claim: A runtime-scoped dependency is on the runtime and test classpaths, not compile. source: S2 evidence: "in the runtime and test classpaths, but not the compile classpath."
- id: C4 claim: The test scope is not transitive. source: S2 evidence: "This scope is not transitive."
Sources
- [S1] Introduction to the Dependency Mechanism. Maven site. https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html . License: Apache-2.0. Accessed 2026-11-16.
- [S2] Introduction to the Dependency Mechanism (Maven site source). apache/maven-site (GitHub). https://github.com/apache/maven-site/blob/master/content/markdown/guides/introduction/introduction-to-dependency-mechanism.md . License: Apache-2.0. Accessed 2026-11-16.
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
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.},
}
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.
- maven-dependency-scopes.table.json (table; CC-BY-4.0)
- maven-dependency-scopes.schema.json (schema; CC-BY-4.0)
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.