<?xml version="1.0" encoding="UTF-8"?>
<?asciidoc-toc maxdepth="2"?>
<?asciidoc-numbered?>
<article xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" version="5.0" xml:lang="en">
<info>
<title>SCM Version Plugin</title>
<date>2019-08-23</date>
</info>
<section xml:id="asciidoc_summary">
<title>Summary</title>
<simpara>Based on the used SCM (Source Control Management) this plugin provides project configuration handling and specific tasks regarding the version handling of the project.
The information of the used SCM is identified by special directories in the project directory (<literal>'.git'</literal>, <literal>'.svn'</literal>).
The plugin supports the following SCMs:</simpara>
<itemizedlist>
<listitem>
<simpara>git</simpara>
</listitem>
<listitem>
<simpara>svn</simpara>
</listitem>
<listitem>
<simpara>file (limited functionality)</simpara>
</listitem>
</itemizedlist>
<simpara>Branches and tags are used for the calculation of the project version. The basic functionality for Git and Subversion is the same.<?asciidoc-br?></simpara>
<note>
<simpara>A file-based project does not support the calculation of the version based on previous versions.</simpara>
</note>
<simpara>It is also possible to identify the changes between the current working copy and the previous version. This functionality can also be used on a CI server during the creation of a new tag. In this case the changes between two versions are written to a file.</simpara>
</section>
<section xml:id="asciidoc_version-information-from-the-scm">
<title>Version Information from the SCM</title>
<simpara>This plugin adds the possibility to calculate version information of a project from the used SCM structure. It initializes a project property <literal>useSCMVersionConfig</literal>. The value of this property is <literal>true</literal>, if the plugin was applied and can be used by the own build logic and other plugins.</simpara>
<section xml:id="asciidoc_subversion">
<title>Subversion</title>
<simpara>This implementation depends on SVNKit 1.8. Therefore an installed SVN client 1.8 for the access to the stored Subversion credentials is required. For a correct calculation of the version, the access to the SVN repository must be available.</simpara>
<caution>
<orderedlist numeration="arabic">
<listitem>
<simpara>This plugin assumes the standard Subversion structure:</simpara>
<literallayout class="monospaced">&lt;project&gt;
 |
 +- &lt;code structure of the trunk&gt;
 |
 +- branches
 |  |
 |  +- &lt;branch name&gt;
 |      |
 |      +- &lt;code structure of the branch&gt;
 |
 +- tags
    |
    +- &lt;tag name&gt;
        |
        +- &lt;code structure of the tag&gt;</literallayout>
</listitem>
<listitem>
<simpara>SVN version calculation is not working without network access.</simpara>
</listitem>
</orderedlist>
</caution>
</section>
<section xml:id="asciidoc_configuration-without-remote-access">
<title>Configuration Without Remote Access</title>
<section xml:id="asciidoc_configuration-with-a-project-property">
<title>Configuration with a Project Property</title>
<simpara>If there is no access to a remote repository, it is possible to specify a version string as project property <literal>offlineVersion</literal> (see above)</simpara>
<screen>gradlew -PofflineVersion=9.9.0.0-LOCAL publish</screen>
<simpara>This will add the version '9.9.0.0-LOCAL' to your project. It is possible to add this property also to the
gradle.properties file in the Gradle user home. In this case all projects with this applied
plugin uses the same version.</simpara>
</section>
<section xml:id="asciidoc_configuration-with-a-static-version">
<title>Configuration with a Static Version</title>
<simpara>This configuration is also working without any remote access, but project specific, because the replacement for
the version information is stored in the build directory of the project. If
<literal>&lt;project build dir&gt;/scmversion/static.version</literal> exists and the content is not empty,
 the content of this is used for the version.</simpara>
