You are viewing a plain text version of this content. The canonical link for it is here.
Posted to site-commits@maven.apache.org by sl...@apache.org on 2023/02/09 00:34:07 UTC

svn commit: r1907531 [8/25] - in /maven/website/content: ./ apache-resource-bundles/ archives/maven-2.x/ background/ developers/ developers/conventions/ developers/release/ developers/website/ docs/ docs/2.0.1/ docs/2.0.10/ docs/2.0.11/ docs/2.0.2/ doc...

Modified: maven/website/content/guides/getting-started/index.html
==============================================================================
--- maven/website/content/guides/getting-started/index.html (original)
+++ maven/website/content/guides/getting-started/index.html Thu Feb  9 00:34:05 2023
@@ -2,7 +2,7 @@
 
 
 <!--
- | Generated by Apache Maven Doxia Site Renderer 2.0.0-M4 from content/apt/guides/getting-started/index.apt at 2023-02-08
+ | Generated by Apache Maven Doxia Site Renderer 2.0.0-M4 from content/markdown/guides/getting-started/index.md at 2023-02-09
  | Rendered using Apache Maven Fluido Skin 1.11.1
 -->
 <html xmlns="http://www.w3.org/1999/xhtml" lang="">
@@ -10,8 +10,7 @@
     <meta charset="UTF-8" />
     <meta name="viewport" content="width=device-width, initial-scale=1" />
     <meta name="generator" content="Apache Maven Doxia Site Renderer 2.0.0-M4" />
-    <meta name="author" content="Jason van Zyl
-Vincent Siveton" />
+    <meta name="author" content="Jason van Zyl, Vincent Siveton" />
     <meta name="date" content="2006-11-01" />
     <title>Maven &#x2013; Maven Getting Started Guide</title>
     <link rel="stylesheet" href="../../css/apache-maven-fluido-1.11.1.min.css" />
@@ -49,8 +48,8 @@ Vincent Siveton" />
           <ul class="breadcrumb">
       <li class=""><a href="https://www.apache.org/" class="externalLink" title="Apache">Apache</a><span class="divider">/</span></li>
       <li class=""><a href="../../index.html" title="Maven">Maven</a><span class="divider">/</span></li>
-    <li class="active ">Maven Getting Started Guide <a href="https://github.com/apache/maven-site/tree/master/content/apt/guides/getting-started/index.apt"><img src="../../images/accessories-text-editor.png" title="Edit" /></a></li>
-        <li id="publishDate" class="pull-right"><span class="divider">|</span> Last Published: 2023-02-08</li>
+    <li class="active ">Maven Getting Started Guide <a href="https://github.com/apache/maven-site/tree/master/content/markdown/guides/getting-started/index.md"><img src="../../images/accessories-text-editor.png" title="Edit" /></a></li>
+        <li id="publishDate" class="pull-right"><span class="divider">|</span> Last Published: 2023-02-09</li>
         <li class="pull-right"><span class="divider">|</span>
 <a href="../../scm.html" title="Get Sources">Get Sources</a></li>
         <li class="pull-right"><a href="../../download.cgi" title="Download">Download</a></li>
@@ -146,51 +145,98 @@ Vincent Siveton" />
           </div>
         </header>
         <main id="bodyColumn"  class="span10" >
-<section>
-<h1>Maven Getting Started Guide</h1>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+<section><section>
+<h2>Maven Getting Started Guide</h2>
 <p>This guide is intended as a reference for those working with Maven for the first time, but is also intended to serve as a cookbook with self-contained references and solutions for common use cases. For first time users, it is recommended that you step through the material in a sequential fashion. For users more familiar with Maven, this guide endeavours to provide a quick solution for the need at hand. It is assumed at this point that you have downloaded Maven and installed Maven on your local machine. If you have not done so please refer to the <a href="../../download.html">Download and Installation</a> instructions.</p>
 <p>Ok, so you now have Maven installed and we're ready to go. Before we jump into our examples we'll very briefly go over what Maven is and how it can help you with your daily work and collaborative efforts with team members. Maven will, of course, work for small projects, but Maven shines in helping teams operate more effectively by allowing team members to focus on what the stakeholders of a project require. You can leave the build infrastructure to Maven!</p></section><section>
-<h1>Sections</h1>
+<h2>Sections</h2>
 <ul>
-<li><a href="./index.html#What_is_Maven">What is Maven?</a></li>
-<li><a href="./index.html#How_can_Maven_benefit_my_development_process">How can Maven benefit my development process?</a></li>
-<li><a href="./index.html#How_do_I_setup_Maven">How do I setup Maven?</a></li>
-<li><a href="./index.html#How_do_I_make_my_first_Maven_project">How do I make my first Maven project?</a></li>
-<li><a href="./index.html#How_do_I_compile_my_application_sources">How do I compile my application sources?</a></li>
-<li><a href="./index.html#How_do_I_compile_my_test_sources_and_run_my_unit_tests">How do I compile my test sources and run my unit tests?</a></li>
-<li><a href="./index.html#How_do_I_create_a_JAR_and_install_it_in_my_local_repository">How do I create a JAR and install it in my local repository?</a></li>
-<li><a href="./index.html#What_is_a_SNAPSHOT_version">What is a SNAPSHOT version?</a></li>
-<li><a href="./index.html#How_do_I_use_plugins">How do I use plugins?</a></li>
-<li><a href="./index.html#How_do_I_add_resources_to_my_JAR">How do I add resources to my JAR?</a></li>
-<li><a href="./index.html#How_do_I_filter_resource_files">How do I filter resource files?</a></li>
-<li><a href="./index.html#How_do_I_use_external_dependencies">How do I use external dependencies?</a></li>
-<li><a href="./index.html#How_do_I_deploy_my_jar_in_my_remote_repository">How do I deploy my jar in my remote repository?</a></li>
-<li><a href="./index.html#How_do_I_create_documentation">How do I create documentation?</a></li>
-<li><a href="./index.html#How_do_I_build_other_types_of_projects">How do I build other types of projects?</a></li>
-<li><a href="./index.html#How_do_I_build_more_than_one_project_at_once">How do I build more than one project at once?</a></li></ul><section>
-<h2><a id="What_is_Maven">What is Maven?</a></h2>
-<p>At first glance Maven can appear to be many things, but in a nutshell Maven is an attempt <i>to apply patterns to a project's build infrastructure in order to promote comprehension and productivity by providing a clear path in the use of best practices</i>. Maven is essentially a project management and comprehension tool and as such provides a way to help with managing:</p>
+
+<li>
+<p><a href="./index.html#What_is_Maven">What is Maven?</a></p></li>
+<li>
+<p><a href="./index.html#How_can_Maven_benefit_my_development_process">How can Maven benefit my development process?</a></p></li>
+<li>
+<p><a href="./index.html#How_do_I_setup_Maven">How do I setup Maven?</a></p></li>
+<li>
+<p><a href="./index.html#How_do_I_make_my_first_Maven_project">How do I make my first Maven project?</a></p></li>
+<li>
+<p><a href="./index.html#How_do_I_compile_my_application_sources">How do I compile my application sources?</a></p></li>
+<li>
+<p><a href="./index.html#How_do_I_compile_my_test_sources_and_run_my_unit_tests">How do I compile my test sources and run my unit tests?</a></p></li>
+<li>
+<p><a href="./index.html#How_do_I_create_a_JAR_and_install_it_in_my_local_repository">How do I create a JAR and install it in my local repository?</a></p></li>
+<li>
+<p><a href="./index.html#What_is_a_SNAPSHOT_version">What is a SNAPSHOT version?</a></p></li>
+<li>
+<p><a href="./index.html#How_do_I_use_plugins">How do I use plugins?</a></p></li>
+<li>
+<p><a href="./index.html#How_do_I_add_resources_to_my_JAR">How do I add resources to my JAR?</a></p></li>
+<li>
+<p><a href="./index.html#How_do_I_filter_resource_files">How do I filter resource files?</a></p></li>
+<li>
+<p><a href="./index.html#How_do_I_use_external_dependencies">How do I use external dependencies?</a></p></li>
+<li>
+<p><a href="./index.html#How_do_I_deploy_my_jar_in_my_remote_repository">How do I deploy my jar in my remote repository?</a></p></li>
+<li>
+<p><a href="./index.html#How_do_I_create_documentation">How do I create documentation?</a></p></li>
+<li>
+<p><a href="./index.html#How_do_I_build_other_types_of_projects">How do I build other types of projects?</a></p></li>
+<li>
+<p><a href="./index.html#How_do_I_build_more_than_one_project_at_once">How do I build more than one project at once?</a></p></li>
+</ul><section>
+<h3>What is Maven?</h3>
+<p>At first glance Maven can appear to be many things, but in a nutshell Maven is an attempt <em>to apply patterns to a project's build infrastructure in order to promote comprehension and productivity by providing a clear path in the use of best practices</em>. Maven is essentially a project management and comprehension tool and as such provides a way to help with managing:</p>
 <ul>
