  ------
  Using System Properties
  ------
  Allan Ramirez
  Dan Tran
  Konrad Windszus
  ------
  2010-01-09
  ------
  
 ~~ 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.

 ~~ NOTE: For help with the syntax of this file, see:
 ~~ http://maven.apache.org/doxia/references/apt-format.html

Using System Properties

%{toc|section=0|fromDepth=2}


  There are different parameters which affect the system properties passed to ${thisPlugin} providers:

* systemPropertyVariables

  This configuration is the replacement of the deprecated <<<systemProperties>>>. It can accept any {{{https://maven.apache.org/ref/3-LATEST/maven-model-builder/#model-interpolation}expression value}}
  referencing Maven's properties that can be converted <<to a String value>> or arbitrary literals.

+---+
<project>
  [...]
  <build>
    <plugins>
      <plugin>
        <groupId>${project.groupId}</groupId>
        <artifactId>${project.artifactId}</artifactId>
        <version>${project.version}</version>
        <configuration>
          <systemPropertyVariables>
            <propertyName>propertyValue</propertyName>
            <buildDirectory>\${project.build.directory}</buildDirectory>
            [...]
          </systemPropertyVariables>
        </configuration>
      </plugin>
    </plugins>
  </build>
  [...]
</project>
+---+

* systemPropertiesFile

  This configuration allows to add system properties through an external properties file whose path is given via this plugin parameter.

* systemProperties (Deprecated)

+---+
<project>
  [...]
  <build>
    <plugins>
      <plugin>
        <groupId>${project.groupId}</groupId>
        <artifactId>${project.artifactId}</artifactId>
        <version>${project.version}</version>
        <configuration>
          <systemProperties>
            <property>
              <name>propertyName</name>
              <value>propertyValue</value>
            </property>
            [...]
          </systemProperties>
        </configuration>
      </plugin>
    </plugins>
  </build>
  [...]
</project>
+---+

  Take note that only <<String typed>> properties can be passed as system
  properties. Any attempt to pass any other Maven variable type (e.g. a <<<List>>>
  or a <<<URL>>> variable) will cause the variable expression to be passed
  literally (unevaluated). So given the example below:

+---+
<project>
  [...]
  <build>
    <plugins>
      <plugin>
        <groupId>${project.groupId}</groupId>
        <artifactId>${project.artifactId}</artifactId>
        <version>${project.version}</version>
        <configuration>
          <systemProperties>
            <property>
              <name>buildDir</name>
              <value>\${project.build.outputDirectory}</value>
            </property>
          </systemProperties>
        </configuration>
      </plugin>
    </plugins>
  </build>
  [...]
</project>
+---+

  The string <<$\{project.build.outputDirectory\}>> will be passed on literally because the type
  of that expression is a <<<File>>>, not a <<<String>>>.

  To inherit the <<<systemProperties>>> collection from the parent configuration,
  you will need to specify <<<combine.children="append">>> on the <<<systemProperties>>> node in the child pom:

+---+
  <systemProperties combine.children="append">
      <property>
         [...]
      </property>
   </systemProperties>
+---+

* Effective System Properties

  The effective system properties are merged from the following sources:

  [[1]] <<<systemProperties>>>

  [[2]] <<<systemPropertiesFile>>>

  [[3]] <<<systemPropertyVariables>>>

  [[4]] {{{https://maven.apache.org/ref/3-LATEST/maven-core/apidocs/org/apache/maven/execution/MavenSession.html#getUserProperties()}User properties from the current Maven session}} (if <<<promoteUserPropertiesToSystemProperties>>> is not set to <<<false>>>)

  []

  where latter items may overwrite properties with the same name of former items.


* Special VM Properties

  Some system properties must be set on the command line of the forked VM, and cannot be set after the
  VM has been started. These properties must be added to the <<<argLine>>> parameter of the Surefire plugin. E.g.,

+---+
  <argLine>-Djava.endorsed.dirs=...</argLine>
+---+