<simpara>If the first call of a project task is started with a parameter <literal>staticVersion</literal> and a
version information, the file will be created with the version information.</simpara>
<screen>gradlew -PstaticVersion=TRUNKVER publish</screen>
<simpara>This will set the version to <literal>TRUNKVER</literal>. The project runs now always with this version.
It is possible to remove this configuration with an empty string for <literal>staticVersion</literal> or
if exists with the task <literal>clean</literal>.</simpara>
<screen>gradlew -PstaticVersion= publish</screen>
<simpara>This command will reset the version to the standard behaviour.</simpara>
<caution>
<simpara>This version will be published to the specified repository and can be used by other processes!</simpara>
</caution>
</section>
</section>
<section xml:id="asciidoc_git">
<title>Git</title>
<simpara>The version can be calculated from the local clone without access to the remote repository.
The plugin assumes, that the default branch is called <literal>'master'</literal>.</simpara>
</section>
<section xml:id="asciidoc_version-calculation">
<title>Version Calculation</title>
<simpara>The plugin detects tags and branches with version information on special prefixes. These prefixes are configured based on the configuration <literal>'prefixes'</literal>.
For parsing, calculation and sorting a library for an extended version object is used. The library supports version numbers with three or four decimal numbers. Furthermore a special pattern is supported.</simpara>
<screen>&lt;prefix&gt;_&lt;version&gt;[-&lt;featurebranch name&gt;][-&lt;build extension&gt;]</screen>
<simpara>Therefore branch names must comply with the following patterns. All examples use the default configuration.
Depending on a special environment configuration (RUNONCI) the build extension is empty or SNAPSHOT, if this setting is true, otherwise it is LOCAL.</simpara>
<section xml:id="asciidoc_feature-branches-hotfix-branches-and-bugfix-branches">
<title>Feature Branches, Hotfix Branches and Bugfix Branches</title>
<screen>&lt;feature, hotfix or bugfix branch prefix&gt;_&lt;version&gt;-&lt;branch name&gt;</screen>
<simpara>These are the default values</simpara>
<informaltable frame="all" rowsep="1" colsep="1">
<?dbhtml table-width="50%"?>
<?dbfo table-width="50%"?>
<?dblatex table-width="50%"?>
<tgroup cols="2">
<colspec colname="col_1" colwidth="107*"/>
<colspec colname="col_2" colwidth="107*"/>
<thead>
<row>
<entry align="left" valign="top">Branch Type</entry>
<entry align="left" valign="top">Default value</entry>
</row>
</thead>
<tbody>
<row>
<entry align="left" valign="top"><simpara>Feature Branch</simpara></entry>
<entry align="left" valign="top"><simpara><literal>'FB'</literal></simpara></entry>
</row>
<row>
<entry align="left" valign="top"><simpara>Hotfix Branch</simpara></entry>
<entry align="left" valign="top"><simpara><literal>'HB'</literal></simpara></entry>
</row>
<row>
<entry align="left" valign="top"><simpara>Bugfix Branch</simpara></entry>
<entry align="left" valign="top"><simpara><literal>'BB'</literal></simpara></entry>
</row>
</tbody>
</tgroup>
</informaltable>
<simpara>The version is the original version of the master/trunk.</simpara>
<formalpara>
<title>Example</title>
<para>
<screen>FB_1.0.0-JIRA-4711
FB_1.0.0-FeatureBranchName</screen>
</para>
</formalpara>
</section>
<section xml:id="asciidoc_stabilization-branch">
<title>Stabilization branch</title>
<screen>&lt;stabilization branch prefix&gt;_&lt;version&gt;</screen>
<simpara>The default stabilization branch prefix is <literal>'SB'</literal>. The version is the base version for this branch. In most cases, it is the major version of the master/trunk, before the branch was created.</simpara>
<formalpara>
<title>Example</title>
<para>
<screen>SB_1        Stabilization branch for version 1.0.0 to 1.X.X
SB_1.0      Stabilization branch for version 1.0.0 to 1.0.X</screen>
</para>
</formalpara>
</section>
<section xml:id="asciidoc_release-tag">
<title>Release Tag</title>
<screen>&lt;release prefix&gt;_&lt;version&gt;[-&lt;featurebranch name&gt;][-&lt;build extension&gt;]</screen>
<simpara>The default release prefix is <literal>'RELEASE'</literal>. The version is the base version of the branch. In the most cases, it is the major version of the master/trunk, before the branch was created.</simpara>
<formalpara>
<title>Example</title>
<para>
<screen>RELEASE_1.1.0                   Release tag for version 1.1.0
RELEASE_1.1.0-dev.1             Tag of a development milestone release for version 1.1.0
RELEASE_1.1.0-rc.1              Tag of a release candidate for version 1.1.0
RELEASE_1.0.0-JIRA-4711-dev.1   Tag of a development milestone release of a feature branch version 1.0.0-JIRA-4711</screen>
</para>
</formalpara>
</section>
<section xml:id="asciidoc_version-calculation-on-git">
<title>Version Calculation on Git</title>
<itemizedlist>
<listitem>
<simpara>Default Branch (master)<?asciidoc-br?>
The plugin is looking for a tag on the branch. If there is no tag the default value is used and extended with <literal>SNAPSHOT</literal>.</simpara>
</listitem>
<listitem>
<simpara>Branch / Feature,Hotfix,Bugfix Branch<?asciidoc-br?>
The plugin is looking for a tag on the branch. If there is no valid tag on the branch, the version is taken from the name of the branch. The version will be always extended with <literal>SNAPSHOT</literal> on the CI server.</simpara>
</listitem>
<listitem>
<simpara>Tags<?asciidoc-br?>
Without local changes the plugin tries to calculate the name from the tag name.</simpara>
</listitem>
</itemizedlist>
<simpara>A checkout of a single commit (detached head) without a tag name will be specially treated. The last found version is
used for the version string. This is extended by the short hash value and 'SNAPSHOT', e.g. 2.0.0-rev.id.ad73b69-SNAPSHOT.
If the environment variable <literal>'CONTINUOUSRELEASE'</literal> or the project variable <literal>'continuousRelease'</literal> is set, the extension SNAPSHOT is not added.</simpara>
</section>
<section xml:id="asciidoc_version-calculation-on-subversion">
<title>Version Calculation on Subversion</title>
<itemizedlist>
<listitem>
<simpara>Trunk<?asciidoc-br?>
The plugin is looking for a tag that matches the specified criteria. In the most cases, the version is calculated from branches and will be extended with <literal>SNAPSHOT</literal>. This behavior can be configured.</simpara>
</listitem>
<listitem>
<simpara>Branch / Feature,Hotfix,Bugfix Branch<?asciidoc-br?>
The plugin is looking for a tag that matches the branch name. If there is no valid tag on the branch, the version is taken from the name of the branch. The version will be always extended with <literal>SNAPSHOT</literal> on the CI server.</simpara>
</listitem>
<listitem>
<simpara>Tags<?asciidoc-br?>
Without local changes the plugin tries to calculate the name from the tag name.</simpara>
</listitem>
</itemizedlist>
</section>
</section>
</section>
<section xml:id="asciidoc_usage">
<title>Usage</title>
<simpara>To use the Gradle SCM Version plugin provided by Intershop, include the following in your build script of your <emphasis role="strong">root</emphasis> project:</simpara>
<formalpara>
<title>build.gradle</title>
<para>
<programlisting language="groovy" linenumbering="unnumbered">plugins {
    id 'com.intershop.gradle.scmversion' version '2.7.2'
}

scm {
    prefixes {
        //default is 'SB'
        stabilizationPrefix = 'SBP'

        //default is 'FB'
        featurePrefix = 'FBP'

        //default is 'HB'
        hotfixPrefix = 'HBP'

        //default is 'BB'
        bugfixPrefix = 'BBP'

        //default is Release
        tagPrefix = 'RBP'
    }

    version {
        type = 'threeDigits'
        initialVersion = '1.0.0'
    }

    changelog {
        previousVersion = '1.0.0'
        changeLogFile = new File(project.buildDir, 'changelog/changelogset.asciidoc')
        filterProject = true
    }
}