-<li>Builds</li>
-<li>Documentation</li>
-<li>Reporting</li>
-<li>Dependencies</li>
-<li>SCMs</li>
-<li>Releases</li>
-<li>Distribution</li></ul>
+
+<li>
+<p>Builds</p></li>
+<li>
+<p>Documentation</p></li>
+<li>
+<p>Reporting</p></li>
+<li>
+<p>Dependencies</p></li>
+<li>
+<p>SCMs</p></li>
+<li>
+<p>Releases</p></li>
+<li>
+<p>Distribution</p></li>
+</ul>
 <p>If you want more background information on Maven you can check out <a href="../../background/philosophy-of-maven.html">The Philosophy of Maven</a> and <a href="../../background/history-of-maven.html">The History of Maven</a>. Now let's move on to how you, the user, can benefit from using Maven.</p></section><section>
-<h2><a id="How_can_Maven_benefit_my_development_process">How can Maven benefit my development process?</a></h2>
+<h3>How can Maven benefit my development process?</h3>
 <p>Maven can provide benefits for your build process by employing standard conventions and practices to accelerate your development cycle while at the same time helping you achieve a higher rate of success.</p>
 <p>Now that we have covered a little bit of the history and purpose of Maven let's get into some real examples to get you up and running with Maven!</p></section><section>
-<h2><a id="How_do_I_setup_Maven">How do I setup Maven?</a></h2>
-<p>The defaults for Maven are often sufficient, but if you need to change the cache location or are behind a HTTP proxy, you will need to create configuration. See the <a href="../mini/guide-configuring-maven.html"> Guide to Configuring Maven</a> for more information.</p></section><section>
-<h2><a id="How_do_I_make_my_first_Maven_project">How do I make my first Maven project?</a></h2>
-<p>We are going to jump headlong into creating your first Maven project! To create our first Maven project we are going to use Maven's archetype mechanism. An archetype is defined as <i>an original pattern or model from which all other things of the same kind are made</i>. In Maven, an archetype is a template of a project which is combined with some user input to produce a working Maven project that has been tailored to the user's requirements. We are going to show you how the archetype mechanism works now, but if you would like to know more about archetypes please refer to our <a href="../introduction/introduction-to-archetypes.html">Introduction to Archetypes</a>.</p>
+<h3>How do I setup Maven?</h3>
+<p>The defaults for Maven are often sufficient, but if you need to change the cache location or are behind a HTTP proxy, you will need to create configuration. See the <a href="../mini/guide-configuring-maven.html">Guide to Configuring Maven</a> for more information.</p></section><section>
+<h3>How do I make my first Maven project?</h3>
+<p>We are going to jump headlong into creating your first Maven project! To create our first Maven project we are going to use Maven's archetype mechanism. An archetype is defined as <em>an original pattern or model from which all other things of the same kind are made</em>. In Maven, an archetype is a template of a project which is combined with some user input to produce a working Maven project that has been tailored to the user's requirements. We are going to show you how the archetype mechanism works now, but if you would like to know more about archetypes please refer to our <a href="../introduction/introduction-to-archetypes.html">Introduction to Archetypes</a>.</p>
 <p>On to creating your first project! In order to create the simplest of Maven projects, execute the following from the command line:</p>
-<div>
-<pre>mvn -B archetype:generate -DgroupId=com.mycompany.app -DartifactId=my-app -DarchetypeArtifactId=maven-archetype-quickstart -DarchetypeVersion=1.4</pre></div>
+
+<div class="source"><pre class="prettyprint linenums"><code>mvn -B archetype:generate -DgroupId=com.mycompany.app -DartifactId=my-app -DarchetypeArtifactId=maven-archetype-quickstart -DarchetypeVersion=1.4
+</code></pre></div>
 <p>Once you have executed this command, you will notice a few things have happened. First, you will notice that a directory named <code>my-app</code> has been created for the new project, and this directory contains a file named <code>pom.xml</code> that should look like this:</p>
-<div class="source"><pre class="prettyprint linenums">&lt;project xmlns=&quot;http://maven.apache.org/POM/4.0.0&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
+
+<div class="source"><pre class="prettyprint linenums"><code>&lt;project xmlns=&quot;http://maven.apache.org/POM/4.0.0&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
   xsi:schemaLocation=&quot;http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd&quot;&gt;
   &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
 
@@ -222,24 +268,37 @@ Vincent Siveton" />
        ... lots of helpful plugins
     &lt;/pluginManagement&gt;
   &lt;/build&gt;
-&lt;/project&gt;</pre></div>
+&lt;/project&gt;
+</code></pre></div>
 <p><code>pom.xml</code> contains the Project Object Model (POM) for this project. The POM is the basic unit of work in Maven. This is important to remember because Maven is inherently project-centric in that everything revolves around the notion of a project. In short, the POM contains every important piece of information about your project and is essentially one-stop-shopping for finding anything related to your project. Understanding the POM is important and new users are encouraged to refer to the <a href="../introduction/introduction-to-the-pom.html">Introduction to the POM</a>.</p>
 <p>This is a very simple POM but still displays the key elements every POM contains, so let's walk through each of them to familiarize you with the POM essentials:</p>
 <ul>
-<li><b>project</b> This is the top-level element in all Maven pom.xml files.</li>
-<li><b>modelVersion</b> This element indicates what version of the object model this POM is using. The version of the model itself changes very infrequently but it is mandatory in order to ensure stability of use if and when the Maven developers deem it necessary to change the model.</li>
-<li><b>groupId</b> This element indicates the unique identifier of the organization or group that created the project. The groupId is one of the key identifiers of a project and is typically based on the fully qualified domain name of your organization. For example <code>org.apache.maven.plugins</code> is the designated groupId for all Maven plugins.</li>
-<li><b>artifactId</b> This element indicates the unique base name of the primary artifact being generated by this project. The primary artifact for a project is typically a JAR file. Secondary artifacts like source bundles also use the artifactId as part of their final name. A typical artifact produced by Maven would have the form &lt;artifactId&gt;-&lt;version&gt;.&lt;extension&gt; (for example, <code>myapp-1.0.jar</code>).</li>
-<li><b>version</b> This element indicates the version of the artifact generated by the project. Maven goes a long way to help you with version management and you will often see the <code>SNAPSHOT</code> designator in a version, which indicates that a project is in a state of development. We will discuss the use of <a href="./index.html#What_is_a_SNAPSHOT_version">snapshots</a> and how they work further on in this guide.</li>
-<li><b>name</b> This element indicates the display name used for the project. This is often used in Maven's generated documentation.</li>
-<li><b>url</b> This element indicates where the project's site can be found. This is often used in Maven's generated documentation.</li>
-<li><b>properties</b> This element contains value placeholders accessible anywhere within a POM.</li>
-<li><b>dependencies</b> This element's children list <a href="/pom.html#dependencies">dependencies</a>. The cornerstone of the POM.</li>
-<li><b>build</b> This element handles things like declaring your project's directory structure and managing plugins.</li></ul>
+
+<li>
+<p><strong>project</strong> This is the top-level element in all Maven pom.xml files.</p></li>
+<li>
+<p><strong>modelVersion</strong> This element indicates what version of the object model this POM is using. The version of the model itself changes very infrequently but it is mandatory in order to ensure stability of use if and when the Maven developers deem it necessary to change the model.</p></li>
+<li>
+<p><strong>groupId</strong> This element indicates the unique identifier of the organization or group that created the project. The groupId is one of the key identifiers of a project and is typically based on the fully qualified domain name of your organization. For example <code>org.apache.maven.plugins</code> is the designated groupId for all Maven plugins.</p></li>
+<li>
+<p><strong>artifactId</strong> This element indicates the unique base name of the primary artifact being generated by this project. The primary artifact for a project is typically a JAR file. Secondary artifacts like source bundles also use the artifactId as part of their final name. A typical artifact produced by Maven would have the form &lt;artifactId&gt;-&lt;version&gt;.&lt;extension&gt; (for example, <code>myapp-1.0.jar</code>).</p></li>
+<li>
+<p><strong>version</strong> This element indicates the version of the artifact generated by the project. Maven goes a long way to help you with version management and you will often see the <code>SNAPSHOT</code> designator in a version, which indicates that a project is in a state of development. We will discuss the use of <a href="./index.html#What_is_a_SNAPSHOT_version">snapshots</a> and how they work further on in this guide.</p></li>
+<li>
+<p><strong>name</strong> This element indicates the display name used for the project. This is often used in Maven's generated documentation.</p></li>
+<li>
+<p><strong>url</strong> This element indicates where the project's site can be found. This is often used in Maven's generated documentation.</p></li>
+<li>
+<p><strong>properties</strong> This element contains value placeholders accessible anywhere within a POM.</p></li>
+<li>
+<p><strong>dependencies</strong> This element's children list <a href="/pom.html#dependencies">dependencies</a>. The cornerstone of the POM.</p></li>
+<li>
+<p><strong>build</strong> This element handles things like declaring your project's directory structure and managing plugins.</p></li>
+</ul>
 <p>For a complete reference of what elements are available for use in the POM please refer to our <a href="/ref/current/maven-model/maven.html">POM Reference</a>. Now let's get back to the project at hand.</p>
 <p>After the archetype generation of your first project you will also notice that the following directory structure has been created:</p>
