You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by el...@apache.org on 2020/06/10 14:57:57 UTC

[maven-site] branch elharo-patch-8 created (now 5a36a9a)

This is an automated email from the ASF dual-hosted git repository.

elharo pushed a change to branch elharo-patch-8
in repository https://gitbox.apache.org/repos/asf/maven-site.git.


      at 5a36a9a  docs: clarify dependency scope rules

This branch includes the following new commits:

     new 5a36a9a  docs: clarify dependency scope rules

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[maven-site] 01/01: docs: clarify dependency scope rules

Posted by el...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

elharo pushed a commit to branch elharo-patch-8
in repository https://gitbox.apache.org/repos/asf/maven-site.git

commit 5a36a9acb3c5773c3e811fa91ae1962c6a8f4717
Author: Elliotte Rusty Harold <el...@users.noreply.github.com>
AuthorDate: Wed Jun 10 10:57:51 2020 -0400

    docs: clarify dependency scope rules
    
    @suztomo
---
 .../introduction-to-dependency-mechanism.apt       | 29 +++++++++++++---------
 1 file changed, 17 insertions(+), 12 deletions(-)

diff --git a/content/apt/guides/introduction/introduction-to-dependency-mechanism.apt b/content/apt/guides/introduction/introduction-to-dependency-mechanism.apt
index a9823e9..03be8cd 100644
--- a/content/apt/guides/introduction/introduction-to-dependency-mechanism.apt
+++ b/content/apt/guides/introduction/introduction-to-dependency-mechanism.apt
@@ -122,28 +122,33 @@ Introduction to the Dependency Mechanism
 
 * {Dependency Scope}
 
- Dependency scope is used to limit the transitivity of a dependency, and also to affect the classpath used for
- various build tasks.
+ Dependency scope is used to limit the transitivity of a dependency and to determine when a dependency is
+ included in a classpath.
 
- There are 6 scopes available:
+ There are 6 scopes:
 
  * <<compile>>\
    This is the default scope, used if none is specified. Compile dependencies are available
    in all classpaths of a project. Furthermore, those dependencies are propagated to dependent projects.
 
  * <<provided>>\
-   This is much like <<<compile>>>, but indicates you expect the JDK or a container to provide the dependency at runtime. For
-   example, when building a web application for the Java Enterprise Edition, you would set the dependency on the
-   Servlet API and related Java EE APIs to scope <<<provided>>> because the web container provides those classes. This
-   scope is only available on the compilation and test classpath, and is not transitive.
+   This is much like <<<compile>>>, but indicates you expect the JDK or a container to provide the dependency at runtime.
+   For example, when building a web application for the Java Enterprise Edition, you would set the dependency on the
+   Servlet API and related Java EE APIs to scope <<<provided>>> because the web container provides those classes.
+   A dependency with this scope is added to the classpath used for compilation and test, but not the 
+   runtime classpath. It is not transitive.
 
  * <<runtime>>\
    This scope indicates that the dependency is not required for compilation, but is for
-   execution. It is in the runtime and test classpaths, but not the compile classpath.
+   execution. Maven includes a dependency with this scope in the runtime and test classpaths,
+   but not the compile classpath.
 
  * <<test>>\
    This scope indicates that the dependency is not required for normal use of the application, and
    is only available for the test compilation and execution phases. This scope is not transitive.
+   Typically this scope is used for test libraries such as JUnit and Mockito.
+   It is also used for non-test libraries such as Apache Commons IO if those libraries are used in
+   unit tests (src/test/java) but not in the model code (src/main/java).
 
  * <<system>>\
    This scope is similar to <<<provided>>> except that you have to provide the JAR
@@ -152,16 +157,16 @@ Introduction to the Dependency Mechanism
 
  * <<import>>\
    This scope is only supported on a dependency of type <<<pom>>> in the <<<\<dependencyManagement\>>>> section. It
-   indicates the dependency to be replaced with the effective list of dependencies in the specified POM's
+   indicates the dependency is to be replaced with the effective list of dependencies in the specified POM's
    <<<\<dependencyManagement\>>>> section. Since they are replaced, dependencies with a scope of <<<import>>> do not
    actually participate in limiting the transitivity of a dependency.
 
  []
 
  Each of the scopes (except for <<<import>>>) affects transitive dependencies in different ways, as is demonstrated in the table below.
- If a dependency is set to the scope in the left column, transitive dependencies of that dependency with the
- scope across the top row will result in a dependency in the main project with the scope listed at the
- intersection. If no scope is listed, it means the dependency will be omitted.
+ If a dependency is set to the scope in the left column, a transitive dependency of that dependency with the
+ scope across the top row results in a dependency in the main project with the scope listed at the
+ intersection. If no scope is listed, it means the dependency is omitted.
 
 *----------+------------+----------+----------+------+
 |          | compile    | provided | runtime  | test