version = scm.version.version</programlisting>
</para>
</formalpara>
</section>
<section xml:id="asciidoc_tasks">
<title>Tasks</title>
<simpara>The Intershop SCM Version plugin adds the following tasks to the project:</simpara>
<informaltable frame="all" rowsep="1" colsep="1">
<?dbhtml table-width="95%"?>
<?dbfo table-width="95%"?>
<?dblatex table-width="95%"?>
<tgroup cols="3">
<colspec colname="col_1" colwidth="81*"/>
<colspec colname="col_2" colwidth="61*"/>
<colspec colname="col_3" colwidth="263*"/>
<thead>
<row>
<entry align="left" valign="top">Task name</entry>
<entry align="left" valign="top">Type</entry>
<entry align="left" valign="top">Description</entry>
</row>
</thead>
<tbody>
<row>
<entry align="left" valign="top"><simpara>showVersion</simpara></entry>
<entry align="left" valign="top"><simpara>ShowVersion</simpara></entry>
<entry align="left" valign="top"><simpara>This task shows the current version of the working copy.</simpara></entry>
</row>
<row>
<entry align="left" valign="top"><simpara>tag</simpara></entry>
<entry align="left" valign="top"><simpara>CreateTag</simpara></entry>
<entry align="left" valign="top"><simpara>This task creates a tag based on the current working copy.<?asciidoc-br?>
It makes changes to the SCM.</simpara></entry>
</row>
<row>
<entry align="left" valign="top"><simpara>branch</simpara></entry>
<entry align="left" valign="top"><simpara>CreateBranch</simpara></entry>
<entry align="left" valign="top"><simpara>This task creates a branch based on the current working copy.<?asciidoc-br?>
It makes changes to the SCM. <?asciidoc-br?>
For creating a feature branch it is necessary to specify a short name for the feature in a project property <literal><emphasis role="strong">feature</emphasis></literal>.</simpara></entry>
</row>
<row>
<entry align="left" valign="top"><simpara>toVersion</simpara></entry>
<entry align="left" valign="top"><simpara>ToVersion</simpara></entry>
<entry align="left" valign="top"><simpara>This task moves the working copy to a target version.
This version must be specified in a project property <literal><emphasis role="strong">targetVersion</emphasis></literal>. It is also possible to specify the short name of a
feature in a property <literal><emphasis role="strong">feature</emphasis></literal> and the kind of branch in the property <literal><emphasis role="strong">branchType</emphasis></literal>, that should be used. The default value for the type is <literal><emphasis role="strong">branch</emphasis></literal>. Possible values are <literal><emphasis role="strong">featureBranch</emphasis></literal>,  <literal><emphasis role="strong">hotfixBranch</emphasis></literal>, <literal><emphasis role="strong">bugfixBranch</emphasis></literal>, <literal><emphasis role="strong">tag</emphasis></literal>. It changes the working copy.</simpara></entry>
</row>
<row>
<entry align="left" valign="top"><simpara>release</simpara></entry>
<entry align="left" valign="top"><simpara>PrepareRelease</simpara></entry>
<entry align="left" valign="top"><simpara>This task creates a tag, if necessary, and move the the working copy to the version.<?asciidoc-br?>
It changes the working copy.</simpara></entry>
</row>
<row>
<entry align="left" valign="top"><simpara>createChangelog</simpara></entry>
<entry align="left" valign="top"><simpara>CreateChangeLog</simpara></entry>
<entry align="left" valign="top"><simpara>This task creates a change log with all changes between the latest commit of the current working copy and the tag of the previous version. It is possible to specify another 'previous' version.<?asciidoc-br?>
The tag for this version is mandatory.</simpara></entry>
</row>
</tbody>
</tgroup>
</informaltable>
<simpara>All task are part of the package <literal>'com.intershop.gradle.scm.task'</literal></simpara>
</section>
<section xml:id="asciidoc_project-extension-scm">
<title>Project Extension 'scm'</title>
<simpara>This plugin adds an extension <emphasis role="strong"><literal>scm</literal></emphasis> to the root project. This extension contains all plugin configurations.</simpara>
<section xml:id="asciidoc_methods">
<title>Methods</title>
<informaltable frame="all" rowsep="1" colsep="1">
<?dbhtml table-width="95%"?>
<?dbfo table-width="95%"?>
<?dblatex table-width="95%"?>
<tgroup cols="3">
<colspec colname="col_1" colwidth="81*"/>
<colspec colname="col_2" colwidth="61*"/>
<colspec colname="col_3" colwidth="263*"/>
<thead>
<row>
<entry align="left" valign="top">Method</entry>
<entry align="left" valign="top">Values</entry>
<entry align="left" valign="top">Description</entry>
</row>
</thead>
<tbody>
<row>
<entry align="left" valign="top"><simpara><emphasis role="strong">prefixes</emphasis>(configure)</simpara></entry>
<entry align="left" valign="top"><simpara><link linkend="prefixconfig">PrefixConfig</link></simpara></entry>
<entry align="left" valign="top"><simpara>This is the extension object for the configuration of branch prefixes.</simpara></entry>
</row>
<row>
<entry align="left" valign="top"><simpara><emphasis role="strong">user</emphasis>(configure)</simpara></entry>
<entry align="left" valign="top"><simpara><link linkend="scmuser">ScmUser</link></simpara></entry>
<entry align="left" valign="top"><simpara>This extension is used for the SCM user authentication.<?asciidoc-br?>
<emphasis>This extension can be configured over environment variables and project properties.</emphasis></simpara></entry>
</row>
<row>
<entry align="left" valign="top"><simpara><emphasis role="strong">key</emphasis>(configure)</simpara></entry>
<entry align="left" valign="top"><simpara><link linkend="scmkey">ScmKey</link></simpara></entry>
<entry align="left" valign="top"><simpara>This is also used for the SCM user authentication.<?asciidoc-br?>
<emphasis>This extension can be configured over environment variables and project properties.</emphasis></simpara></entry>
</row>
<row>
<entry align="left" valign="top"><simpara><emphasis role="strong">version</emphasis>(configure)</simpara></entry>
<entry align="left" valign="top"><simpara><link linkend="scmversion">ScmVersion</link></simpara></entry>
<entry align="left" valign="top"><simpara>This extension contains settings for version calculation and reads properties for the current version and previous version.</simpara></entry>
</row>
<row>
<entry align="left" valign="top"><simpara><emphasis role="strong">changelog</emphasis>(configure)</simpara></entry>
<entry align="left" valign="top"><simpara><link linkend="scmchangelog">ScmChangelog</link></simpara></entry>
<entry align="left" valign="top"><simpara>This extension contains settings for change log configuration.</simpara></entry>
</row>
</tbody>
</tgroup>
</informaltable>
<section xml:id="asciidoc_-anchor-xml-id-prefixconfig-xreflabel-prefixconfig-prefix-configuration-prefixes-literal-prefixconfig-literal">
<title><anchor xml:id="prefixconfig" xreflabel="[prefixconfig]"/>Prefix configuration 'prefixes' (<literal>PrefixConfig</literal>)</title>
<informaltable frame="all" rowsep="1" colsep="1">
<?dbhtml table-width="95%"?>
<?dbfo table-width="95%"?>
<?dblatex table-width="95%"?>
<tgroup cols="4">
<colspec colname="col_1" colwidth="81*"/>
<colspec colname="col_2" colwidth="61*"/>
<colspec colname="col_3" colwidth="61*"/>
<colspec colname="col_4" colwidth="202*"/>
<thead>
<row>
<entry align="left" valign="top">Property</entry>
<entry align="left" valign="top">Type</entry>
<entry align="left" valign="top">Default value</entry>
<entry align="left" valign="top">Description</entry>
</row>
</thead>
<tbody>
<row>
<entry align="left" valign="top"><simpara><emphasis role="strong">stabilizationPrefix</emphasis></simpara></entry>
<entry align="left" valign="top"><simpara><literal>String</literal></simpara></entry>
<entry align="left" valign="top"><simpara><literal>SB</literal></simpara></entry>
<entry align="left" valign="top"><simpara>Prefix for stabilization branches</simpara></entry>
</row>
<row>
<entry align="left" valign="top"><simpara><emphasis role="strong">featurePrefix</emphasis></simpara></entry>
<entry align="left" valign="top"><simpara><literal>String</literal></simpara></entry>
<entry align="left" valign="top"><simpara><literal>FB</literal></simpara></entry>
<entry align="left" valign="top"><simpara>Prefix for feature branches</simpara></entry>
</row>
<row>
<entry align="left" valign="top"><simpara><emphasis role="strong">hotfixPrefix</emphasis></simpara></entry>
<entry align="left" valign="top"><simpara><literal>String</literal></simpara></entry>
<entry align="left" valign="top"><simpara><literal>HB</literal></simpara></entry>
<entry align="left" valign="top"><simpara>Prefix for hotfix branches</simpara></entry>
</row>
<row>
<entry align="left" valign="top"><simpara><emphasis role="strong">bugfixPrefix</emphasis></simpara></entry>
<entry align="left" valign="top"><simpara><literal>String</literal></simpara></entry>
<entry align="left" valign="top"><simpara><literal>BB</literal></simpara></entry>
<entry align="left" valign="top"><simpara>Prefix for bugfix branches</simpara></entry>
</row>
<row>
<entry align="left" valign="top"><simpara><emphasis role="strong">tagPrefix</emphasis></simpara></entry>
<entry align="left" valign="top"><simpara><literal>String</literal></simpara></entry>
<entry align="left" valign="top"><simpara><literal>RELEASE</literal></simpara></entry>
<entry align="left" valign="top"><simpara>Prefix for release tags</simpara></entry>
</row>
<row>
<entry align="left" valign="top"><simpara><emphasis role="strong">prefixSeperator</emphasis></simpara></entry>
<entry align="left" valign="top"><simpara><literal>String</literal></simpara></entry>
<entry align="left" valign="top"><simpara><literal>_</literal></simpara></entry>
<entry align="left" valign="top"><simpara>Separator between prefix and version</simpara></entry>
</row>
</tbody>
</tgroup>
</informaltable>
</section>
<section xml:id="asciidoc_authentication">
<title>Authentication</title>
<section xml:id="asciidoc_user-object-user-literal-scmuser-literal-anchor-xml-id-scmuser-xreflabel-scmuser">
<title>User object 'user' (<literal>ScmUser</literal>)<anchor xml:id="scmuser" xreflabel="[scmuser]"/></title>
<informaltable frame="all" rowsep="1" colsep="1">
<?dbhtml table-width="95%"?>
<?dbfo table-width="95%"?>
<?dblatex table-width="95%"?>
<tgroup cols="4">
<colspec colname="col_1" colwidth="81*"/>
<colspec colname="col_2" colwidth="61*"/>
<colspec colname="col_3" colwidth="61*"/>
<colspec colname="col_4" colwidth="202*"/>
<thead>
<row>
<entry align="left" valign="top">Property</entry>
<entry align="left" valign="top">Type</entry>
<entry align="left" valign="top">Default value</entry>
<entry align="left" valign="top">Description</entry>
</row>
</thead>
<tbody>
<row>
<entry align="left" valign="top"><simpara><emphasis role="strong">name</emphasis></simpara></entry>
<entry align="left" valign="top"><simpara><literal>String</literal></simpara></entry>
<entry align="left" valign="top"><simpara>''</simpara></entry>
<entry align="left" valign="top"><simpara>Username or token<?asciidoc-br?>
<emphasis>This can be overwritten by the system or environment variable <literal>SCM_USERNAME</literal> or project property <literal>scmUserName</literal>.</emphasis></simpara></entry>
</row>
<row>
<entry align="left" valign="top"><simpara><emphasis role="strong">password</emphasis></simpara></entry>
<entry align="left" valign="top"><simpara><literal>String</literal></simpara></entry>
<entry align="left" valign="top"><simpara>''</simpara></entry>
<entry align="left" valign="top"><simpara>Password<?asciidoc-br?>
<emphasis>This can be overwritten by the system or environment variable <literal>SCM_PASSWORD</literal> or project property <literal>scmUserPasswd</literal>.</emphasis></simpara></entry>
</row>
</tbody>
</tgroup>
</informaltable>
</section>
<section xml:id="asciidoc_ssh-key-object-key-literal-scmkey-literal-only-for-git-anchor-xml-id-scmkey-xreflabel-scmkey">
<title>SSH Key object 'key' (<literal>ScmKey</literal>) (only for Git)<anchor xml:id="scmkey" xreflabel="[scmkey]"/></title>
<informaltable frame="all" rowsep="1" colsep="1">
<?dbhtml table-width="95%"?>
<?dbfo table-width="95%"?>
<?dblatex table-width="95%"?>
<tgroup cols="4">
<colspec colname="col_1" colwidth="81*"/>
<colspec colname="col_2" colwidth="61*"/>
<colspec colname="col_3" colwidth="61*"/>
<colspec colname="col_4" colwidth="202*"/>
<thead>
<row>
<entry align="left" valign="top">Property</entry>
<entry align="left" valign="top">Type</entry>
<entry align="left" valign="top">Default value</entry>
<entry align="left" valign="top">Description</entry>
</row>
</thead>
<tbody>
<row>
<entry align="left" valign="top"><simpara><emphasis role="strong">file</emphasis></simpara></entry>
<entry align="left" valign="top"><simpara><literal>File</literal></simpara></entry>
<entry align="left" valign="top"><simpara><literal>null</literal></simpara></entry>
<entry align="left" valign="top"><simpara>Private key for SCM authentication<?asciidoc-br?>
<emphasis>This can be overwritten by the system or environment variable <literal>SCM_KEYFILE</literal> or project property <literal>scmKeyFile</literal>.</emphasis>
The plugin uses per default for ssh access &lt;user_home&gt;/.ssh/id_rsa or &lt;user_home&gt;/.ssh/id_dsa without passphrase.</simpara></entry>
</row>
<row>
<entry align="left" valign="top"><simpara><emphasis role="strong">passphrase</emphasis></simpara></entry>
<entry align="left" valign="top"><simpara><literal>String</literal></simpara></entry>
<entry align="left" valign="top"><simpara>''</simpara></entry>
<entry align="left" valign="top"><simpara>passphrase for private key<?asciidoc-br?>
<emphasis>This can be overwritten by the system or environment variable <literal>SCM_KEYPASSPHRASE</literal> or project property <literal>scmKeyPassphrase</literal>.</emphasis></simpara></entry>
</row>
</tbody>
</tgroup>
</informaltable>
</section>
</section>
<section xml:id="asciidoc_version-object-version-literal-scmversion-literal-anchor-xml-id-scmversion-xreflabel-scmversion">
<title>Version object 'version' (<literal>ScmVersion</literal>)<anchor xml:id="scmversion" xreflabel="[scmversion]"/></title>
<informaltable frame="all" rowsep="1" colsep="1">
<?dbhtml table-width="95%"?>
<?dbfo table-width="95%"?>
<?dblatex table-width="95%"?>
<tgroup cols="5">
<colspec colname="col_1" colwidth="81*"/>
<colspec colname="col_2" colwidth="61*"/>
<colspec colname="col_3" colwidth="61*"/>
<colspec colname="col_4" colwidth="61*"/>
<colspec colname="col_5" colwidth="141*"/>
<thead>
<row>
<entry align="left" valign="top">Property</entry>
<entry align="left" valign="top">Type</entry>
<entry align="left" valign="top">Default value</entry>
<entry align="left" valign="top">Values</entry>
<entry align="left" valign="top">Description</entry>
</row>
</thead>
<tbody>
<row>
<entry align="left" valign="top"><simpara><emphasis role="strong">type</emphasis></simpara></entry>
<entry align="left" valign="top"><simpara><literal>String</literal></simpara></entry>
<entry align="left" valign="top"><simpara><literal>threeDigits</literal></simpara></entry>
<entry align="left" valign="top"><simpara><literal>fourDigits</literal><?asciidoc-br?>
 <literal>threeDigits</literal></simpara></entry>