-<div>
-<pre>my-app
+
+<div class="source"><pre class="prettyprint linenums"><code>my-app
 |-- pom.xml
 `-- src
     |-- main
@@ -253,17 +312,19 @@ Vincent Siveton" />
             `-- com
                 `-- mycompany
                     `-- app
-                        `-- AppTest.java</pre></div>
-<p>As you can see, the project created from the archetype has a POM, a source tree for your application's sources and a source tree for your test sources. This is the standard layout for Maven projects (the application sources reside in <code>${basedir}/src/main/java</code> and test sources reside in <code>${basedir}/src/test/java</code>, where ${basedir} represents the directory containing <code>pom.xml</code>).</p>
+                        `-- AppTest.java
+</code></pre></div>
+<p>As you can see, the project created from the archetype has a POM, a source tree for your application's sources and a source tree for your test sources. This is the standard layout for Maven projects (the application sources reside in <code>$\{basedir\}/src/main/java</code> and test sources reside in <code>$\{basedir\}/src/test/java</code>, where ${basedir} represents the directory containing <code>pom.xml</code>).</p>
 <p>If you were to create a Maven project by hand this is the directory structure that we recommend using. This is a Maven convention and to learn more about it you can read our <a href="../introduction/introduction-to-the-standard-directory-layout.html">Introduction to the Standard Directory Layout</a>.</p>
-<p>Now that we have a POM, some application sources, and some test sources you are probably asking...</p></section><section>
-<h2><a id="How_do_I_compile_my_application_sources">How do I compile my application sources?</a></h2>
+<p>Now that we have a POM, some application sources, and some test sources you are probably asking&#x2026;</p></section><section>
+<h3>How do I compile my application sources?</h3>
 <p>Change to the directory where pom.xml is created by archetype:generate and execute the following command to compile your application sources:</p>
-<div>
-<pre>mvn compile</pre></div>
+
+<div class="source"><pre class="prettyprint linenums"><code>mvn compile
+</code></pre></div>
 <p>Upon executing this command you should see output like the following:</p>
-<div>
-<pre>[INFO] Scanning for projects...
+
+<div class="source"><pre class="prettyprint linenums"><code>[INFO] Scanning for projects...
 [INFO] 
 [INFO] ----------------------&lt; com.mycompany.app:my-app &gt;----------------------
 [INFO] Building my-app 1.0-SNAPSHOT
@@ -281,18 +342,20 @@ Vincent Siveton" />
 [INFO] ------------------------------------------------------------------------
 [INFO] Total time:  0.899 s
 [INFO] Finished at: 2020-07-12T11:31:54+01:00
-[INFO] ------------------------------------------------------------------------</pre></div>
+[INFO] ------------------------------------------------------------------------
+</code></pre></div>
 <p>The first time you execute this (or any other) command, Maven will need to download all the plugins and related dependencies it needs to fulfill the command. From a clean installation of Maven, this can take quite a while (in the output above, it took almost 4 minutes). If you execute the command again, Maven will now have what it needs, so it won't need to download anything new and will be able to execute the command much more quickly.</p>
-<p>As you can see from the output, the compiled classes were placed in <code>${basedir}/target/classes</code>, which is another standard convention employed by Maven. So, if you're a keen observer, you'll notice that by using the standard conventions, the POM above is very small and you haven't had to tell Maven explicitly where any of your sources are or where the output should go. By following the standard Maven conventions, you can get a lot done with very little effort! Just as a casual comparison, let's take a look at what you might have had to do in <a class="externalLink" href="http://ant.apache.org">Ant</a> to accomplish the same <a href="../../ant/build-a1.xml">thing</a>.</p>
+<p>As you can see from the output, the compiled classes were placed in <code>$\{basedir\}/target/classes</code>, which is another standard convention employed by Maven. So, if you're a keen observer, you'll notice that by using the standard conventions, the POM above is very small and you haven't had to tell Maven explicitly where any of your sources are or where the output should go. By following the standard Maven conventions, you can get a lot done with very little effort! Just as a casual comparison, let's take a look at what you might have had to do in <a href="http://ant.apache.org" class="externalLink">Ant</a> to accomplish the same <a href="../../ant/build-a1.xml">thing</a>.</p>
 <p>Now, this is simply to compile a single tree of application sources and the Ant script shown is pretty much the same size as the POM shown above. But we'll see how much more we can do with just that simple POM!</p></section><section>
-<h2><a id="How_do_I_compile_my_test_sources_and_run_my_unit_tests">How do I compile my test sources and run my unit tests?</a></h2>
+<h3>How do I compile my test sources and run my unit tests?</h3>
 <p>Now you're successfully compiling your application's sources and now you've got some unit tests that you want to compile and execute (because every programmer always writes and executes their unit tests *nudge nudge wink wink*).</p>
 <p>Execute the following command:</p>
-<div>
-<pre>mvn test</pre></div>
+
+<div class="source"><pre class="prettyprint linenums"><code>mvn test
+</code></pre></div>
 <p>Upon executing this command you should see output like the following:</p>
-<div>
-<pre>[INFO] Scanning for projects...
+
+<div class="source"><pre class="prettyprint linenums"><code>[INFO] Scanning for projects...
 [INFO] 
 [INFO] ----------------------&lt; com.mycompany.app:my-app &gt;----------------------
 [INFO] Building my-app 1.0-SNAPSHOT
@@ -330,26 +393,34 @@ Vincent Siveton" />
 [INFO] ------------------------------------------------------------------------
 [INFO] Total time:  1.881 s
 [INFO] Finished at: 2020-07-12T12:00:33+01:00
-[INFO] ------------------------------------------------------------------------</pre></div>
+[INFO] ------------------------------------------------------------------------
+</code></pre></div>
 <p>Some things to notice about the output:</p>
 <ul>
