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 sv...@apache.org on 2023/02/06 16:37:56 UTC

svn commit: r1907471 - in /maven/website/content: guides/introduction/introduction-to-profiles.html maven-site-1.0-site.jar pom.html

Author: svn-site-role
Date: Mon Feb  6 16:37:55 2023
New Revision: 1907471

Log:
Site checkin for project Apache Maven Site

Modified:
    maven/website/content/guides/introduction/introduction-to-profiles.html
    maven/website/content/maven-site-1.0-site.jar
    maven/website/content/pom.html

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 Mon Feb  6 16:37:55 2023
@@ -151,7 +151,15 @@
 <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><a href="#Details_on_profile_activation">Details on profile activation</a></li>
+<li><a href="#Details_on_profile_activation">Details on profile activation</a>
+<ul>
+<li><a href="#Explicit_profile_activation">Explicit profile activation</a></li>
+<li><a href="#Implicit_profile_activation">Implicit profile activation</a>
+<ul>
+<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>
@@ -181,12 +189,14 @@
 <h2><a name="How_can_a_profile_be_triggered.3F_How_does_this_vary_according_to_the_type_of_profile_being_used.3F"></a>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>From the command line</li>
-<li>Through Maven settings</li>
-<li>Based on environment variables</li>
-<li>OS settings</li>
-<li>Present or missing files</li></ul><section>
-<h3><a name="Details_on_profile_activation"></a>Details on profile activation</h3>
+<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>
+<h3><a name="Details_on_profile_activation"></a>Details on profile activation</h3><section>
+<h4><a name="Explicit_profile_activation"></a>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>&lt;activeProfiles&gt;</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>
@@ -199,8 +209,10 @@
   &lt;/activeProfiles&gt;
   ...
 &lt;/settings&gt;</pre></div>
-<p>Profiles listed in the <code>&lt;activeProfiles&gt;</code> tag would be activated by default every time a project use it.</p>
-<p>Profiles can be automatically triggered based on the detected state of the build environment. These triggers are specified via an <code>&lt;activation&gt;</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>
+<p>Profiles listed in the <code>&lt;activeProfiles&gt;</code> tag would be activated by default every time a project use it.</p></section><section>
+<h4><a name="Implicit_profile_activation"></a>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>&lt;activation&gt;</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><a name="JDK"></a>JDK</h5>
 <p>The following configuration will trigger the profile when the JDK's version <i>starts with</i> &quot;1.4&quot; (eg. &quot;1.4.0_08&quot;, &quot;1.4.2_07&quot;, &quot;1.4&quot;), in particular it <i>won't be active</i> for <b>newer</b> versions like &quot;1.8&quot; or &quot;11&quot;:</p>
 <div class="source"><pre class="prettyprint linenums">&lt;profiles&gt;
   &lt;profile&gt;
@@ -219,8 +231,9 @@
     ...
   &lt;/profile&gt;
 &lt;/profiles&gt;</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 &quot;patch&quot; release such as <code>_05</code> that is not taken into consideration in the above range.</p>
-<p>This next one will activate based on OS settings. See the <a href="/enforcer/enforcer-rules/requireOS.html">Maven Enforcer Plugin</a> for more details about OS values.</p>
+<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 &quot;patch&quot; release such as <code>_05</code> that is not taken into consideration in the above range.</p></section><section>
+<h5><a name="OS"></a>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">&lt;profiles&gt;
   &lt;profile&gt;
     &lt;activation&gt;
@@ -233,7 +246,8 @@
     &lt;/activation&gt;
     ...
   &lt;/profile&gt;
-&lt;/profiles&gt;</pre></div>
+&lt;/profiles&gt;</pre></div></section><section>
+<h5><a name="Property"></a>Property</h5>
 <p>The profile below will be activated when the system property &quot;debug&quot; is specified with any value:</p>
 <div class="source"><pre class="prettyprint linenums">&lt;profiles&gt;
   &lt;profile&gt;
@@ -289,6 +303,19 @@ mvn groupId:artifactId:goal -Ddebug=fals
 <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><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">&lt;profiles&gt;
+  &lt;profile&gt;
+    &lt;activation&gt;
+      &lt;property&gt;
+        &lt;name&gt;packaging&lt;/name&gt;
+        &lt;value&gt;war&lt;/value&gt;
+      &lt;/property&gt;
+    &lt;/activation&gt;
+    ...
+  &lt;/profile&gt;
+&lt;/profiles&gt;</pre></div></section><section>
+<h5><a name="Files"></a>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">&lt;profiles&gt;
   &lt;profile&gt;
@@ -311,7 +338,7 @@ mvn groupId:artifactId:goal -Ddebug=fals
     ...
   &lt;/profile&gt;
 &lt;/profiles&gt;</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>
+<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><a name="Deactivating_a_profile"></a>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>

Modified: maven/website/content/maven-site-1.0-site.jar
==============================================================================
Binary files - no diff available.

Modified: maven/website/content/pom.html
==============================================================================
--- maven/website/content/pom.html (original)
+++ maven/website/content/pom.html Mon Feb  6 16:37:55 2023
@@ -1354,7 +1354,7 @@ Display parameters as parsed by Maven (i
 <li>A (non-negated) prefix for all other cases</li></ul>
 <p>(Negated) prefix values match if the JDK version used for running Maven starts/doesn't start with the given prefix (excluding the potentially leading <code>!</code>). The value ranges match if the JDK version used for running Maven is between lower and upper bounds (either inclusive or exclusive).</p></li>
 <li><b>os</b>: The <code>os</code> element can define some operating system specific properties shown above. See the maven-enforcer-plugins <a class="externalLink" href="https://maven.apache.org/enforcer/enforcer-rules/requireOS.html">RequireOS Rule</a> for more details about OS values.</li>
-<li><b>property</b>: The <code>profile</code> will activate if Maven detects a system property and commandline property (a value which can be dereferenced within the POM by <code>${name}</code>) of the corresponding <code>name=value</code> pair.</li>
+<li><b>property</b>: The <code>profile</code> will activate if Maven detects a system property or CLI user property (a value which can be dereferenced within the POM by <code>${name}</code>) of the corresponding <code>name=value</code> pair and it matches the given value (if given). Since Maven 3.9.0 one can also evaluate the <b>packaging value</b> of the pom via property name <code>packaging</code>.</li>
 <li><b>file</b>: Finally, a given filename may activate the <code>profile</code> by the <code>existence</code> of a file, or if it is <code>missing</code>. <b>NOTE</b>: interpolation for this element is limited to <code>${basedir}</code>, System properties and request properties.</li></ul>
 <p>The <code>activation</code> element is not the only way that a <code>profile</code> may be activated. The <code>settings.xml</code> file's <code>activeProfile</code> element may contain the profile's <code>id</code>. They may also be activated explicitly through the command line via a comma separated list after the <code>-P</code> flag (e.g. <code>-P codecoverage</code>).</p>
 <p><i>To see which profile will activate in a certain build, use the</i> <code>maven-help-plugin</code>.</p>