<entry align="left" valign="top"><simpara>The number of used decimal numbers for a version number.</simpara></entry>
</row>
<row>
<entry align="left" valign="top"><simpara><emphasis role="strong">dryRun</emphasis></simpara></entry>
<entry align="left" valign="top"><simpara><literal>boolean</literal></simpara></entry>
<entry align="left" valign="top"><simpara><literal>false</literal></simpara></entry>
<entry align="left" valign="top"><simpara><literal>false</literal><?asciidoc-br?>
<literal>true</literal></simpara></entry>
<entry align="left" valign="top"><simpara>Tasks will run without changes on the working copy or SCM.<?asciidoc-br?>
<emphasis>This can be overwritten by the system or environment variable <literal>DRYRUN</literal> or project property <literal>dryRun</literal>.</emphasis></simpara></entry>
</row>
<row>
<entry align="left" valign="top"><simpara><emphasis role="strong">runOnCI</emphasis></simpara></entry>
<entry align="left" valign="top"><simpara><literal>boolean</literal></simpara></entry>
<entry align="left" valign="top"><simpara><literal>false</literal></simpara></entry>
<entry align="left" valign="top"><simpara><literal>false</literal><?asciidoc-br?>
<literal>true</literal></simpara></entry>
<entry align="left" valign="top"><simpara>This configuration must be <literal>true</literal>, if the project is used on a CI server.<?asciidoc-br?>
<emphasis>This can be overwritten by the system or environment variable <literal>RUNONCI</literal> or project property <literal>runOnCI</literal>.</emphasis></simpara></entry>
</row>
<row>
<entry align="left" valign="top"><simpara><emphasis role="strong">increment</emphasis></simpara></entry>
<entry align="left" valign="top"><simpara><literal>String</literal></simpara></entry>
<entry align="left" valign="top"><simpara><literal>null</literal></simpara></entry>
<entry align="left" valign="top"><simpara><literal>MAJOR</literal><?asciidoc-br?>
<literal>MINOR</literal><?asciidoc-br?>
<literal>PATCH</literal><?asciidoc-br?>
 <literal>HOTFIX</literal></simpara></entry>