-<li>Maven downloads more dependencies this time. These are the dependencies and plugins necessary for executing the tests (it already has the dependencies it needs for compiling and won't download them again).</li>
-<li>Before compiling and executing the tests Maven compiles the main code (all these classes are up to date because we haven't changed anything since we compiled last).</li></ul>
+
+<li>
+<p>Maven downloads more dependencies this time. These are the dependencies and plugins necessary for executing the tests (it already has the dependencies it needs for compiling and won't download them again).</p></li>
+<li>
+<p>Before compiling and executing the tests Maven compiles the main code (all these classes are up to date because we haven't changed anything since we compiled last).</p></li>
+</ul>
 <p>If you simply want to compile your test sources (but not execute the tests), you can execute the following:</p>
-<div>
-<pre> mvn test-compile</pre></div>
-<p>Now that you can compile your application sources, compile your tests, and execute the tests, you'll want to move on to the next logical step so you'll be asking ...</p></section><section>
-<h2><a id="How_do_I_create_a_JAR_and_install_it_in_my_local_repository">How do I create a JAR and install it in my local repository?</a></h2>
-<p>Making a JAR file is straight forward enough and can be accomplished by executing the following command:</p>
-<div>
-<pre>mvn package</pre></div>
-<p>You can now take a look in the <code>${basedir}/target</code> directory and you will see the generated JAR file.</p>
-<p>Now you'll want to install the artifact you've generated (the JAR file) in your local repository (<code>${user.home}/.m2/repository</code> is the default location). For more information on repositories you can refer to our <a href="../introduction/introduction-to-repositories.html">Introduction to Repositories</a> but let's move on to installing our artifact! To do so execute the following command:</p>
-<div>
-<pre>mvn install</pre></div>
+
+<div class="source"><pre class="prettyprint linenums"><code> mvn test-compile
+</code></pre></div>
+<p>Now that you can compile your application sources, compile your tests, and execute the tests, you'll want to move on to the next logical step so you'll be asking &#x2026;</p></section><section>
+<h3>How do I create a JAR and install it in my local repository?</h3>
+<p>Making a JAR file is straight forward enough and can be accomplished by executing the following command:</p><!--  How to skip tests ... jvz -->
+
+<div class="source"><pre class="prettyprint linenums"><code>mvn package
+</code></pre></div>
+<p>You can now take a look in the <code>$\{basedir\}/target</code> directory and you will see the generated JAR file.</p>
+<p>Now you'll want to install the artifact you've generated (the JAR file) in your local repository (<code>$\{user.home\}/.m2/repository</code> is the default location). For more information on repositories you can refer to our <a href="../introduction/introduction-to-repositories.html">Introduction to Repositories</a> but let's move on to installing our artifact! To do so execute the following command:</p>
+
+<div class="source"><pre class="prettyprint linenums"><code>mvn install
+</code></pre></div>
 <p>Upon executing this command you should see the following output:</p>
-<div>
-<pre>[INFO] Scanning for projects...
+
+<div class="source"><pre class="prettyprint linenums"><code>[INFO] Scanning for projects...
 [INFO] 
 [INFO] ----------------------&lt; com.mycompany.app:my-app &gt;----------------------
 [INFO] Building my-app 1.0-SNAPSHOT
@@ -389,41 +460,56 @@ Vincent Siveton" />
 [INFO] ------------------------------------------------------------------------
 [INFO] Total time:  1.678 s
 [INFO] Finished at: 2020-07-12T12:04:45+01:00
-[INFO] ------------------------------------------------------------------------</pre></div>
+[INFO] ------------------------------------------------------------------------
+</code></pre></div>
 <p>Note that the surefire plugin (which executes the test) looks for tests contained in files with a particular naming convention. By default the tests included are:</p>
 <ul>
-<li><code>**/*Test.java</code></li>
-<li><code>**/Test*.java</code></li>
-<li><code>**/*TestCase.java</code></li></ul>
+
+<li>
+<p><code>\*\*/\*Test.java</code></p></li>
+<li>
+<p><code>\*\*/Test\*.java</code></p></li>
+<li>
+<p><code>\*\*/\*TestCase.java</code></p></li>
+</ul>
 <p>And the default excludes are:</p>
 <ul>
-<li><code>**/Abstract*Test.java</code></li>
-<li><code>**/Abstract*TestCase.java</code></li></ul>
+
+<li>
+<p><code>\*\*/Abstract\*Test.java</code></p></li>
+<li>
+<p><code>\*\*/Abstract\*TestCase.java</code></p></li>
+</ul>
 <p>You have walked through the process for setting up, building, testing, packaging, and installing a typical Maven project. This is likely the vast majority of what projects will be doing with Maven and if you've noticed, everything you've been able to do up to this point has been driven by an 18-line file, namely the project's model or POM. If you look at a typical Ant <a href="../../ant/build-a1.xml">build file</a> that provides the same functionality that we've achieved thus far you'll notice it's already twice the size of the POM and we're just getting started! There is far more functionality available to you from Maven without requiring any additions to our POM as it currently stands. To get any more functionality out of our example Ant build file you must keep making error-prone additions.</p>
 <p>So what else can you get for free? There are a great number of Maven plugins that work out of the box with even a simple POM like we have above. We'll mention one here specifically as it is one of the highly prized features of Maven: without any work on your part this POM has enough information to generate a web site for your project! You will most likely want to customize your Maven site but if you're pressed for time all you need to do to provide basic information about your project is execute the following command:</p>
-<div>
-<pre>mvn site</pre></div>
+
+<div class="source"><pre class="prettyprint linenums"><code>mvn site
+</code></pre></div>
 <p>There are plenty of other standalone goals that can be executed as well, for example:</p>
-<div>
-<pre>mvn clean</pre></div>
+
+<div class="source"><pre class="prettyprint linenums"><code>mvn clean
+</code></pre></div>
 <p>This will remove the <code>target</code> directory with all the build data before starting so that it is fresh.</p></section><section>
-<h2><a id="What_is_a_SNAPSHOT_version">What is a SNAPSHOT version?</a></h2>
-<p>Notice the value of the <b>version</b> tag in the <code>pom.xml</code> file shown below has the suffix: <code>-SNAPSHOT</code>.</p>
-<div class="source"><pre class="prettyprint linenums">&lt;project xmlns=&quot;http://maven.apache.org/POM/4.0.0&quot;
+<h3>What is a SNAPSHOT version?</h3>
+<p>Notice the value of the <strong>version</strong> tag in the <code>pom.xml</code> file shown below has the suffix: <code>-SNAPSHOT</code>.</p>
+
+<div class="source"><pre class="prettyprint linenums"><code>&lt;project xmlns=&quot;http://maven.apache.org/POM/4.0.0&quot;
   ...
   &lt;groupId&gt;...&lt;/groupId&gt;
   &lt;artifactId&gt;my-app&lt;/artifactId&gt;
   ...
   &lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;
   &lt;name&gt;Maven Quick Start Archetype&lt;/name&gt;
-  ...</pre></div>
-<p>The <code>SNAPSHOT</code> value refers to the 'latest' code along a development branch, and provides no guarantee the code is stable or unchanging. Conversely, the code in a 'release' version (any version value without the suffix <code>SNAPSHOT</code>) is unchanging.</p>
-<p>In other words, a SNAPSHOT version is the 'development' version before the final 'release' version. The SNAPSHOT is &quot;older&quot; than its release.</p>
-<p>During the <a href="../../plugins/maven-release-plugin/">release</a> process, a version of <b>x.y-SNAPSHOT</b> changes to <b>x.y</b>. The release process also increments the development version to <b>x.(y+1)-SNAPSHOT</b>. For example, version <b>1.0-SNAPSHOT</b> is released as version <b>1.0</b>, and the new development version is version <b>1.1-SNAPSHOT</b>.</p></section><section>
-<h2><a id="How_do_I_use_plugins">How do I use plugins?</a></h2>
+  ...
+</code></pre></div>
+<p>The <code>SNAPSHOT</code> value refers to the &#x2018;latest&#x2019; code along a development branch, and provides no guarantee the code is stable or unchanging. Conversely, the code in a &#x2018;release&#x2019; version (any version value without the suffix <code>SNAPSHOT</code>) is unchanging.</p>
+<p>In other words, a SNAPSHOT version is the &#x2018;development&#x2019; version before the final &#x2018;release&#x2019; version. The SNAPSHOT is &#x201c;older&#x201d; than its release.</p>
+<p>During the <a href="../../plugins/maven-release-plugin/">release</a> process, a version of <strong>x.y-SNAPSHOT</strong> changes to <strong>x.y</strong>. The release process also increments the development version to <strong>x.(y+1)-SNAPSHOT</strong>. For example, version <strong>1.0-SNAPSHOT</strong> is released as version <strong>1.0</strong>, and the new development version is version <strong>1.1-SNAPSHOT</strong>.</p></section><section>
+<h3>How do I use plugins?</h3>
 <p>Whenever you want to customise the build for a Maven project, this is done by adding or reconfiguring plugins.</p>
 <p>For this example, we will configure the Java compiler to allow JDK 5.0 sources. This is as simple as adding this to your POM:</p>
-<div class="source"><pre class="prettyprint linenums">...
+
+<div class="source"><pre class="prettyprint linenums"><code>...
 &lt;build&gt;
   &lt;plugins&gt;
     &lt;plugin&gt;
@@ -437,15 +523,16 @@ Vincent Siveton" />
     &lt;/plugin&gt;
   &lt;/plugins&gt;
 &lt;/build&gt;
-...</pre></div>
+...
+</code></pre></div>
 <p>You'll notice that all plugins in Maven look much like a dependency - and in some ways they are. This plugin will be automatically downloaded and used - including a specific version if you request it (the default is to use the latest available).</p>
-<p>The <code>configuration</code> element applies the given parameters to every goal from the compiler plugin. In the above case, the compiler plugin is already used as part of the build process and this just changes the configuration. It is also possible to add new goals to the process, and configure specific goals. For information on this, see the <a href="../introduction/introduction-to-the-lifecycle.html"> Introduction to the Build Lifecycle</a>.</p>
-<p>To find out what configuration is available for a plugin, you can see the <a href="../../plugins/"> Plugins List</a> and navigate to the plugin and goal you are using. For general information about how to configure the available parameters of a plugin, have a look at the <a href="../mini/guide-configuring-plugins.html">Guide to Configuring Plugins</a>.</p></section><section>
-<h2><a id="How_do_I_add_resources_to_my_JAR">How do I add resources to my JAR?</a></h2>
+<p>The <code>configuration</code> element applies the given parameters to every goal from the compiler plugin. In the above case, the compiler plugin is already used as part of the build process and this just changes the configuration. It is also possible to add new goals to the process, and configure specific goals. For information on this, see the <a href="../introduction/introduction-to-the-lifecycle.html">Introduction to the Build Lifecycle</a>.</p>
+<p>To find out what configuration is available for a plugin, you can see the <a href="../../plugins/">Plugins List</a> and navigate to the plugin and goal you are using. For general information about how to configure the available parameters of a plugin, have a look at the <a href="../mini/guide-configuring-plugins.html">Guide to Configuring Plugins</a>.</p></section><section>
+<h3>How do I add resources to my JAR?</h3>
 <p>Another common use case that can be satisfied which requires no changes to the POM that we have above is packaging resources in the JAR file. For this common task, Maven again relies on the <a href="../introduction/introduction-to-the-standard-directory-layout.html">Standard Directory Layout</a>, which means by using standard Maven conventions you can package resources within JARs simply by placing those resources in a standard directory structure.</p>
-<p>You see below in our example we have added the directory <code>${basedir}/src/main/resources</code> into which we place any resources we wish to package in our JAR. The simple rule employed by Maven is this: any directories or files placed within the <code>${basedir}/src/main/resources</code> directory are packaged in your JAR with the exact same structure starting at the base of the JAR.</p>
-<div>
-<pre>my-app
+<p>You see below in our example we have added the directory <code>$\{basedir\}/src/main/resources</code> into which we place any resources we wish to package in our JAR. The simple rule employed by Maven is this: any directories or files placed within the <code>$\{basedir\}/src/main/resources</code> directory are packaged in your JAR with the exact same structure starting at the base of the JAR.</p>
+
+<div class="source"><pre class="prettyprint linenums"><code>my-app
 |-- pom.xml
 `-- src
     |-- main
@@ -462,10 +549,11 @@ Vincent Siveton" />
             `-- com
                 `-- mycompany
                     `-- app
-                        `-- AppTest.java</pre></div>
+                        `-- AppTest.java
+</code></pre></div>
 <p>So you can see in our example that we have a <code>META-INF</code> directory with an <code>application.properties</code> file within that directory. If you unpacked the JAR that Maven created for you and took a look at it you would see the following:</p>
-<div>
-<pre>|-- META-INF
+
+<div class="source"><pre class="prettyprint linenums"><code>|-- META-INF
 |   |-- MANIFEST.MF
 |   `-- application.properties
 |   `-- maven
@@ -476,17 +564,19 @@ Vincent Siveton" />
 `-- com
     `-- mycompany
         `-- app
-            `-- App.class</pre></div>
-<p>As you can see, the contents of <code>${basedir}/src/main/resources</code> can be found starting at the base of the JAR and our <code>application.properties</code> file is there in the <code>META-INF</code> directory. You will also notice some other files there like <code>META-INF/MANIFEST.MF</code> as well as a <code>pom.xml</code> and <code>pom.properties</code> file. These come standard with generation of a JAR in Maven. You can create your own manifest if you choose, but Maven will generate one by default if you don't. (You can also modify the entries in the default manifest. We will touch on this later.) The <code>pom.xml</code> and <code>pom.properties</code> files are packaged up in the JAR so that each artifact produced by Maven is self-describing and also allows you to utilize the metadata in your own application if the need arises. One simple use might be to retrieve the version of your application. Operating on the POM file would require you to use some Maven utilities
  but the properties can be utilized using the standard Java API and look like the following:</p>
-<div>
-<pre>#Generated by Maven
+            `-- App.class
+</code></pre></div>
+<p>As you can see, the contents of <code>$\{basedir\}/src/main/resources</code> can be found starting at the base of the JAR and our <code>application.properties</code> file is there in the <code>META-INF</code> directory. You will also notice some other files there like <code>META-INF/MANIFEST.MF</code> as well as a <code>pom.xml</code> and <code>pom.properties</code> file. These come standard with generation of a JAR in Maven. You can create your own manifest if you choose, but Maven will generate one by default if you don't. (You can also modify the entries in the default manifest. We will touch on this later.) The <code>pom.xml</code> and <code>pom.properties</code> files are packaged up in the JAR so that each artifact produced by Maven is self-describing and also allows you to utilize the metadata in your own application if the need arises. One simple use might be to retrieve the version of your application. Operating on the POM file would require you to use some Maven utiliti
 es but the properties can be utilized using the standard Java API and look like the following:</p>
+
+<div class="source"><pre class="prettyprint linenums"><code>#Generated by Maven
 #Tue Oct 04 15:43:21 GMT-05:00 2005
 version=1.0-SNAPSHOT
 groupId=com.mycompany.app
-artifactId=my-app</pre></div>
+artifactId=my-app
+</code></pre></div>
 <p>To add resources to the classpath for your unit tests, you follow the same pattern as you do for adding resources to the JAR except the directory you place resources in is ${basedir}/src/test/resources. At this point you would have a project directory structure that would look like the following:</p>
-<div>
-<pre>my-app
+
+<div class="source"><pre class="prettyprint linenums"><code>my-app
 |-- pom.xml
 `-- src
     |-- main
@@ -505,20 +595,24 @@ artifactId=my-app</pre></div>
         |           `-- app
         |               `-- AppTest.java
         `-- resources
-            `-- test.properties</pre></div>
+            `-- test.properties
+</code></pre></div>
 <p>In a unit test you could use a simple snippet of code like the following to access the resource required for testing:</p>
-<div class="source"><pre class="prettyprint linenums">...
+
+<div class="source"><pre class="prettyprint linenums"><code>...
 
 // Retrieve resource
 InputStream is = getClass().getResourceAsStream( &quot;/test.properties&quot; );
 
 // Do something with the resource
 
-...</pre></div></section><section>
-<h2><a id="How_do_I_filter_resource_files">How do I filter resource files?</a></h2>
-<p>Sometimes a resource file will need to contain a value that can only be supplied at build time. To accomplish this in Maven, put a reference to the property that will contain the value into your resource file using the syntax <code>${&lt;property name&gt;}</code>. The property can be one of the values defined in your pom.xml, a value defined in the user's settings.xml, a property defined in an external properties file, or a system property.</p>
+...
+</code></pre></div></section><section>
+<h3>How do I filter resource files?</h3>
+<p>Sometimes a resource file will need to contain a value that can only be supplied at build time. To accomplish this in Maven, put a reference to the property that will contain the value into your resource file using the syntax <code>$\{\&lt;property name\&gt;\}</code>. The property can be one of the values defined in your pom.xml, a value defined in the user's settings.xml, a property defined in an external properties file, or a system property.</p>
 <p>To have Maven filter resources when copying, simply set <code>filtering</code> to true for the resource directory in your <code>pom.xml</code>:</p>
-<div class="source"><pre class="prettyprint linenums">&lt;project xmlns=&quot;http://maven.apache.org/POM/4.0.0&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
+
+<div class="source"><pre class="prettyprint linenums"><code>&lt;project xmlns=&quot;http://maven.apache.org/POM/4.0.0&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
   xsi:schemaLocation=&quot;http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd&quot;&gt;
   &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
 
@@ -547,28 +641,34 @@ InputStream is = getClass().getResourceA
       &lt;/resource&gt;
     &lt;/resources&gt;
   &lt;/build&gt;
-&lt;/project&gt;</pre></div>
+&lt;/project&gt;
+</code></pre></div>
 <p>You'll notice that we had to add the <code>build</code>, <code>resources</code>, and <code>resource</code> elements which weren't there before. In addition, we had to explicitly state that the resources are located in the src/main/resources directory. All of this information was provided as default values previously, but because the default value for <code>filtering</code> is false, we had to add this to our pom.xml in order to override that default value and set <code>filtering</code> to true.</p>
-<p>To reference a property defined in your pom.xml, the property name uses the names of the XML elements that define the value, with &quot;pom&quot; being allowed as an alias for the project (root) element. So <code>${project.name}</code> refers to the name of the project, <code>${project.version}</code> refers to the version of the project, <code>${project.build.finalName}</code> refers to the final name of the file created when the built project is packaged, etc. Note that some elements of the POM have default values, so don't need to be explicitly defined in your <code>pom.xml</code> for the values to be available here. Similarly, values in the user's <code>settings.xml</code> can be referenced using property names beginning with &quot;settings&quot; (for example, <code>${settings.localRepository}</code> refers to the path of the user's local repository).</p>
+<p>To reference a property defined in your pom.xml, the property name uses the names of the XML elements that define the value, with &#x201c;pom&#x201d; being allowed as an alias for the project (root) element. So <code>$\{project.name\}</code> refers to the name of the project, <code>$\{project.version\}</code> refers to the version of the project, <code>$\{project.build.finalName\}</code> refers to the final name of the file created when the built project is packaged, etc. Note that some elements of the POM have default values, so don't need to be explicitly defined in your <code>pom.xml</code> for the values to be available here. Similarly, values in the user's <code>settings.xml</code> can be referenced using property names beginning with &#x201c;settings&#x201d; (for example, <code>$\{settings.localRepository\}</code> refers to the path of the user's local repository).</p>
 <p>To continue our example, let's add a couple of properties to the <code>application.properties</code> file (which we put in the <code>src/main/resources</code> directory) whose values will be supplied when the resource is filtered:</p>
-<div>
-<pre># application.properties
+
+<div class="source"><pre class="prettyprint linenums"><code># application.properties
 application.name=${project.name}
-application.version=${project.version}</pre></div>
+application.version=${project.version}
+</code></pre></div>
 <p>With that in place, you can execute the following command (process-resources is the build lifecycle phase where the resources are copied and filtered):</p>
-<div>
-<pre>mvn process-resources</pre></div>
+
+<div class="source"><pre class="prettyprint linenums"><code>mvn process-resources
+</code></pre></div>
 <p>and the <code>application.properties</code> file under <code>target/classes</code> (and will eventually go into the jar) looks like this:</p>
-<div>
-<pre># application.properties
+
+<div class="source"><pre class="prettyprint linenums"><code># application.properties
 application.name=Maven Quick Start Archetype
-application.version=1.0-SNAPSHOT</pre></div>
+application.version=1.0-SNAPSHOT
+</code></pre></div>
 <p>To reference a property defined in an external file, all you need to do is add a reference to this external file in your pom.xml. First, let's create our external properties file and call it <code>src/main/filters/filter.properties</code>:</p>
-<div>
-<pre># filter.properties
-my.filter.value=hello!</pre></div>
+
+<div class="source"><pre class="prettyprint linenums"><code># filter.properties
+my.filter.value=hello!
+</code></pre></div>
 <p>Next, we'll add a reference to this new file in the <code>pom.xml</code>:</p>
-<div class="source"><pre class="prettyprint linenums">&lt;project xmlns=&quot;http://maven.apache.org/POM/4.0.0&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
+
+<div class="source"><pre class="prettyprint linenums"><code>&lt;project xmlns=&quot;http://maven.apache.org/POM/4.0.0&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
   xsi:schemaLocation=&quot;http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd&quot;&gt;
   &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
 
@@ -600,15 +700,18 @@ my.filter.value=hello!</pre></div>
       &lt;/resource&gt;
     &lt;/resources&gt;
   &lt;/build&gt;
-&lt;/project&gt;</pre></div>
+&lt;/project&gt;
+</code></pre></div>
 <p>Then, if we add a reference to this property in the <code>application.properties</code> file:</p>
-<div>
-<pre># application.properties
+
+<div class="source"><pre class="prettyprint linenums"><code># application.properties
 application.name=${project.name}
 application.version=${project.version}
-message=${my.filter.value}</pre></div>
+message=${my.filter.value}
+</code></pre></div>
 <p>the next execution of the <code>mvn process-resources</code> command will put our new property value into <code>application.properties</code>. As an alternative to defining the my.filter.value property in an external file, you could also have defined it in the <code>properties</code> section of your <code>pom.xml</code> and you'd get the same effect (notice I don't need the references to <code>src/main/filters/filter.properties</code> either):</p>
-<div class="source"><pre class="prettyprint linenums">&lt;project xmlns=&quot;http://maven.apache.org/POM/4.0.0&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
+
+<div class="source"><pre class="prettyprint linenums"><code>&lt;project xmlns=&quot;http://maven.apache.org/POM/4.0.0&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
   xsi:schemaLocation=&quot;http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd&quot;&gt;
   &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
 
@@ -641,19 +744,23 @@ message=${my.filter.value}</pre></div>
   &lt;properties&gt;
     &lt;my.filter.value&gt;hello&lt;/my.filter.value&gt;
   &lt;/properties&gt;
-&lt;/project&gt;</pre></div>
+&lt;/project&gt;
+</code></pre></div>
 <p>Filtering resources can also get values from system properties; either the system properties built into Java (like <code>java.version</code> or <code>user.home</code>) or properties defined on the command line using the standard Java -D parameter. To continue the example, let's change our <code>application.properties</code> file to look like this:</p>
-<div>
-<pre># application.properties
+
+<div class="source"><pre class="prettyprint linenums"><code># application.properties
 java.version=${java.version}
-command.line.prop=${command.line.prop}</pre></div>
+command.line.prop=${command.line.prop}
+</code></pre></div>
 <p>Now, when you execute the following command (note the definition of the command.line.prop property on the command line), the <code>application.properties</code> file will contain the values from the system properties.</p>
-<div>
-<pre>mvn process-resources &quot;-Dcommand.line.prop=hello again&quot;</pre></div></section><section>
-<h2><a id="How_do_I_use_external_dependencies">How do I use external dependencies?</a></h2>
+
+<div class="source"><pre class="prettyprint linenums"><code>mvn process-resources &quot;-Dcommand.line.prop=hello again&quot;
+</code></pre></div></section><section>
+<h3>How do I use external dependencies?</h3>
 <p>You've probably already noticed a <code>dependencies</code> element in the POM we've been using as an example. You have, in fact, been using an external dependency all this time, but here we'll talk about how this works in a bit more detail. For a more thorough introduction, please refer to our <a href="../introduction/introduction-to-dependency-mechanism.html">Introduction to Dependency Mechanism</a>.</p>
 <p>The <code>dependencies</code> section of the pom.xml lists all of the external dependencies that our project needs in order to build (whether it needs that dependency at compile time, test time, run time, or whatever). Right now, our project is depending on JUnit only (I took out all of the resource filtering stuff for clarity):</p>
-<div class="source"><pre class="prettyprint linenums">&lt;project xmlns=&quot;http://maven.apache.org/POM/4.0.0&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
+
+<div class="source"><pre class="prettyprint linenums"><code>&lt;project xmlns=&quot;http://maven.apache.org/POM/4.0.0&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
   xsi:schemaLocation=&quot;http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd&quot;&gt;
   &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
 
@@ -673,11 +780,14 @@ command.line.prop=${command.line.prop}</
       &lt;scope&gt;test&lt;/scope&gt;
     &lt;/dependency&gt;
   &lt;/dependencies&gt;
-&lt;/project&gt;</pre></div>
-<p>For each external dependency, you'll need to define at least 4 things: groupId, artifactId, version, and scope. The groupId, artifactId, and version are the same as those given in the <code>pom.xml</code> for the project that built that dependency. The scope element indicates how your project uses that dependency, and can be values like <code>compile</code>, <code>test</code>, and <code>runtime</code>. For more information on everything you can specify for a dependency, see the <a href="/ref/current/maven-model/maven.html">Project Descriptor Reference</a>.</p>
+&lt;/project&gt;
+</code></pre></div>
+<p>For each external dependency, you'll need to define at least 4 things: groupId, artifactId, version, and scope. The groupId, artifactId, and version are the same as those given in the <code>pom.xml</code> for the project that built that dependency. The scope element indicates how your project uses that dependency, and can be values like <code>compile</code>, <code>test</code>, and <code>runtime</code>. For more information on everything you can specify for a dependency, see the <a href="/ref/current/maven-model/maven.html">Project Descriptor Reference</a>.</p><!-- DJ: Does this link work? I can't find the document. -->
+
 <p>For more information about the dependency mechanism as a whole, see <a href="../introduction/introduction-to-dependency-mechanism.html">Introduction to Dependency Mechanism</a>.</p>
-<p>With this information about a dependency, Maven will be able to reference the dependency when it builds the project. Where does Maven reference the dependency from? Maven looks in your local repository (<code>${user.home}/.m2/repository</code> is the default location) to find all dependencies. In a <a href="#How_do_I_create_a_JAR_and_install_it_in_my_local_repository">previous section</a>, we installed the artifact from our project (my-app-1.0-SNAPSHOT.jar) into the local repository. Once it's installed there, another project can reference that jar as a dependency simply by adding the dependency information to its pom.xml:</p>
-<div class="source"><pre class="prettyprint linenums">&lt;project xmlns=&quot;http://maven.apache.org/POM/4.0.0&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
+<p>With this information about a dependency, Maven will be able to reference the dependency when it builds the project. Where does Maven reference the dependency from? Maven looks in your local repository (<code>$\{user.home\}/.m2/repository</code> is the default location) to find all dependencies. In a <a href="How_do_I_create_a_JAR_and_install_it_in_my_local_repository">previous section</a>, we installed the artifact from our project (my-app-1.0-SNAPSHOT.jar) into the local repository. Once it's installed there, another project can reference that jar as a dependency simply by adding the dependency information to its pom.xml:</p>
+
+<div class="source"><pre class="prettyprint linenums"><code>&lt;project xmlns=&quot;http://maven.apache.org/POM/4.0.0&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
   xsi:schemaLocation=&quot;http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd&quot;&gt;
   &lt;groupId&gt;com.mycompany.app&lt;/groupId&gt;
   &lt;artifactId&gt;my-other-app&lt;/artifactId&gt;
@@ -691,10 +801,12 @@ command.line.prop=${command.line.prop}</
       &lt;scope&gt;compile&lt;/scope&gt;
     &lt;/dependency&gt;
   &lt;/dependencies&gt;
-&lt;/project&gt;</pre></div>
-<p>What about dependencies built somewhere else? How do they get into my local repository? Whenever a project references a dependency that isn't available in the local repository, Maven will download the dependency from a remote repository into the local repository. You probably noticed Maven downloading a lot of things when you built your very first project (these downloads were dependencies for the various plugins used to build the project). By default, the remote repository Maven uses can be found (and browsed) at <a class="externalLink" href="https://repo.maven.apache.org/maven2/">https://repo.maven.apache.org/maven2/</a>. You can also set up your own remote repository (maybe a central repository for your company) to use instead of or in addition to the default remote repository. For more information on repositories you can refer to the <a href="../introduction/introduction-to-repositories.html">Introduction to Repositories</a>.</p>
-<p>Let's add another dependency to our project. Let's say we've added some logging to the code and need to add log4j as a dependency. First, we need to know what the groupId, artifactId, and version are for log4j. The appropriate directory on Maven Central is called <a class="externalLink" href="https://repo.maven.apache.org/maven2/log4j/log4j/">/maven2/log4j/log4j</a>. In that directory is a file called maven-metadata.xml. Here's what the maven-metadata.xml for log4j looks like:</p>
-<div class="source"><pre class="prettyprint linenums">&lt;metadata&gt;
+&lt;/project&gt;
+</code></pre></div>
+<p>What about dependencies built somewhere else? How do they get into my local repository? Whenever a project references a dependency that isn't available in the local repository, Maven will download the dependency from a remote repository into the local repository. You probably noticed Maven downloading a lot of things when you built your very first project (these downloads were dependencies for the various plugins used to build the project). By default, the remote repository Maven uses can be found (and browsed) at <a href="https://repo.maven.apache.org/maven2/" class="externalLink">https://repo.maven.apache.org/maven2/</a>. You can also set up your own remote repository (maybe a central repository for your company) to use instead of or in addition to the default remote repository. For more information on repositories you can refer to the <a href="../introduction/introduction-to-repositories.html">Introduction to Repositories</a>.</p>
+<p>Let's add another dependency to our project. Let's say we've added some logging to the code and need to add log4j as a dependency. First, we need to know what the groupId, artifactId, and version are for log4j. The appropriate directory on Maven Central is called <a href="https://repo.maven.apache.org/maven2/log4j/log4j/" class="externalLink">/maven2/log4j/log4j</a>. In that directory is a file called maven-metadata.xml. Here's what the maven-metadata.xml for log4j looks like:</p>
+
+<div class="source"><pre class="prettyprint linenums"><code>&lt;metadata&gt;
   &lt;groupId&gt;log4j&lt;/groupId&gt;
   &lt;artifactId&gt;log4j&lt;/artifactId&gt;
   &lt;version&gt;1.1.3&lt;/version&gt;
@@ -711,10 +823,12 @@ command.line.prop=${command.line.prop}</
       &lt;version&gt;1.2.12&lt;/version&gt;
     &lt;/versions&gt;
   &lt;/versioning&gt;
-&lt;/metadata&gt;</pre></div>
-<p>From this file, we can see that the groupId we want is &quot;log4j&quot; and the artifactId is &quot;log4j&quot;. We see lots of different version values to choose from; for now, we'll just use the latest version, 1.2.12 (some maven-metadata.xml files may also specify which version is the current release version: see <a href="/ref/current/maven-repository-metadata/repository-metadata.html">repository metadata reference</a>). Alongside the maven-metadata.xml file, we can see a directory corresponding to each version of the log4j library. Inside each of these, we'll find the actual jar file (e.g. log4j-1.2.12.jar) as well as a pom file (this is the pom.xml for the dependency, indicating any further dependencies it might have and other information) and another maven-metadata.xml file. There's also an md5 file corresponding to each of these, which contains an MD5 hash for these files. You can use this to authenticate the library or to figure out which version of a particular library 
 you may be using already.</p>
+&lt;/metadata&gt;
+</code></pre></div>
+<p>From this file, we can see that the groupId we want is &#x201c;log4j&#x201d; and the artifactId is &#x201c;log4j&#x201d;. We see lots of different version values to choose from; for now, we'll just use the latest version, 1.2.12 (some maven-metadata.xml files may also specify which version is the current release version: see <a href="/ref/current/maven-repository-metadata/repository-metadata.html">repository metadata reference</a>). Alongside the maven-metadata.xml file, we can see a directory corresponding to each version of the log4j library. Inside each of these, we'll find the actual jar file (e.g. log4j-1.2.12.jar) as well as a pom file (this is the pom.xml for the dependency, indicating any further dependencies it might have and other information) and another maven-metadata.xml file. There's also an md5 file corresponding to each of these, which contains an MD5 hash for these files. You can use this to authenticate the library or to figure out which version of a particular 
 library you may be using already.</p>
 <p>Now that we know the information we need, we can add the dependency to our pom.xml:</p>
-<div class="source"><pre class="prettyprint linenums">&lt;project xmlns=&quot;http://maven.apache.org/POM/4.0.0&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
+
+<div class="source"><pre class="prettyprint linenums"><code>&lt;project xmlns=&quot;http://maven.apache.org/POM/4.0.0&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
   xsi:schemaLocation=&quot;http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd&quot;&gt;
   &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
 
@@ -740,12 +854,15 @@ command.line.prop=${command.line.prop}</
       &lt;scope&gt;compile&lt;/scope&gt;
     &lt;/dependency&gt;
   &lt;/dependencies&gt;
-&lt;/project&gt;</pre></div>
-<p>Now, when we compile the project (<code>mvn compile</code>), we'll see Maven download the log4j dependency for us.</p></section><section>
-<h2><a id="How_do_I_deploy_my_jar_in_my_remote_repository">How do I deploy my jar in my remote repository?</a></h2>
+&lt;/project&gt;
+</code></pre></div>
+<p>Now, when we compile the project (<code>mvn compile</code>), we'll see Maven download the log4j dependency for us.</p><!-- DJ: Current -->
+</section><section>
+<h3>How do I deploy my jar in my remote repository?</h3>
 <p>For deploying jars to an external repository, you have to configure the repository url in the pom.xml and the authentication information for connecting to the repository in the settings.xml.</p>
 <p>Here is an example using scp and username/password authentication:</p>
-<div class="source"><pre class="prettyprint linenums">&lt;project xmlns=&quot;http://maven.apache.org/POM/4.0.0&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
+
+<div class="source"><pre class="prettyprint linenums"><code>&lt;project xmlns=&quot;http://maven.apache.org/POM/4.0.0&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
   xsi:schemaLocation=&quot;http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd&quot;&gt;
   &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
 
@@ -794,8 +911,10 @@ command.line.prop=${command.line.prop}</
       &lt;url&gt;scp://repository.mycompany.com/repository/maven2&lt;/url&gt;
     &lt;/repository&gt;
   &lt;/distributionManagement&gt;
-&lt;/project&gt;</pre></div>
-<div class="source"><pre class="prettyprint linenums">&lt;settings xmlns=&quot;http://maven.apache.org/SETTINGS/1.0.0&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
+&lt;/project&gt;
+</code></pre></div>
+
+<div class="source"><pre class="prettyprint linenums"><code>&lt;settings xmlns=&quot;http://maven.apache.org/SETTINGS/1.0.0&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
   xsi:schemaLocation=&quot;http://maven.apache.org/SETTINGS/1.0.0 https://maven.apache.org/xsd/settings-1.0.0.xsd&quot;&gt;
   ...
   &lt;servers&gt;
@@ -808,28 +927,32 @@ command.line.prop=${command.line.prop}</
     &lt;/server&gt;
   &lt;/servers&gt;
   ...
-&lt;/settings&gt;</pre></div>
-<p>Note that if you are connecting to an openssh ssh server which has the parameter &quot;PasswordAuthentication&quot; set to &quot;no&quot; in the sshd_confing, you will have to type your password each time for username/password authentication (although you can log in using another ssh client by typing in the username and password). You might want to switch to public key authentication in this case.</p>
-<p>Care should be taken if using passwords in <code>settings.xml</code>. For more information, see <a href="../mini/guide-encryption.html"> Password Encryption</a>.</p></section><section>
-<h2><a id="How_do_I_create_documentation">How do I create documentation?</a></h2>
+&lt;/settings&gt;
+</code></pre></div>
+<p>Note that if you are connecting to an openssh ssh server which has the parameter &#x201c;PasswordAuthentication&#x201d; set to &#x201c;no&#x201d; in the sshd_confing, you will have to type your password each time for username/password authentication (although you can log in using another ssh client by typing in the username and password). You might want to switch to public key authentication in this case.</p>
+<p>Care should be taken if using passwords in <code>settings.xml</code>. For more information, see <a href="../mini/guide-encryption.html">Password Encryption</a>.</p></section><section>
+<h3>How do I create documentation?</h3>
 <p>To get you jump started with Maven's documentation system you can use the archetype mechanism to generate a site for your existing project using the following command:</p>
-<div>
-<pre>mvn archetype:generate \
+
+<div class="source"><pre class="prettyprint linenums"><code>mvn archetype:generate \
   -DarchetypeGroupId=org.apache.maven.archetypes \
   -DarchetypeArtifactId=maven-archetype-site \
   -DgroupId=com.mycompany.app \
-  -DartifactId=my-app-site</pre></div>
+  -DartifactId=my-app-site
+</code></pre></div>
 <p>Now head on over to the <a href="../mini/guide-site.html">Guide to creating a site</a> to learn how to create the documentation for your project.</p></section><section>
-<h2><a id="How_do_I_build_other_types_of_projects">How do I build other types of projects?</a></h2>
+<h3>How do I build other types of projects?</h3>
 <p>Note that the lifecycle applies to any project type. For example, back in the base directory we can create a simple web application:</p>
-<div>
-<pre>mvn archetype:generate \
+
+<div class="source"><pre class="prettyprint linenums"><code>mvn archetype:generate \
     -DarchetypeGroupId=org.apache.maven.archetypes \
     -DarchetypeArtifactId=maven-archetype-webapp \
     -DgroupId=com.mycompany.app \
-    -DartifactId=my-webapp</pre></div>
+    -DartifactId=my-webapp
+</code></pre></div>
 <p>Note that these must all be on a single line. This will create a directory called <code>my-webapp</code> containing the following project descriptor:</p>
-<div class="source"><pre class="prettyprint linenums">&lt;project xmlns=&quot;http://maven.apache.org/POM/4.0.0&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
+
+<div class="source"><pre class="prettyprint linenums"><code>&lt;project xmlns=&quot;http://maven.apache.org/POM/4.0.0&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
   xsi:schemaLocation=&quot;http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd&quot;&gt;
   &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
 
@@ -850,16 +973,18 @@ command.line.prop=${command.line.prop}</
   &lt;build&gt;
     &lt;finalName&gt;my-webapp&lt;/finalName&gt;
   &lt;/build&gt;
-&lt;/project&gt;</pre></div>
-<p>Note the <code>&lt;packaging&gt;</code> element - this tells Maven to build as a WAR. Change into the webapp project's directory and try:</p>
-<div>
-<pre>mvn package</pre></div>
+&lt;/project&gt;
+</code></pre></div>
+<p>Note the <code>\&lt;packaging\&gt;</code> element - this tells Maven to build as a WAR. Change into the webapp project's directory and try:</p>
+
+<div class="source"><pre class="prettyprint linenums"><code>mvn package
+</code></pre></div>
 <p>You'll see <code>target/my-webapp.war</code> is built, and that all the normal steps were executed.</p></section><section>
-<h2><a id="How_do_I_build_more_than_one_project_at_once">How do I build more than one project at once?</a></h2>
+<h3>How do I build more than one project at once?</h3>
 <p>The concept of dealing with multiple modules is built in to Maven. In this section, we will show how to build the WAR above, and include the previous JAR as well in one step.</p>
 <p>Firstly, we need to add a parent <code>pom.xml</code> file in the directory above the other two, so it should look like this:</p>
-<div>
-<pre>+- pom.xml
+
+<div class="source"><pre class="prettyprint linenums"><code>+- pom.xml
 +- my-app
 | +- pom.xml
 | +- src
@@ -869,9 +994,11 @@ command.line.prop=${command.line.prop}</
 | +- pom.xml
 | +- src
 |   +- main
-|     +- webapp</pre></div>
+|     +- webapp
+</code></pre></div>
 <p>The POM file you'll create should contain the following:</p>
-<div class="source"><pre class="prettyprint linenums">&lt;project xmlns=&quot;http://maven.apache.org/POM/4.0.0&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
+
+<div class="source"><pre class="prettyprint linenums"><code>&lt;project xmlns=&quot;http://maven.apache.org/POM/4.0.0&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
   xsi:schemaLocation=&quot;http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd&quot;&gt;
   &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
 
@@ -884,9 +1011,11 @@ command.line.prop=${command.line.prop}</
     &lt;module&gt;my-app&lt;/module&gt;
     &lt;module&gt;my-webapp&lt;/module&gt;
   &lt;/modules&gt;
-&lt;/project&gt;</pre></div>
+&lt;/project&gt;
+</code></pre></div>
 <p>We'll need a dependency on the JAR from the webapp, so add this to <code>my-webapp/pom.xml</code>:</p>
-<div class="source"><pre class="prettyprint linenums">  ...
+
+<div class="source"><pre class="prettyprint linenums"><code>  ...
   &lt;dependencies&gt;
     &lt;dependency&gt;
       &lt;groupId&gt;com.mycompany.app&lt;/groupId&gt;
@@ -894,22 +1023,26 @@ command.line.prop=${command.line.prop}</
       &lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;
     &lt;/dependency&gt;
     ...
-  &lt;/dependencies&gt;</pre></div>
-<p>Finally, add the following <code>&lt;parent&gt;</code> element to both of the other <code>pom.xml</code> files in the subdirectories:</p>
-<div class="source"><pre class="prettyprint linenums">&lt;project xmlns=&quot;http://maven.apache.org/POM/4.0.0&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
+  &lt;/dependencies&gt;
+</code></pre></div>
+<p>Finally, add the following <code>\&lt;parent\&gt;</code> element to both of the other <code>pom.xml</code> files in the subdirectories:</p>
+
+<div class="source"><pre class="prettyprint linenums"><code>&lt;project xmlns=&quot;http://maven.apache.org/POM/4.0.0&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
   xsi:schemaLocation=&quot;http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd&quot;&gt;
   &lt;parent&gt;
     &lt;groupId&gt;com.mycompany.app&lt;/groupId&gt;
     &lt;artifactId&gt;app&lt;/artifactId&gt;
     &lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;
   &lt;/parent&gt;
-  ...</pre></div>
-<p>Now, try it... from the top level directory, run:</p>
-<div>
-<pre>mvn verify</pre></div>
+  ...
+</code></pre></div>
+<p>Now, try it&#x2026; from the top level directory, run:</p>
+
+<div class="source"><pre class="prettyprint linenums"><code>mvn verify
+</code></pre></div>
 <p>The WAR has now been created in <code>my-webapp/target/my-webapp.war</code>, and the JAR is included:</p>
-<div>
-<pre>$ jar tvf my-webapp/target/my-webapp-1.0-SNAPSHOT.war
+
+<div class="source"><pre class="prettyprint linenums"><code>$ jar tvf my-webapp/target/my-webapp-1.0-SNAPSHOT.war
    0 Fri Jun 24 10:59:56 EST 2005 META-INF/
  222 Fri Jun 24 10:59:54 EST 2005 META-INF/MANIFEST.MF
    0 Fri Jun 24 10:59:56 EST 2005 META-INF/maven/
@@ -921,11 +1054,12 @@ command.line.prop=${command.line.prop}</
  123 Fri Jun 24 10:59:56 EST 2005 META-INF/maven/com.mycompany.app/my-webapp/pom.properties
   52 Fri Jun 24 10:59:56 EST 2005 index.jsp
    0 Fri Jun 24 10:59:56 EST 2005 WEB-INF/lib/
-2713 Fri Jun 24 10:59:56 EST 2005 WEB-INF/lib/my-app-1.0-SNAPSHOT.jar</pre></div>
+2713 Fri Jun 24 10:59:56 EST 2005 WEB-INF/lib/my-app-1.0-SNAPSHOT.jar
+</code></pre></div>
 <p>How does this work? Firstly, the parent POM created (called <code>app</code>), has a packaging of <code>pom</code> and a list of modules defined. This tells Maven to run all operations over the set of projects instead of just the current one (to override this behaviour, you can use the <code>--non-recursive</code> command line option).</p>
 <p>Next, we tell the WAR that it requires the <code>my-app</code> JAR. This does a few things: it makes it available on the classpath to any code in the WAR (none in this case), it makes sure the JAR is always built before the WAR, and it indicates to the WAR plugin to include the JAR in its library directory.</p>
-<p>You may have noticed that <code>junit-4.11.jar</code> was a dependency, but didn't end up in the WAR. The reason for this is the <code>&lt;scope&gt;test&lt;/scope&gt;</code> element - it is only required for testing, and so is not included in the web application as the compile time dependency <code>my-app</code> is.</p>
-<p>The final step was to include a parent definition. This ensures that the POM can always be located even if the project is distributed separately from its parent by looking it up in the repository.</p></section></section>
+<p>You may have noticed that <code>junit-4.11.jar</code> was a dependency, but didn't end up in the WAR. The reason for this is the <code>\&lt;scope\&gt;test\&lt;/scope\&gt;</code> element - it is only required for testing, and so is not included in the web application as the compile time dependency <code>my-app</code> is.</p>
+<p>The final step was to include a parent definition. This ensures that the POM can always be located even if the project is distributed separately from its parent by looking it up in the repository.</p></section></section></section>
         </main>
       </div>
     </div>