Modified: maven/website/content/guides/introduction/introduction-to-profiles.html ============================================================================== --- maven/website/content/guides/introduction/introduction-to-profiles.html (original) +++ maven/website/content/guides/introduction/introduction-to-profiles.html Sat Feb 18 20:40:58 2023 @@ -2,7 +2,7 @@ <!-- - | Generated by Apache Maven Doxia Site Renderer 2.0.0-M4 from content/markdown/guides/introduction/introduction-to-profiles.md at 2023-02-18 + | Generated by Apache Maven Doxia Site Renderer 2.0.0-M4 from content/apt/guides/introduction/introduction-to-profiles.apt at 2023-02-18 | Rendered using Apache Maven Fluido Skin 1.11.1 --> <html xmlns="http://www.w3.org/1999/xhtml" lang=""> @@ -48,7 +48,7 @@ <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 ">Introduction to build profiles <a href="https://github.com/apache/maven-site/tree/master/content/markdown/guides/introduction/introduction-to-profiles.md"><img src="../../images/accessories-text-editor.png" title="Edit" /></a></li> + <li class="active ">Introduction to build profiles <a href="https://github.com/apache/maven-site/tree/master/content/apt/guides/introduction/introduction-to-profiles.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-18</li> <li class="pull-right"><span class="divider">|</span> <a href="../../scm.html" title="Get Sources">Get Sources</a></li> @@ -145,165 +145,96 @@ </div> </header> <main id="bodyColumn" class="span10" > -<!-- -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>Introduction to Build Profiles</h2> +<section> +<h1>Introduction to Build Profiles</h1> <ul> - -<li> -<p><a href="#what-are-the-different-types-of-profile-where-is-each-defined">What are the different types of profile? Where is each defined?</a></p></li> -<li> -<p><a href="#how-can-a-profile-be-triggered-how-does-this-vary-according-to-the-type-of-profile-being-used">How can a profile be triggered? How does this vary according to the type of profile being used?</a></p></li> -<li> -<p><a href="#details-on-profile-activation">Details on profile activation</a></p></li> -<li> -<p><a href="#explicit-profile-activation">Explicit profile activation</a></p></li> -<li> -<p><a href="#implici-profile-activation">Implicit profile activation</a></p> +<li><a href="#What_are_the_different_types_of_profile.3F_Where_is_each_defined.3F">What are the different types of profile? Where is each defined?</a></li> +<li><a href="#How_can_a_profile_be_triggered.3F_How_does_this_vary_according_to_the_type_of_profile_being_used.3F">How can a profile be triggered? How does this vary according to the type of profile being used?</a> <ul> - -<li> -<p><a href="#jdk">JDK</a></p></li> -<li> -<p><a href="#os">OS</a></p></li> -<li> -<p><a href="#property">Property</a></p></li> -<li> -<p><a href="#files">Files</a></p></li> -</ul></li> -<li> -<p><a href="#deactivating-a-profile">Deactivating a profile</a></p></li> -<li> -<p><a href="#which-areas-of-a-pom-can-be-customized-by-each-type-of-profile-why">Which areas of a POM can be customized by each type of profile? Why?</a></p></li> -<li> -<p><a href="#profiles-in-external-files">Profiles in external files</a></p></li> -<li> -<p><a href="#profiles-in-poms">Profiles in POMs</a></p></li> -<li> -<p><a href="#pom-elements-outside-profiles">POM elements outside <code><profiles></code></a></p></li> -<li> -<p><a href="#profile-order">Profile Order</a></p></li> -<li> -<p><a href="#profile-pitfalls">Profile Pitfalls</a></p></li> -<li> -<p><a href="#external-properties">External Properties</a></p></li> -<li> -<p><a href="#incomplete-specification-of-a-natural-profile-set">Incomplete Specification of a Natural Profile Set</a></p></li> -<li> -<p><a href="#how-can-i-tell-which-profiles-are-in-effect-during-a-build">How can I tell which profiles are in effect during a build?</a></p></li> -<li> -<p><a href="#naming-conventions">Naming Conventions</a></p></li> -</ul> -<p>Apache Maven goes to great lengths to ensure that builds are portable. Among other things, this means allowing build configuration inside the POM, avoiding <strong>all</strong> filesystem references (in inheritance, dependencies, and other places), and leaning much more heavily on the local repository to store the metadata needed to make this possible.</p> -<p>However, sometimes portability is not entirely possible. Under certain conditions, plugins may need to be configured with local filesystem paths. Under other circumstances, a slightly different dependency set will be required, and the project's artifact name may need to be adjusted slightly. And at still other times, you may even need to include a whole plugin in the build lifecycle depending on the detected build environment.</p> -<p>To address these circumstances, Maven supports build profiles. Profiles are specified using a subset of the elements available in the POM itself (plus one extra section), and are triggered in any of a variety of ways. They modify the POM at build time, and are meant to be used in complementary sets to give equivalent-but-different parameters for a set of target environments (providing, for example, the path of the appserver root in the development, testing, and production environments). As such, profiles can easily lead to differing build results from different members of your team. However, used properly, profiles can be used while still preserving project portability. This will also minimize the use of <code>-f</code> option of maven which allows user to create another POM with different parameters or configuration to build which makes it more maintainable since it is running with one POM only.</p><section> -<h3>What are the different types of profile? Where is each defined?</h3> +<li><a href="#Details_on_profile_activation">Details on profile activation</a> <ul> - -<li> -<p>Per Project</p> +<li><a href="#Explicit_profile_activation">Explicit profile activation</a></li> +<li><a href="#Implicit_profile_activation">Implicit profile activation</a> <ul> - -<li>Defined in the POM itself <code>(pom.xml)</code>.</li> -</ul></li> -<li> -<p>Per User</p> +<li><a href="#JDK">JDK</a></li> +<li><a href="#OS">OS</a></li> +<li><a href="#Property">Property</a></li> +<li><a href="#Files">Files</a></li></ul></li></ul></li> +<li><a href="#Deactivating_a_profile">Deactivating a profile</a></li></ul></li> +<li><a href="#Which_areas_of_a_POM_can_be_customized_by_each_type_of_profile.3F_Why.3F">Which areas of a POM can be customized by each type of profile? Why?</a> <ul> - -<li>Defined in the <a href="/ref/current/maven-settings/settings.html">Maven-settings</a> <code>(%USER_HOME%/.m2/settings.xml)</code>.</li> -</ul></li> -<li> -<p>Global</p> +<li><a href="#Profiles_in_external_files">Profiles in external files</a></li> +<li><a href="#Profiles_in_POMs">Profiles in POMs</a></li> +<li><a href="#POM_elements_outside_.3Cprofiles.3E">POM elements outside <profiles></a></li></ul></li> +<li><a href="#Profile_Order">Profile Order</a></li> +<li><a href="#Profile_Pitfalls">Profile Pitfalls</a> <ul> - -<li>Defined in the <a href="/ref/current/maven-settings/settings.html">global Maven-settings</a> <code>(${maven.home}/conf/settings.xml)</code>.</li> -</ul></li> -<li> -<p>Profile descriptor</p> +<li><a href="#External_Properties">External Properties</a></li> +<li><a href="#Incomplete_Specification_of_a_Natural_Profile_Set">Incomplete Specification of a Natural Profile Set</a></li></ul></li> +<li><a href="#How_can_I_tell_which_profiles_are_in_effect_during_a_build.3F">How can I tell which profiles are in effect during a build?</a></li> +<li><a href="#Naming_Conventions">Naming Conventions</a></li></ul> +<p>Apache Maven goes to great lengths to ensure that builds are portable. Among other things, this means allowing build configuration inside the POM, avoiding <b>all</b> filesystem references (in inheritance, dependencies, and other places), and leaning much more heavily on the local repository to store the metadata needed to make this possible.</p> +<p>However, sometimes portability is not entirely possible. Under certain conditions, plugins may need to be configured with local filesystem paths. Under other circumstances, a slightly different dependency set will be required, and the project's artifact name may need to be adjusted slightly. And at still other times, you may even need to include a whole plugin in the build lifecycle depending on the detected build environment.</p> +<p>To address these circumstances, Maven supports build profiles. Profiles are specified using a subset of the elements available in the POM itself (plus one extra section), and are triggered in any of a variety of ways. They modify the POM at build time, and are meant to be used in complementary sets to give equivalent-but-different parameters for a set of target environments (providing, for example, the path of the appserver root in the development, testing, and production environments). As such, profiles can easily lead to differing build results from different members of your team. However, used properly, profiles can be used while still preserving project portability. This will also minimize the use of <code>-f</code> option of maven which allows user to create another POM with different parameters or configuration to build which makes it more maintainable since it is running with one POM only.</p><section> +<h2>What are the different types of profile? Where is each defined?</h2> <ul> - -<li>a descriptor located in <a href="/ref/2.2.1/maven-profile/profiles.html">project basedir <code>(profiles.xml)</code></a> (no longer supported in Maven 3.0 and above; see <a href="https://cwiki.apache.org/confluence/display/MAVEN/Maven+3.x+Compatibility+Notes#Maven3.xCompatibilityNotes-profiles.xml" class="externalLink">Maven 3 compatibility notes</a>)</li> -</ul></li> -</ul></section><section> -<h3>How can a profile be triggered? How does this vary according to the type of profile being used?</h3> +<li>Per Project +<p>- Defined in the POM itself <code>(pom.xml)</code>.</p></li> +<li>Per User +<p>- Defined in the <a href="/ref/current/maven-settings/settings.html"> Maven-settings</a> <code>(%USER_HOME%/.m2/settings.xml)</code>.</p></li> +<li>Global +<p>- Defined in the <a href="/ref/current/maven-settings/settings.html"> global Maven-settings</a> <code>(${maven.home}/conf/settings.xml)</code>.</p></li> +<li>Profile descriptor +<p>- a descriptor located in <a href="/ref/2.2.1/maven-profile/profiles.html">project basedir <code>(profiles.xml)</code></a> (no longer supported in Maven 3.0 and above; see <a class="externalLink" href="https://cwiki.apache.org/confluence/display/MAVEN/Maven+3.x+Compatibility+Notes#Maven3.xCompatibilityNotes-profiles.xml"> Maven 3 compatibility notes</a>)</p></li></ul></section><section> +<h2>How can a profile be triggered? How does this vary according to the type of profile being used?</h2> <p>A profile can be activated in several ways:</p> <ul> - -<li> -<p>Explicitly</p></li> -<li> -<p>Implicitly</p></li> -<li> -<p>Based on OS</p></li> -<li> -<p>Based on system properties</p></li> -<li> -<p>Based on presence of files</p></li> -</ul> +<li>Explicitly</li> +<li>Implicitly</li> +<li>Based on OS</li> +<li>Based on system properties</li> +<li>Based on presence of files</li></ul> <p>Refer to the sections below for details.</p><section> -<h4>Details on profile activation</h4><section> -<h5>Explicit profile activation</h5> +<h3>Details on profile activation</h3><section> +<h4>Explicit profile activation</h4> <p>Profiles can be explicitly specified using the <code>-P</code> command line flag.</p> <p>This flag is followed by a comma-delimited list of profile IDs to use. The profile(s) specified in the option are activated in addition to any profiles which are activated by their activation configuration or the <code><activeProfiles></code> section in <code>settings.xml</code>. From Maven 4 onward, Maven will refuse to activate or deactivate a profile that cannot be resolved. To prevent this, prefix the profile identifier with an <code>?</code>, marking it as optional:</p> - -<div class="source"><pre class="prettyprint linenums"><code>mvn groupId:artifactId:goal -P profile-1,profile-2,?profile-3 -</code></pre></div> +<div> +<pre>mvn groupId:artifactId:goal -P profile-1,profile-2,?profile-3</pre></div> <p>Profiles can be activated in the Maven settings, via the <code><activeProfiles></code> section. This section takes a list of <code><activeProfile></code> elements, each containing a profile-id inside.</p> - -<div class="source"><pre class="prettyprint linenums"><code class="language-xml"><settings> +<div class="source"><pre class="prettyprint linenums"><settings> ... <activeProfiles> <activeProfile>profile-1</activeProfile> </activeProfiles> ... -</settings> -</code></pre></div> +</settings></pre></div> <p>Profiles listed in the <code><activeProfiles></code> tag would be activated by default every time a project use it.</p></section><section> -<h5>Implicit profile activation</h5> -<p>Profiles can be automatically triggered based on the detected state of the build environment. These triggers are specified via an <code><activation></code> section in the profile itself. Currently, this detection is limited to JDK version matching, operating system matching or the presence/the value of a system property. Here are some examples.</p>JDK -<p>The following configuration will trigger the profile when the JDK's version <em>starts with</em> “1.4” (eg. “1.4.0_08”, “1.4.2_07”, “1.4”), in particular it <em>won't be active</em> for <strong>newer</strong> versions like “1.8” or “11”:</p> - -<div class="source"><pre class="prettyprint linenums"><code class="language-xml"><profiles> +<h4>Implicit profile activation</h4> +<p>Profiles can be automatically triggered based on the detected state of the build environment. These triggers are specified via an <code><activation></code> section in the profile itself. Currently, this detection is limited to JDK version matching, operating system matching or the presence/the value of a system property. Here are some examples.</p><section> +<h5>JDK</h5> +<p>The following configuration will trigger the profile when the JDK's version <i>starts with</i> "1.4" (eg. "1.4.0_08", "1.4.2_07", "1.4"), in particular it <i>won't be active</i> for <b>newer</b> versions like "1.8" or "11":</p> +<div class="source"><pre class="prettyprint linenums"><profiles> <profile> <activation> <jdk>1.4</jdk> </activation> ... </profile> -</profiles> -</code></pre></div> -<p>Ranges can also be used as of Maven 2.1 (refer to the <a href="/enforcer/enforcer-rules/versionRanges.html">Enforcer Version Range Syntax</a> for more information). Range values must start with either <code>\[</code> or <code>(</code> otherwise the value is interpreted as prefix. The following honours versions 1.3, 1.4 and 1.5.</p> - -<div class="source"><pre class="prettyprint linenums"><code class="language-xml"><profiles> +</profiles></pre></div> +<p>Ranges can also be used as of Maven 2.1 (refer to the <a href="/enforcer/enforcer-rules/versionRanges.html"> Enforcer Version Range Syntax</a> for more information). Range values must start with either <code>[</code> or <code>(</code> otherwise the value is interpreted as prefix. The following honours versions 1.3, 1.4 and 1.5.</p> +<div class="source"><pre class="prettyprint linenums"><profiles> <profile> <activation> <jdk>[1.3,1.6)</jdk> </activation> ... </profile> -</profiles> -</code></pre></div> -<p><em>Note:</em> an upper bound such as <code>,1.5\]</code> is likely not to include most releases of 1.5, since they will have an additional “patch” release such as <code>_05</code> that is not taken into consideration in the above range.</p>OS +</profiles></pre></div> +<p><i>Note:</i> an upper bound such as <code>,1.5]</code> is likely not to include most releases of 1.5, since they will have an additional "patch" release such as <code>_05</code> that is not taken into consideration in the above range.</p></section><section> +<h5>OS</h5> <p>This next one will activate based on the detected operating system. See the <a href="/enforcer/enforcer-rules/requireOS.html">Maven Enforcer Plugin</a> for more details about OS values.</p> - -<div class="source"><pre class="prettyprint linenums"><code class="language-xml"><profiles> +<div class="source"><pre class="prettyprint linenums"><profiles> <profile> <activation> <os> @@ -315,11 +246,10 @@ under the License. </activation> ... </profile> -</profiles> -</code></pre></div>Property -<p>The profile below will be activated when the system property “debug” is specified with any value:</p> - -<div class="source"><pre class="prettyprint linenums"><code class="language-xml"><profiles> +</profiles></pre></div></section><section> +<h5>Property</h5> +<p>The profile below will be activated when the system property "debug" is specified with any value:</p> +<div class="source"><pre class="prettyprint linenums"><profiles> <profile> <activation> <property> @@ -328,11 +258,9 @@ under the License. </activation> ... </profile> -</profiles> -</code></pre></div> -<p>The following profile will be activated when the system property “debug” is not defined at all:</p> - -<div class="source"><pre class="prettyprint linenums"><code class="language-xml"><profiles> +</profiles></pre></div> +<p>The following profile will be activated when the system property "debug" is not defined at all:</p> +<div class="source"><pre class="prettyprint linenums"><profiles> <profile> <activation> <property> @@ -341,11 +269,9 @@ under the License. </activation> ... </profile> -</profiles> -</code></pre></div> -<p>The following profile will be activated when the system property “debug” is not defined, or is defined with a value which is not “true”.</p> - -<div class="source"><pre class="prettyprint linenums"><code class="language-xml"><profiles> +</profiles></pre></div> +<p>The following profile will be activated when the system property "debug" is not defined, or is defined with a value which is not "true".</p> +<div class="source"><pre class="prettyprint linenums"><profiles> <profile> <activation> <property> @@ -355,16 +281,13 @@ under the License. </activation> ... </profile> -</profiles> -</code></pre></div> +</profiles></pre></div> <p>To activate this you would type one of those on the command line:</p> - -<div class="source"><pre class="prettyprint linenums"><code>mvn groupId:artifactId:goal -mvn groupId:artifactId:goal -Ddebug=false -</code></pre></div> -<p>The next example will trigger the profile when the system property “environment” is specified with the value “test”:</p> - -<div class="source"><pre class="prettyprint linenums"><code class="language-xml"><profiles> +<div> +<pre>mvn groupId:artifactId:goal +mvn groupId:artifactId:goal -Ddebug=false</pre></div> +<p>The next example will trigger the profile when the system property "environment" is specified with the value "test":</p> +<div class="source"><pre class="prettyprint linenums"><profiles> <profile> <activation> <property> @@ -374,17 +297,14 @@ mvn groupId:artifactId:goal -Ddebug=fals </activation> ... </profile> -</profiles> -</code></pre></div> +</profiles></pre></div> <p>To activate this you would type this on the command line:</p> - -<div class="source"><pre class="prettyprint linenums"><code>mvn groupId:artifactId:goal -Denvironment=test -</code></pre></div> +<div> +<pre>mvn groupId:artifactId:goal -Denvironment=test</pre></div> <p>As of Maven 3.0, profiles in the POM can also be activated based on properties from active profiles from the <code>settings.xml</code>.</p> -<p><strong>Note</strong>: Environment variables like <code>FOO</code> are available as properties of the form <code>env.FOO</code>. Further note that environment variable names are normalized to all upper-case on Windows.</p> +<p><b>Note</b>: Environment variables like <code>FOO</code> are available as properties of the form <code>env.FOO</code>. Further note that environment variable names are normalized to all upper-case on Windows.</p> <p>Since Maven 3.9.0 one can also evaluate the POM's packaging value by referencing property <code>packaging</code>. This is only useful where the profile activation is defined in a common parent POM which is reused among multiple Maven projects. The next example will trigger the profile when a project with packaging <code>war</code> is built:</p> - -<div class="source"><pre class="prettyprint linenums"><code class="language-xml"><profiles> +<div class="source"><pre class="prettyprint linenums"><profiles> <profile> <activation> <property> @@ -394,11 +314,10 @@ mvn groupId:artifactId:goal -Ddebug=fals </activation> ... </profile> -</profiles> -</code></pre></div>Files +</profiles></pre></div></section><section> +<h5>Files</h5> <p>This example will trigger the profile when the generated file <code>target/generated-sources/axistools/wsdl2java/org/apache/maven</code> is missing.</p> - -<div class="source"><pre class="prettyprint linenums"><code class="language-xml"><profiles> +<div class="source"><pre class="prettyprint linenums"><profiles> <profile> <activation> <file> @@ -407,12 +326,10 @@ mvn groupId:artifactId:goal -Ddebug=fals </activation> ... </profile> -</profiles> -</code></pre></div> +</profiles></pre></div> <p>As of Maven 2.0.9, the tags <code><exists></code> and <code><missing></code> could be interpolated. Supported variables are system properties like <code>${user.home}</code> and environment variables like <code>${env.HOME}</code>. Please note that properties and values defined in the POM itself are not available for interpolation here, e.g. the above example activator cannot use <code>${project.build.directory}</code> but needs to hard-code the path <code>target</code>.</p> <p>Profiles can also be active by default using a configuration like the following:</p> - -<div class="source"><pre class="prettyprint linenums"><code class="language-xml"><profiles> +<div class="source"><pre class="prettyprint linenums"><profiles> <profile> <id>profile-1</id> <activation> @@ -420,77 +337,53 @@ mvn groupId:artifactId:goal -Ddebug=fals </activation> ... </profile> -</profiles> -</code></pre></div> -<p>This profile will automatically be active for all builds unless another profile in the same POM is activated using one of the previously described methods. All profiles that are active by default are automatically deactivated when a profile in the POM is activated on the command line or through its activation config.</p></section></section><section> -<h4>Deactivating a profile</h4> -<p>Starting with Maven 2.0.10, one or more profiles can be deactivated using the command line by prefixing their identifier with either the character ‘!’ or ‘-’ as shown below:</p> - -<div class="source"><pre class="prettyprint linenums"><code>mvn groupId:artifactId:goal -P !profile-1,!profile-2,!?profile-3 -</code></pre></div> +</profiles></pre></div> +<p>This profile will automatically be active for all builds unless another profile in the same POM is activated using one of the previously described methods. All profiles that are active by default are automatically deactivated when a profile in the POM is activated on the command line or through its activation config.</p></section></section></section><section> +<h3>Deactivating a profile</h3> +<p>Starting with Maven 2.0.10, one or more profiles can be deactivated using the command line by prefixing their identifier with either the character '!' or '-' as shown below:</p> +<div> +<pre>mvn groupId:artifactId:goal -P !profile-1,!profile-2,!?profile-3</pre></div> <p>or</p> - -<div class="source"><pre class="prettyprint linenums"><code>mvn groupId:artifactId:goal -P -profile-1,-profile-2,-?profile-3 -</code></pre></div> +<div> +<pre>mvn groupId:artifactId:goal -P -profile-1,-profile-2,-?profile-3</pre></div> <p>This can be used to deactivate profiles marked as activeByDefault or profiles that would otherwise be activated through their activation config.</p></section></section><section> -<h3>Which areas of a POM can be customized by each type of profile? Why?</h3> -<p>Now that we've talked about where to specify profiles, and how to activate them, it will be useful to talk about <em>what</em> you can specify in a profile. As with the other aspects of profile configuration, this answer is not straightforward.</p> +<h2>Which areas of a POM can be customized by each type of profile? Why?</h2> +<p>Now that we've talked about where to specify profiles, and how to activate them, it will be useful to talk about <i>what</i> you can specify in a profile. As with the other aspects of profile configuration, this answer is not straightforward.</p> <p>Depending on where you choose to configure your profile, you will have access to varying POM configuration options.</p><section> -<h4>Profiles in external files</h4> +<h3>Profiles in external files</h3> <p>Profiles specified in external files (i.e in <code>settings.xml</code> or <code>profiles.xml</code>) are not portable in the strictest sense. Anything that seems to stand a high chance of changing the result of the build is restricted to the inline profiles in the POM. Things like repository lists could simply be a proprietary repository of approved artifacts, and won't change the outcome of the build. Therefore, you will only be able to modify the <code><repositories></code> and <code><pluginRepositories></code> sections, plus an extra <code><properties></code> section.</p> <p>The <code><properties></code> section allows you to specify free-form key-value pairs which will be included in the interpolation process for the POM. This allows you to specify a plugin configuration in the form of <code>${profile.provided.path}</code>.</p></section><section> -<h4>Profiles in POMs</h4> -<p>On the other hand, if your profiles can be reasonably specified <em>inside</em> the POM, you have many more options. The trade-off, of course, is that you can only modify <em>that</em> project and its sub-modules. Since these profiles are specified inline, and therefore have a better chance of preserving portability, it's reasonable to say you can add more information to them without the risk of that information being unavailable to other users.</p> +<h3>Profiles in POMs</h3> +<p>On the other hand, if your profiles can be reasonably specified <i>inside</i> the POM, you have many more options. The trade-off, of course, is that you can only modify <i>that</i> project and its sub-modules. Since these profiles are specified inline, and therefore have a better chance of preserving portability, it's reasonable to say you can add more information to them without the risk of that information being unavailable to other users.</p> <p>Profiles specified in the POM can modify <a href="/ref/current/maven-model/maven.html">the following POM elements</a>:</p> <ul> - -<li> -<p><code><repositories></code></p></li> -<li> -<p><code><pluginRepositories></code></p></li> -<li> -<p><code><dependencies></code></p></li> -<li> -<p><code><plugins></code></p></li> -<li> -<p><code><properties></code> (not actually available in the main POM, but used behind the scenes)</p></li> -<li> -<p><code><modules></code></p></li> -<li> -<p><code><reports></code></p></li> -<li> -<p><code><reporting></code></p></li> -<li> -<p><code><dependencyManagement></code></p></li> -<li> -<p><code><distributionManagement></code></p></li> -<li> -<p>a subset of the <code><build></code> element, which consists of:</p></li> -<li> -<p><code><defaultGoal></code></p></li> -<li> -<p><code><resources></code></p></li> -<li> -<p><code><testResources></code></p></li> -<li> -<p><code><directory></code></p></li> -<li> -<p><code><finalName></code></p></li> -<li> -<p><code><filters></code></p></li> -<li> -<p><code><pluginManagement></code></p></li> -<li> -<p><code><plugins></code></p></li> -</ul></section><section> -<h4>POM elements outside <code><profiles></code></h4> +<li><code><repositories></code></li> +<li><code><pluginRepositories></code></li> +<li><code><dependencies></code></li> +<li><code><plugins></code></li> +<li><code><properties></code> (not actually available in the main POM, but used behind the scenes)</li> +<li><code><modules></code></li> +<li><code><reports></code></li> +<li><code><reporting></code></li> +<li><code><dependencyManagement></code></li> +<li><code><distributionManagement></code></li> +<li>a subset of the <code><build></code> element, which consists of: +<ul> +<li><code><defaultGoal></code></li> +<li><code><resources></code></li> +<li><code><testResources></code></li> +<li><code><directory></code></li> +<li><code><finalName></code></li> +<li><code><filters></code></li> +<li><code><pluginManagement></code></li> +<li><code><plugins></code></li></ul></li></ul></section><section> +<h3>POM elements outside <profiles></h3> <p>We don't allow modification of some POM elements outside of POM-profiles because these runtime modifications will not be distributed when the POM is deployed to the repository system, making that person's build of that project completely unique from others. While you can do this to some extent with the options given for external profiles, the danger is limited. Another reason is that this POM info is sometimes being reused from the parent POM.</p> <p>External files such as <code>settings.xml</code> and <code>profiles.xml</code> also does not support elements outside the POM-profiles. Let us take this scenario for elaboration. When the effective POM get deployed to a remote repository, any person can pickup its info out of the repository and use it to build a Maven project directly. Now, imagine that if we can set profiles in dependencies, which is very important to a build, or in any other elements outside POM-profiles in <code>settings.xml</code> then most probably we cannot expect someone else to use that POM from the repository and be able to build it. And we have to also think about how to share the <code>settings.xml</code> with others. Note that too many files to configure is very confusing and very hard to maintain. Bottom line is that since this is build data, it should be in the POM. One of the goals in Maven 2 is to consolidate all the information needed to run a build into a single file, or file hierarchy which is the POM.</p></section></section><section> -<h3>Profile Order</h3> -<p>All profile elements in a POM from active profiles overwrite the global elements with the same name of the POM or extend those in case of collections. In case multiple profiles are active in the same POM or external file, the ones which are defined <strong>later</strong> take precedence over the ones defined <strong>earlier</strong> (independent of their profile id and activation order).</p> +<h2>Profile Order</h2> +<p>All profile elements in a POM from active profiles overwrite the global elements with the same name of the POM or extend those in case of collections. In case multiple profiles are active in the same POM or external file, the ones which are defined <b>later</b> take precedence over the ones defined <b>earlier</b> (independent of their profile id and activation order).</p> <p>Example:</p> - -<div class="source"><pre class="prettyprint linenums"><code class="language-xml"><project> +<div class="source"><pre class="prettyprint linenums"><project> ... <repositories> <repository> @@ -527,16 +420,14 @@ mvn groupId:artifactId:goal -Ddebug=fals ... </profiles> ... -</project> -</code></pre></div> +</project></pre></div> <p>This leads to the repository list: <code>profile-2-repo, profile-1-repo, global-repo</code>.</p></section><section> -<h3>Profile Pitfalls</h3> +<h2>Profile Pitfalls</h2> <p>We've already mentioned the fact that adding profiles to your build has the potential to break portability for your project. We've even gone so far as to highlight circumstances where profiles are likely to break project portability. However, it's worth reiterating those points as part of a more coherent discussion about some pitfalls to avoid when using profiles.</p> <p>There are two main problem areas to keep in mind when using profiles. First are external properties, usually used in plugin configurations. These pose the risk of breaking portability in your project. The other, more subtle area is the incomplete specification of a natural set of profiles.</p><section> -<h4>External Properties</h4> +<h3>External Properties</h3> <p>External property definition concerns any property value defined outside the <code>pom.xml</code> but not defined in a corresponding profile inside it. The most obvious usage of properties in the POM is in plugin configuration. While it is certainly possible to break project portability without properties, these critters can have subtle effects that cause builds to fail. For example, specifying appserver paths in a profile that is specified in the <code>settings.xml</code> may cause your integration test plugin to fail when another user on the team attempts to build without a similar <code>settings.xml</code>. Consider the following <code>pom.xml</code> snippet for a web application project:</p> - -<div class="source"><pre class="prettyprint linenums"><code class="language-xml"><project> +<div class="source"><pre class="prettyprint linenums"><project> ... <build> <plugins> @@ -552,11 +443,9 @@ mvn groupId:artifactId:goal -Ddebug=fals </plugins> </build> ... -</project> -</code></pre></div> +</project></pre></div> <p>Now, in your local <code>${user.home}/.m2/settings.xml</code>, you have:</p> - -<div class="source"><pre class="prettyprint linenums"><code class="language-xml"><settings> +<div class="source"><pre class="prettyprint linenums"><settings> ... <profiles> <profile> @@ -571,16 +460,14 @@ mvn groupId:artifactId:goal -Ddebug=fals <activeProfile>appserverConfig</activeProfile> </activeProfiles> ... -</settings> -</code></pre></div> -<p>When you build the <strong>integration-test</strong> lifecycle phase, your integration tests pass, since the path you've provided allows the test plugin to install and test this web application.</p> -<p><em>However</em>, when your colleague attempts to build to <strong>integration-test</strong>, his build fails spectacularly, complaining that it cannot resolve the plugin configuration parameter <code><appserverHome></code>, or worse, that the value of that parameter - literally <code>${appserver.home}</code> - is invalid (if it warns you at all).</p> +</settings></pre></div> +<p>When you build the <b>integration-test</b> lifecycle phase, your integration tests pass, since the path you've provided allows the test plugin to install and test this web application.</p> +<p><i>However</i>, when your colleague attempts to build to <b>integration-test</b>, his build fails spectacularly, complaining that it cannot resolve the plugin configuration parameter <code><appserverHome></code>, or worse, that the value of that parameter - literally <code>${appserver.home}</code> - is invalid (if it warns you at all).</p> <p>Congratulations, your project is now non-portable. Inlining this profile in your <code>pom.xml</code> can help alleviate this, with the obvious drawback that each project hierarchy (allowing for the effects of inheritance) now have to specify this information. Since Maven provides good support for project inheritance, it's possible to stick this sort of configuration in the <code><pluginManagement></code> section of a team-level POM or similar, and simply inherit the paths.</p> <p>Another, less attractive answer might be standardization of development environments. However, this will tend to compromise the productivity gain that Maven is capable of providing.</p></section><section> -<h4>Incomplete Specification of a Natural Profile Set</h4> +<h3>Incomplete Specification of a Natural Profile Set</h3> <p>In addition to the above portability-breaker, it's easy to fail to cover all cases with your profiles. When you do this, you're usually leaving one of your target environments high and dry. Let's take the example <code>pom.xml</code> snippet from above one more time:</p> - -<div class="source"><pre class="prettyprint linenums"><code class="language-xml"><project> +<div class="source"><pre class="prettyprint linenums"><project> ... <build> <plugins> @@ -596,11 +483,9 @@ mvn groupId:artifactId:goal -Ddebug=fals </plugins> </build> ... -</project> -</code></pre></div> +</project></pre></div> <p>Now, consider the following profile, which would be specified inline in the <code>pom.xml</code>:</p> - -<div class="source"><pre class="prettyprint linenums"><code class="language-xml"><project> +<div class="source"><pre class="prettyprint linenums"><project> ... <profiles> <profile> @@ -630,73 +515,60 @@ mvn groupId:artifactId:goal -Ddebug=fals </profile> </profiles> .. -</project> -</code></pre></div> -<p>This profile looks quite similar to the one from the last example, with a few important exceptions: it's plainly geared toward a development environment, a new profile named <code>appserverConfig-dev-2</code> is added and it has an activation section that will trigger its inclusion when the system properties contain “env=dev” for a profile named <code>appserverConfig-dev</code> and “env=dev-2” for a profile named <code>appserverConfig-dev-2</code>. So, executing:</p> - -<div class="source"><pre class="prettyprint linenums"><code>mvn -Denv=dev-2 integration-test -</code></pre></div> +</project></pre></div> +<p>This profile looks quite similar to the one from the last example, with a few important exceptions: it's plainly geared toward a development environment, a new profile named <code>appserverConfig-dev-2</code> is added and it has an activation section that will trigger its inclusion when the system properties contain "env=dev" for a profile named <code>appserverConfig-dev</code> and "env=dev-2" for a profile named <code>appserverConfig-dev-2</code>. So, executing:</p> +<div> +<pre>mvn -Denv=dev-2 integration-test</pre></div> <p>will result in a successful build, applying the properties given by profile named <code>appserverConfig-dev-2</code>. And when we execute</p> - -<div class="source"><pre class="prettyprint linenums"><code>mvn -Denv=dev integration-test -</code></pre></div> +<div> +<pre>mvn -Denv=dev integration-test</pre></div> <p>it will result in a successful build applying the properties given by the profile named <code>appserverConfig-dev</code>. However, executing:</p> - -<div class="source"><pre class="prettyprint linenums"><code>mvn -Denv=production integration-test -</code></pre></div> -<p>will not do a successful build. Why? Because, the resulting non-interpolated literal value of <code>${appserver.home}</code> will not be a valid path for deploying and testing your web application. We haven't considered the case for the production environment when writing our profiles. The “production” environment (env=production), along with “test” and possibly even “local” constitute a natural set of target environments for which we may want to build the integration-test lifecycle phase. The incomplete specification of this natural set means we have effectively limited our valid target environments to the development environment. Your teammates - and probably your manager - will not see the humor in this. When you construct profiles to handle cases such as these, be sure to address the entire set of target permutations.</p> -<p>As a quick aside, it's possible for user-specific profiles to act in a similar way. This means that profiles for handling different environments which are keyed to the user can act up when the team adds a new developer. While I suppose this <em>could</em> act as useful training for the newbie, it just wouldn't be nice to throw them to the wolves in this way. Again, be sure to think of the <em>whole</em> set of profiles.</p></section></section><section> -<h3>How can I tell which profiles are in effect during a build?</h3> +<div> +<pre>mvn -Denv=production integration-test</pre></div> +<p>will not do a successful build. Why? Because, the resulting non-interpolated literal value of <code>${appserver.home}</code> will not be a valid path for deploying and testing your web application. We haven't considered the case for the production environment when writing our profiles. The "production" environment (env=production), along with "test" and possibly even "local" constitute a natural set of target environments for which we may want to build the integration-test lifecycle phase. The incomplete specification of this natural set means we have effectively limited our valid target environments to the development environment. Your teammates - and probably your manager - will not see the humor in this. When you construct profiles to handle cases such as these, be sure to address the entire set of target permutations.</p> +<p>As a quick aside, it's possible for user-specific profiles to act in a similar way. This means that profiles for handling different environments which are keyed to the user can act up when the team adds a new developer. While I suppose this <i>could</i> act as useful training for the newbie, it just wouldn't be nice to throw them to the wolves in this way. Again, be sure to think of the <i>whole</i> set of profiles.</p></section></section><section> +<h2>How can I tell which profiles are in effect during a build?</h2> <p>Determining active profiles will help the user to know what particular profiles has been executed during a build. We can use the <a href="/plugins/maven-help-plugin/">Maven Help Plugin</a> to tell what profiles are in effect during a build.</p> - -<div class="source"><pre class="prettyprint linenums"><code> mvn help:active-profiles -</code></pre></div> -<p>Let us have some small samples that will help us to understand more on the <em>active-profiles</em> goal of that plugin.</p> +<div> +<pre> mvn help:active-profiles</pre></div> +<p>Let us have some small samples that will help us to understand more on the <i>active-profiles</i> goal of that plugin.</p> <p>From the last example of profiles in the <code>pom.xml</code>, you'll notice that there are two profiles named <code>appserverConfig-dev</code> and <code>appserverConfig-dev-2</code> which has been given different values for properties. If we go ahead and execute:</p> +<div> +<pre> mvn help:active-profiles -Denv=dev</pre></div> +<p>The result will be a bulleted list of the id of the profile with an activation property of "env=dev" together with the source where it was declared. See sample below.</p> +<div> +<pre>The following profiles are active: -<div class="source"><pre class="prettyprint linenums"><code> mvn help:active-profiles -Denv=dev -</code></pre></div> -<p>The result will be a bulleted list of the id of the profile with an activation property of “env=dev” together with the source where it was declared. See sample below.</p> - -<div class="source"><pre class="prettyprint linenums"><code>The following profiles are active: - - - appserverConfig-dev (source: pom) -</code></pre></div> + - appserverConfig-dev (source: pom)</pre></div> <p>Now if we have a profile declared in <code>settings.xml</code> (refer to the sample of profile in <code>settings.xml</code>) and that have been set to be an active profile and execute:</p> - -<div class="source"><pre class="prettyprint linenums"><code> mvn help:active-profiles -</code></pre></div> +<div> +<pre> mvn help:active-profiles</pre></div> <p>The result should be something like this</p> +<div> +<pre>The following profiles are active: -<div class="source"><pre class="prettyprint linenums"><code>The following profiles are active: - - - appserverConfig (source: settings.xml) -</code></pre></div> + - appserverConfig (source: settings.xml)</pre></div> <p>Even though we don't have an activation property, a profile has been listed as active. Why? Like we mentioned before, a profile that has been set as an active profile in the <code>settings.xml</code> is automatically activated.</p> <p>Now if we have something like a profile in the <code>settings.xml</code> that has been set as an active profile and also triggered a profile in the POM. Which profile do you think will have an effect on the build?</p> - -<div class="source"><pre class="prettyprint linenums"><code> mvn help:active-profiles -P appserverConfig-dev -</code></pre></div> +<div> +<pre> mvn help:active-profiles -P appserverConfig-dev</pre></div> <p>This will list the activated profiles:</p> - -<div class="source"><pre class="prettyprint linenums"><code>The following profiles are active: +<div> +<pre>The following profiles are active: - appserverConfig-dev (source: pom) - - appserverConfig (source: settings.xml) -</code></pre></div> + - appserverConfig (source: settings.xml)</pre></div> <p>Even though it listed the two active profiles, we are not sure which one of them has been applied. To see the effect on the build execute:</p> - -<div class="source"><pre class="prettyprint linenums"><code> mvn help:effective-pom -P appserverConfig-dev -</code></pre></div> +<div> +<pre> mvn help:effective-pom -P appserverConfig-dev</pre></div> <p>This will print the effective POM for this build configuration out to the console. Take note that profiles in the <code>settings.xml</code> takes higher priority than profiles in the POM. So the profile that has been applied here is <code>appserverConfig</code> not <code>appserverConfig-dev</code>.</p> <p>If you want to redirect the output from the plugin to a file called <code>effective-pom.xml</code>, use the command-line option <code>-Doutput=effective-pom.xml</code>.</p></section><section> -<h3>Naming Conventions</h3> -<p>By now you've noticed that profiles are a natural way of addressing the problem of different build configuration requirements for different target environments. Above, we discussed the concept of a “natural set” of profiles to address this situation, and the importance of considering the whole set of profiles that will be required.</p> -<p>However, the question of how to organize and manage the evolution of that set is non-trivial as well. Just as a good developer strives to write self-documenting code, it's important that your profile id's give a hint to their intended use. One good way to do this is to use the common system property trigger as part of the name for the profile. This might result in names like <strong>env-dev</strong>, <strong>env-test</strong>, and <strong>env-prod</strong> for profiles that are triggered by the system property <strong>env</strong>. Such a system leaves a highly intuitive hint on how to activate a build targeted at a particular environment. Thus, to activate a build for the test environment, you need to activate <strong>env-test</strong> by issuing:</p> - -<div class="source"><pre class="prettyprint linenums"><code>mvn -Denv=test <phase> -</code></pre></div> -<p>The right command-line option can be had by simply substituting “=” for “-” in the profile id.</p></section></section></section> +<h2>Naming Conventions</h2> +<p>By now you've noticed that profiles are a natural way of addressing the problem of different build configuration requirements for different target environments. Above, we discussed the concept of a "natural set" of profiles to address this situation, and the importance of considering the whole set of profiles that will be required.</p> +<p>However, the question of how to organize and manage the evolution of that set is non-trivial as well. Just as a good developer strives to write self-documenting code, it's important that your profile id's give a hint to their intended use. One good way to do this is to use the common system property trigger as part of the name for the profile. This might result in names like <b>env-dev</b>, <b>env-test</b>, and <b>env-prod</b> for profiles that are triggered by the system property <b>env</b>. Such a system leaves a highly intuitive hint on how to activate a build targeted at a particular environment. Thus, to activate a build for the test environment, you need to activate <b>env-test</b> by issuing:</p> +<div> +<pre>mvn -Denv=test <phase></pre></div> +<p>The right command-line option can be had by simply substituting "=" for "-" in the profile id.</p></section></section> </main> </div> </div>
Modified: maven/website/content/guides/introduction/introduction-to-repositories.html ============================================================================== --- maven/website/content/guides/introduction/introduction-to-repositories.html (original) +++ maven/website/content/guides/introduction/introduction-to-repositories.html Sat Feb 18 20:40:58 2023 @@ -2,7 +2,7 @@ <!-- - | Generated by Apache Maven Doxia Site Renderer 2.0.0-M4 from content/markdown/guides/introduction/introduction-to-repositories.md at 2023-02-18 + | Generated by Apache Maven Doxia Site Renderer 2.0.0-M4 from content/apt/guides/introduction/introduction-to-repositories.apt at 2023-02-18 | Rendered using Apache Maven Fluido Skin 1.11.1 --> <html xmlns="http://www.w3.org/1999/xhtml" lang=""> @@ -10,7 +10,8 @@ <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, Brian Fox" /> + <meta name="author" content="Jason van Zyl +Brian Fox" /> <meta name="date" content="2008-05-13" /> <title>Maven – Introduction to Repositories</title> <link rel="stylesheet" href="../../css/apache-maven-fluido-1.11.1.min.css" /> @@ -48,7 +49,7 @@ <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 ">Introduction to Repositories <a href="https://github.com/apache/maven-site/tree/master/content/markdown/guides/introduction/introduction-to-repositories.md"><img src="../../images/accessories-text-editor.png" title="Edit" /></a></li> + <li class="active ">Introduction to Repositories <a href="https://github.com/apache/maven-site/tree/master/content/apt/guides/introduction/introduction-to-repositories.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-18</li> <li class="pull-right"><span class="divider">|</span> <a href="../../scm.html" title="Get Sources">Get Sources</a></li> @@ -152,64 +153,45 @@ </div> </header> <main id="bodyColumn" class="span10" > -<!-- -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>Introduction to Repositories</h2><section> -<h3>Artifact Repositories</h3> +<section> +<h1>Introduction to Repositories</h1><section> +<h2>Artifact Repositories</h2> <p>A repository in Maven holds build artifacts and dependencies of varying types.</p> -<p>There are exactly two types of repositories: <strong>local</strong> and <strong>remote</strong>:</p> -<p>1 the <strong>local</strong> repository is a directory on the computer where Maven runs. It caches remote downloads and contains temporary build artifacts that you have not yet released.</p> -<p>1 <strong>remote</strong> repositories refer to any other type of repository, accessed by a variety of protocols such as <code>file://</code> and <code>https://</code>. These repositories might be a truly remote repository set up by a third party to provide their artifacts for downloading (for example, <a href="https://repo.maven.apache.org/maven2/" class="externalLink">repo.maven.apache.org</a>). Other “remote” repositories may be internal repositories set up on a file or HTTP server within your company, used to share private artifacts between development teams and for releases.</p> +<p>There are exactly two types of repositories: <b>local</b> and <b>remote</b>:</p> +<ol style="list-style-type: decimal"> +<li>the <b>local</b> repository is a directory on the computer where Maven runs. It caches remote downloads and contains temporary build artifacts that you have not yet released.</li> +<li><b>remote</b> repositories refer to any other type of repository, accessed by a variety of protocols such as <code>file://</code> and <code>https://</code>. These repositories might be a truly remote repository set up by a third party to provide their artifacts for downloading (for example, <a class="externalLink" href="https://repo.maven.apache.org/maven2/">repo.maven.apache.org</a>). Other "remote" repositories may be internal repositories set up on a file or HTTP server within your company, used to share private artifacts between development teams and for releases.</li></ol> <p>Local and remote repositories are structured the same way so that scripts can run on either side, or they can be synced for offline use. The layout of the repositories is completely transparent to the Maven user, however.</p></section><section> -<h3>Using Repositories</h3> +<h2>Using Repositories</h2> <p>In general, you should not need to do anything with the local repository on a regular basis, except clean it out if you are short on disk space (or erase it completely if you are willing to download everything again).</p> <p>For the remote repositories, they are used for both downloading and uploading (if you have the permission to do so).</p><section> -<h4>Downloading from a Remote Repository</h4> -<p>Downloading in Maven is triggered by a project declaring a dependency that is not present in the local repository (or for a <code>SNAPSHOT</code>, when the remote repository contains one that is newer). By default, Maven will download from the <a href="https://repo.maven.apache.org/maven2/" class="externalLink">central</a> repository.</p> +<h3>Downloading from a Remote Repository</h3> +<p>Downloading in Maven is triggered by a project declaring a dependency that is not present in the local repository (or for a <code>SNAPSHOT</code>, when the remote repository contains one that is newer). By default, Maven will download from the <a class="externalLink" href="https://repo.maven.apache.org/maven2/">central</a> repository.</p> <p>To override this, you need to specify a <code>mirror</code> as shown in <a href="../mini/guide-mirror-settings.html">Using Mirrors for Repositories</a>.</p> <p>You can set this in your <code>settings.xml</code> file to globally use a certain mirror. However, it is common for a project to <a href="../mini/guide-multiple-repositories.html">customise the repository in its <code>pom.xml</code></a> and that your setting will take precedence. If dependencies are not being found, check that you have not overridden the remote repository.</p> <p>For more information on dependencies, see <a href="./introduction-to-dependency-mechanism.html">Dependency Mechanism</a>.</p></section><section> -<h4>Using Mirrors for the Central Repository</h4> +<h3>Using Mirrors for the Central Repository</h3> <p>There are <a href="/repository/">several official Central repositories</a> geographically distributed. You can make changes to your <code>settings.xml</code> file to use one or more mirrors. Instructions for this can be found in the guide <a href="../mini/guide-mirror-settings.html">Using Mirrors for Repositories</a>.</p></section></section><section> -<h3>Building Offline</h3> +<h2>Building Offline</h2> <p>If you are temporarily disconnected from the internet and you need to build your projects offline, you can use the offline switch on the CLI:</p> - -<div class="source"><pre class="prettyprint linenums"><code> mvn -o package -</code></pre></div> +<div> +<pre> mvn -o package</pre></div> <p>Many plugins honor the offline setting and do not perform any operations that connect to the internet. Some examples are resolving Javadoc links and link checking the site.</p></section><section> -<h3>Uploading to a Remote Repository</h3> +<h2>Uploading to a Remote Repository</h2> <p>While this is possible for any type of remote repository, you must have the permission to do so. To have someone upload to the Central Maven repository, see <a href="../../repository/index.html">Repository Center</a>.</p></section><section> -<h3>Internal Repositories</h3> +<h2>Internal Repositories</h2> <p>When using Maven, particularly in a corporate environment, connecting to the internet to download dependencies is not acceptable for security, speed or bandwidth reasons. For that reason, it is desirable to set up an internal repository to house a copy of artifacts, and to publish private artifacts to.</p> <p>Such an internal repository can be downloaded using HTTP or the file system (with a <code>file://</code> URL), and uploaded to using SCP, FTP, or a file copy.</p> -<p>As far as Maven is concerned, there is nothing special about this repository: it is another <strong>remote repository</strong> that contains artifacts to download to a user's local cache, and is a publish destination for artifact releases.</p> +<p>As far as Maven is concerned, there is nothing special about this repository: it is another <b>remote repository</b> that contains artifacts to download to a user's local cache, and is a publish destination for artifact releases.</p> <p>Additionally, you may want to share the repository server with your generated project sites. For more information on creating and deploying sites, see <a href="../mini/guide-site.html">Creating a Site</a>.</p></section><section> -<h3>Setting up the Internal Repository</h3> -<p>To set up an internal repository just requires that you have a place to put it, and then copy required artifacts there using the same layout as in a remote repository such as <a href="https://repo.maven.apache.org/maven2/" class="externalLink">repo.maven.apache.org</a>.</p> -<p>It is <em>not</em> recommended that you scrape or <code>rsync://</code> a full copy of central as there is a large amount of data there and doing so will get you banned. You can use a program such as those described on the <a href="../../repository-management.html">Repository Management</a> page to run your internal repository's server, download from the internet as required, and then hold the artifacts in your internal repository for faster downloading later.</p> +<h2>Setting up the Internal Repository</h2> +<p>To set up an internal repository just requires that you have a place to put it, and then copy required artifacts there using the same layout as in a remote repository such as <a class="externalLink" href="https://repo.maven.apache.org/maven2/">repo.maven.apache.org</a>.</p> +<p>It is <i>not</i> recommended that you scrape or <code>rsync://</code> a full copy of central as there is a large amount of data there and doing so will get you banned. You can use a program such as those described on the <a href="../../repository-management.html">Repository Management</a> page to run your internal repository's server, download from the internet as required, and then hold the artifacts in your internal repository for faster downloading later.</p> <p>The other options available are to manually download and vet releases, then copy them to the internal repository, or to have Maven download them for a user, and manually upload the vetted artifacts to the internal repository which is used for releases. This step is the only one available for artifacts where the license forbids their distribution automatically, such as several J2EE JARs provided by Sun. Refer to the <a href="../mini/guide-coping-with-sun-jars.html">Guide to coping with SUN JARs</a> document for more information.</p> <p>It should be noted that Maven intends to include enhanced support for such features in the future, including click through licenses on downloading, and verification of signatures.</p></section><section> -<h3>Using the Internal Repository</h3> +<h2>Using the Internal Repository</h2> <p>Using the internal repository is quite simple. Simply make a change to add a <code>repositories</code> element:</p> - -<div class="source"><pre class="prettyprint linenums"><code class="language-xml"> +<div class="source"><pre class="prettyprint linenums"> <project> ... <repositories> @@ -220,14 +202,11 @@ under the License. </repositories> ... </project> - -</code></pre></div> +</pre></div> <p>If your internal repository requires authentication, the <code>id</code> element can be used in your <a href="../../settings.html#Servers">settings</a> file to specify login information.</p></section><section> -<h3>Deploying to the Internal Repository</h3> +<h2>Deploying to the Internal Repository</h2> <p>One of the most important reasons to have one or more internal repositories is to be able to publish your own private releases.</p> -<p>To publish to the repository, you will need to have access via one of SCP, SFTP, FTP, WebDAV, or the filesystem. Connectivity is accomplished with the various <a href="/wagon/wagon-providers/index.html">wagons</a>. Some wagons may need to be added as <a href="/ref/current/maven-model/maven.html#class_extension">extension</a> to your build.</p><!-- For example, to set up an SCP transfer. --> -<!-- show the scp example. --> -</section></section></section> +<p>To publish to the repository, you will need to have access via one of SCP, SFTP, FTP, WebDAV, or the filesystem. Connectivity is accomplished with the various <a href="/wagon/wagon-providers/index.html">wagons</a>. Some wagons may need to be added as <a href="/ref/current/maven-model/maven.html#class_extension">extension</a> to your build.</p></section></section> </main> </div> </div>