<entry align="left" valign="top"><simpara>If this property is set, the configured position is used for incrementing the version.<?asciidoc-br?>
 <emphasis>This can be overwritten by the system or environment variable <literal>INCREMENT</literal>, or project property <literal>increment</literal>.</emphasis></simpara></entry>
</row>
<row>
<entry align="left" valign="top"><simpara><emphasis role="strong">initialVersion</emphasis></simpara></entry>
<entry align="left" valign="top"><simpara><literal>String</literal></simpara></entry>
<entry align="left" valign="top"><simpara><literal>'1.0.0.0'</literal><?asciidoc-br?>
 <literal>'1.0.0'</literal></simpara></entry>
<entry align="left" valign="top"></entry>
<entry align="left" valign="top"><simpara>The inital version if a calculation from SCM is not possible.</simpara></entry>
</row>
<row>
<entry align="left" valign="top"><simpara><emphasis role="strong">branchType</emphasis></simpara></entry>
<entry align="left" valign="top"><simpara><literal>String</literal></simpara></entry>
<entry align="left" valign="top"><simpara><literal>tag</literal></simpara></entry>
<entry align="left" valign="top"><simpara><literal>branch</literal><?asciidoc-br?>
<literal>tag</literal></simpara></entry>
<entry align="left" valign="top"><simpara>The branch which is primarily used for the version calculation.</simpara></entry>
</row>
<row>
<entry align="left" valign="top"><simpara><emphasis role="strong">patternDigits</emphasis></simpara></entry>
<entry align="left" valign="top"><simpara><literal>int</literal></simpara></entry>
<entry align="left" valign="top"><simpara><literal>2</literal></simpara></entry>
<entry align="left" valign="top"><simpara><literal>1</literal><?asciidoc-br?>
<literal>2</literal><?asciidoc-br?>
<literal>3</literal> (available only if ScmVersion <literal>type</literal> is <literal>fourDigits</literal>)</simpara></entry>
<entry align="left" valign="top"><simpara>Determines the number of digit blocks of the version number that will be used for calculating the version filter from branches.</simpara></entry>
</row>
<row>
<entry align="left" valign="top"><simpara><emphasis role="strong">defaultMetadata</emphasis></simpara></entry>
<entry align="left" valign="top"><simpara><literal>String</literal></simpara></entry>
<entry align="left" valign="top"><simpara>''</simpara></entry>
<entry align="left" valign="top"></entry>
<entry align="left" valign="top"><simpara>This is used for releases of feature branches.</simpara></entry>
</row>
<row>
<entry align="left" valign="top"><simpara><emphasis role="strong">useBuildExtension</emphasis></simpara></entry>
<entry align="left" valign="top"><simpara><literal>boolean</literal></simpara></entry>
<entry align="left" valign="top"><simpara><literal>false</literal></simpara></entry>
<entry align="left" valign="top"><simpara><literal>false</literal><?asciidoc-br?>
<literal>true</literal></simpara></entry>
<entry align="left" valign="top"><simpara>Build extension will be removed for SNAPSHOT extensions if this property is false.</simpara></entry>
</row>
<row>
<entry align="left" valign="top"><simpara><emphasis role="strong">branchWithVersion</emphasis></simpara></entry>
<entry align="left" valign="top"><simpara><literal>boolean</literal></simpara></entry>
<entry align="left" valign="top"><simpara><literal>true</literal></simpara></entry>
<entry align="left" valign="top"></entry>
<entry align="left" valign="top"><simpara>This property affects only GIT based repositories.<?asciidoc-br?>
If this property is false the version of feature branches is calculated from any tag on the branch. Therefore it is not necessary to specify a version in the branch name.</simpara></entry>
</row>
<row>
<entry align="left" valign="top"><simpara><emphasis role="strong">majorVersionOnly</emphasis></simpara></entry>
<entry align="left" valign="top"><simpara><literal>boolean</literal></simpara></entry>
<entry align="left" valign="top"><simpara><literal>true</literal></simpara></entry>
<entry align="left" valign="top"></entry>
<entry align="left" valign="top"><simpara>This property affects only GIT based repositories.<?asciidoc-br?>
If this property is true and branchWithVersion is false, the version is always only the major version. If the increment property is always configure for MAJOR the version will be increased.</simpara></entry>
</row>
<row>
<entry align="left" valign="top"><simpara><emphasis role="strong">disableSCM</emphasis></simpara></entry>
<entry align="left" valign="top"><simpara><literal>boolean</literal></simpara></entry>
<entry align="left" valign="top"><simpara><literal>false</literal></simpara></entry>
<entry align="left" valign="top"><simpara><literal>false</literal><?asciidoc-br?>
<literal>true</literal></simpara></entry>
<entry align="left" valign="top"><simpara>If this property is <literal>true</literal>, the initial version is always used and the SCM usage is disabled.
The environment variable <literal>'SCMVERSIONEXT'</literal> or the project variable <literal>'scmVersionExt'</literal> will be used on the CI server for special extensions.<?asciidoc-br?>
If set to:<?asciidoc-br?>
<literal>'SNAPSHOT'</literal> - <literal>'SNAPSHOT'</literal> will be added to the version.<?asciidoc-br?>
<literal>'RELEASE'</literal> - intial version is used without any extension.<?asciidoc-br?>
If no value is specified a time stamp will be added.<?asciidoc-br?>
On a local developer machine <literal>'LOCAL'</literal> will be added to the version.</simpara></entry>
</row>
<row>
<entry align="left" valign="top"><simpara><emphasis role="strong">version</emphasis></simpara></entry>
<entry align="left" valign="top"><simpara><literal>String</literal></simpara></entry>
<entry align="left" valign="top"><simpara><emphasis role="strong">initialVersion</emphasis></simpara></entry>
<entry align="left" valign="top"><simpara><emphasis role="strong">read only</emphasis></simpara></entry>
<entry align="left" valign="top"><simpara>Returns the version of the working copy</simpara></entry>
</row>
<row>
<entry align="left" valign="top"><simpara><emphasis role="strong">branchName</emphasis></simpara></entry>
<entry align="left" valign="top"><simpara><literal>String</literal></simpara></entry>
<entry align="left" valign="top"><simpara>''</simpara></entry>
<entry align="left" valign="top"><simpara><emphasis role="strong">read only</emphasis></simpara></entry>
<entry align="left" valign="top"><simpara>Returns the branch name only (String after last /)</simpara></entry>
</row>
<row>
<entry align="left" valign="top"><simpara><emphasis role="strong">versionExt</emphasis></simpara></entry>
<entry align="left" valign="top"><simpara><literal>String</literal></simpara></entry>
<entry align="left" valign="top"><simpara>''</simpara></entry>
<entry align="left" valign="top"><simpara><emphasis role="strong">read only</emphasis></simpara></entry>
<entry align="left" valign="top"><simpara>see description for <literal>disableSCM</literal>. The environment variable <literal>SCMVERSIONEXT</literal> or the project variable <literal>scmVersionExt</literal> is used for the return value.</simpara></entry>
</row>
<row>
<entry align="left" valign="top"><simpara><emphasis role="strong">previousVersion</emphasis></simpara></entry>
<entry align="left" valign="top"><simpara><literal>String</literal></simpara></entry>
<entry align="left" valign="top"><simpara>''</simpara></entry>
<entry align="left" valign="top"><simpara><emphasis role="strong">read only</emphasis></simpara></entry>
<entry align="left" valign="top"><simpara>Returns the previous version of the working copy.</simpara></entry>
</row>
<row>
<entry align="left" valign="top"><simpara><emphasis role="strong">previousVersionTag</emphasis></simpara></entry>
<entry align="left" valign="top"><simpara><literal>VersionTag</literal></simpara></entry>
<entry align="left" valign="top"><simpara><literal>null</literal></simpara></entry>
<entry align="left" valign="top"><simpara><emphasis role="strong">read only</emphasis></simpara></entry>
<entry align="left" valign="top"><simpara>Returns an object with the previous version and the associated release tag.</simpara></entry>
</row>
<row>
<entry align="left" valign="top"><simpara><emphasis role="strong">continuousRelease</emphasis></simpara></entry>
<entry align="left" valign="top"><simpara><literal>boolean</literal></simpara></entry>
<entry align="left" valign="top"><simpara><literal>false</literal></simpara></entry>
<entry align="left" valign="top"><simpara><literal>false</literal><?asciidoc-br?>
<literal>true</literal></simpara></entry>
<entry align="left" valign="top"><simpara>For continuous releases it is helpful to use an version extension with an relation to the source control.
It is possible to enable this configuration also over the environment variable <literal>'CONTINUOUSRELEASE'</literal> or the project variable <literal>'continuousRelease'</literal>.</simpara></entry>
</row>
<row>
<entry align="left" valign="top"><simpara><emphasis role="strong">continuousReleaseBranches</emphasis></simpara></entry>
<entry align="left" valign="top"><simpara><literal>List&lt;String&gt;</literal></simpara></entry>
<entry align="left" valign="top"><simpara><literal>[]</literal></simpara></entry>
<entry align="left" valign="top"><simpara>Branchnames</simpara></entry>
<entry align="left" valign="top"><simpara>In combination with continuousRelease it should be possible to specify the branches for this
kind of version extension. Continuous releases will be also used for the master or trunk.
If you want extend the list of branches, it is possible to extend the list.</simpara></entry>
</row>
</tbody>
</tgroup>
</informaltable>
</section>
<section xml:id="asciidoc_changelog-object-changelog-literal-scmchangelog-literal-anchor-xml-id-scmchangelog-xreflabel-scmchangelog">
<title>Changelog Object 'changeLog' (<literal>ScmChangeLog</literal>)<anchor xml:id="scmchangelog" xreflabel="[scmchangelog]"/></title>
<informaltable frame="all" rowsep="1" colsep="1">
<?dbhtml table-width="95%"?>
<?dbfo table-width="95%"?>
<?dblatex table-width="95%"?>
<tgroup cols="4">
<colspec colname="col_1" colwidth="81*"/>
<colspec colname="col_2" colwidth="61*"/>
<colspec colname="col_3" colwidth="61*"/>
<colspec colname="col_4" colwidth="202*"/>
<thead>
<row>
<entry align="left" valign="top">Property</entry>
<entry align="left" valign="top">Type</entry>
<entry align="left" valign="top">Default value</entry>
<entry align="left" valign="top">Description</entry>
</row>
</thead>
<tbody>
<row>
<entry align="left" valign="top"><simpara><emphasis role="strong">previousVersion</emphasis></simpara></entry>
<entry align="left" valign="top"><simpara><literal>String</literal></simpara></entry>
<entry align="left" valign="top"><simpara><emphasis role="strong">version.previousVersion</emphasis></simpara></entry>
<entry align="left" valign="top"><simpara>Any version with tag for change log calculation.<?asciidoc-br?>
It is possible to override the value with the enviroment variable <literal>PREV_VERSION</literal></simpara></entry>
</row>
<row>
<entry align="left" valign="top"><simpara><emphasis role="strong">changelogFile</emphasis></simpara></entry>
<entry align="left" valign="top"><simpara><literal>File</literal></simpara></entry>
<entry align="left" valign="top"><simpara><literal>&lt;buildDir&gt;/changelog/<?asciidoc-br?>
changelog.asciidoc</literal></simpara></entry>
<entry align="left" valign="top"><simpara>The change log will be written to this file. The log file is empty, if the previous version does not exists.</simpara></entry>
</row>
<row>
<entry align="left" valign="top"><simpara><emphasis role="strong">filterProject</emphasis></simpara></entry>
<entry align="left" valign="top"><simpara><literal>boolean</literal></simpara></entry>
<entry align="left" valign="top"><simpara><literal>false</literal></simpara></entry>
<entry align="left" valign="top"><simpara>Filter changed files for projects (first folder in changed files must be identical to last folder of project svn url)</simpara></entry>
</row>
</tbody>
</tgroup>
</informaltable>
</section>
</section>
</section>
<section xml:id="asciidoc_example-configurations">
<title>Example Configurations</title>
<section xml:id="asciidoc_simple-configuration">
<title>Simple Configuration</title>
<programlisting language="groovy" linenumbering="unnumbered">plugins {
    id 'com.intershop.gradle.scmversion' version '2.7.2'
}


