In the previous chapter, we have seen the groupId
, artifactId
, and version
tags, used to determine in a deterministic way a project.
The dependency
tag owns another subtag named scope
.
The scope hints at the visibility of a dependency, relatively to the different life phases (build, test, runtime, and so on). Maven provides six scopes: compile
, provided
, runtime
, test
, system
, and import
.
Let's review them a bit more.
This is the default scope. Dependencies with <scope>compile</scope>
are needed to build, test, and run, and are propagated to dependent projects.
Scope compile
is to be used in most of the cases, for instance, when a class of your src/
folder uses imports of classes.
So, as an example, consider that your code holds the following:
import org.apache.log4j.Logger; import org.springframework.util.Assert;
If your code holds the preceding lines then, your pom.xml
will contain the following:
<dependencies> <dependency...