scm {
    version {
        type = 'threeDigits'
        initialVersion = '1.0.0'
    }
}

version = scm.version.version</programlisting>
</section>
<section xml:id="asciidoc_gradle-properties-with-authentication-configuration">
<title>gradle.properties with Authentication Configuration</title>
<simpara>This configuration works for Subversion and Git (http(s)://&#8230;&#8203;). It is necessary to specify username and password for this kind of repositories.</simpara>
<programlisting language="properties" linenumbering="unnumbered">scmUserName = username
scmUserPasswd = password</programlisting>
<simpara>This configuration works for GitLab / GitHub (ssh://&#8230;&#8203;) with a private key and if necessary with a passphrase.
There is no default value for the key.</simpara>
<programlisting language="properties" linenumbering="unnumbered"># without passphrase
scmKeyFile = /user/home/.ssh/id_rsa</programlisting>
<programlisting language="properties" linenumbering="unnumbered"># with passphrase
scmKeyFile = /user/home/.ssh/id_rsa
scmKeyPassphrase = passphrase</programlisting>
<simpara>To use ssh keys you have to switch your repository from https to ssh with the following command:</simpara>
<programlisting language="shell" linenumbering="unnumbered">git remote set-url origin git@gitlab.coporate.com:yourname/yourrepo.git</programlisting>
</section>
<section xml:id="asciidoc_simple-configuration-without-scm">
<title>Simple Configuration Without SCM</title>
<simpara>This configuration can be used when a different version control system is used in the project or another version schema is set in the project.</simpara>
<note>
<simpara>Using this configuration a lot of the features are no longer available.</simpara>
</note>
<programlisting language="groovy" linenumbering="unnumbered">plugins {
    id 'com.intershop.gradle.scmversion' version '2.7.2'
}

scm {
    version {
        disableSCM = true
        initialVersion = '1.0.0'
    }
}

version = scm.version.version</programlisting>
<simpara>On a CI server some properties must be transfered via the command line:</simpara>
<formalpara>
<title>snapshot build:</title>
<para>
<programlisting language="properties" linenumbering="unnumbered">./gradlew publish -PrunOnCI=true -PscmVersionExt=SNAPSHOT</programlisting>
</para>
</formalpara>
<formalpara>
<title>release build:</title>
<para>
<programlisting language="properties" linenumbering="unnumbered">./gradlew publish -PrunOnCI=true -PscmVersionExt=RELEASE</programlisting>
</para>
</formalpara>
<note>
<simpara>After a release it is necessary to change the version manually.</simpara>
</note>
</section>
<section xml:id="asciidoc_test">
<title>Test</title>
<simpara>The integration tests use test repositories. Therefore, it is necessary to specify project properties for the test execution.</simpara>
<table frame="all" rowsep="1" colsep="1">
<title>Subversion test configuration</title>
<tgroup cols="3">
<colspec colname="col_1" colwidth="33*"/>
<colspec colname="col_2" colwidth="33*"/>
<colspec colname="col_3" colwidth="33*"/>
<thead>
<row>
<entry align="left" valign="top">Test Property</entry>
<entry align="left" valign="top">Description</entry>
<entry align="left" valign="top">Value</entry>
</row>
</thead>
<tbody>
<row>
<entry align="left" valign="top"><simpara><emphasis role="strong">svnurl</emphasis></simpara></entry>
<entry align="left" valign="top"><simpara>Root URL of the test project</simpara></entry>
<entry align="left" valign="top"><simpara>Must be specified with environment variable <literal>SVNURL</literal></simpara></entry>
</row>
<row>
<entry align="left" valign="top"><simpara><emphasis role="strong">svnuser</emphasis></simpara></entry>
<entry align="left" valign="top"><simpara>User name of Subversion test user</simpara></entry>
<entry align="left" valign="top"><simpara>Must be specified with environment variable <literal>SVNUSER</literal></simpara></entry>
</row>
<row>
<entry align="left" valign="top"><simpara><emphasis role="strong">svnpasswd</emphasis></simpara></entry>
<entry align="left" valign="top"><simpara>Password for Subversion test user</simpara></entry>
<entry align="left" valign="top"><simpara>Must be specified with environment variable <literal>SVNPASSWD</literal></simpara></entry>
</row>
</tbody>
</tgroup>
</table>
<table frame="all" rowsep="1" colsep="1">
<title>Git test configuration</title>
<tgroup cols="3">
<colspec colname="col_1" colwidth="33*"/>
<colspec colname="col_2" colwidth="33*"/>
<colspec colname="col_3" colwidth="33*"/>
<thead>
<row>
<entry align="left" valign="top">Test Property</entry>
<entry align="left" valign="top">Description</entry>
<entry align="left" valign="top">Value</entry>
</row>
</thead>
<tbody>
<row>
<entry align="left" valign="top"><simpara><emphasis role="strong">giturl</emphasis></simpara></entry>
<entry align="left" valign="top"><simpara>URL of the test project</simpara></entry>
<entry align="left" valign="top"><simpara>Must be specified with environment variable <literal>GITURL</literal></simpara></entry>
</row>
<row>
<entry align="left" valign="top"><simpara><emphasis role="strong">gituser</emphasis></simpara></entry>
<entry align="left" valign="top"><simpara>User name of Git test user</simpara></entry>
<entry align="left" valign="top"><simpara>Must be specified with environment variable <literal>GITUSER</literal></simpara></entry>
</row>
<row>
<entry align="left" valign="top"><simpara><emphasis role="strong">gitpasswd</emphasis></simpara></entry>
<entry align="left" valign="top"><simpara>Password for Git test user</simpara></entry>
<entry align="left" valign="top"><simpara>Must be specified with environment variable <literal>GITPASSWD</literal></simpara></entry>
</row>
</tbody>
</tgroup>
</table>
</section>
</section>
<section xml:id="asciidoc_license">
<title>License</title>
<simpara>Copyright 2014-2016 Intershop Communications.</simpara>
<simpara>Licensed 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</simpara>
<simpara><link xlink:href="http://www.apache.org/licenses/LICENSE-2.0">http://www.apache.org/licenses/LICENSE-2.0</link></simpara>
<simpara>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.</simpara>
</section>
</article>