<?xml version="1.0" encoding="UTF-8"?>
<?asciidoc-toc maxdepth="2"?>
<?asciidoc-numbered?>
<article xmlns="http://docbook.org/ns/docbook" xmlns:xl="http://www.w3.org/1999/xlink" version="5.0" xml:lang="en">
<info>
<title>SCM Version Plugin</title>
<date>2020-02-10</date>
</info>
<note>
<simpara>Version 6.0 (and later) of this plugin will only work with JDK 8, Gradle 6.X and later.
Furthermore Subversion will be not longer supported.</simpara>
</note>
<section xml:id="asciidocsummary">
<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>). Only Git is full supported and all others uses a file implementation.
But the "file" support is limited.</simpara>
<simpara>Git Branches and tags are used for the calculation of the project version.<?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="asciidocversion-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>
<section xml:id="asciidocconfiguration-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>
<section xml:id="asciidocgit-version-calculation">
<title>Git Version Calculation</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>
<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.
If no prefix is specified the plugin assumes that the branch is a feature branch. If the version is not part of the branch name,
the version is taken from the last tag.</simpara>
<section xml:id="asciidocfeature-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="asciidocstabilization-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="asciidocrelease-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="asciidocversion-calculation-on-git-summary">
<title>Version Calculation on Git - Summary</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>
</section>
<section xml:id="asciidocusage">
<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>
<details open>
<summary>Groovy</summary>
<formalpara>
<title>build.gradle</title>
<para>
<programlisting language="groovy" linenumbering="unnumbered">plugins {
    id 'com.intershop.gradle.scmversion' version '6.1.0'
}

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 {
        targetVersion = '1.0.0'
        changelogFile = new File(project.buildDir, 'changelog/changelogset.asciidoc')
    }
}

version = scm.version.version</programlisting>
</para>
</formalpara>
</details>
<details>
<summary>Kotlin</summary>
<formalpara>
<title>build.gradle.kts</title>
<para>
<programlisting language="kotlin" linenumbering="unnumbered">plugins {
    id("com.intershop.gradle.scmversion") version "6.1.0"
}

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 = File(project.buildDir, "changelog/changelogset.asciidoc")
    }
}

version = scm.version.version</programlisting>
</para>
</formalpara>
</details>
</section>
<section xml:id="asciidoctasks">
<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. This can be done over the commandline parameter <literal>--feature</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 configuration or on the commandline with the paramater <literal>--version</literal>. It is also possible to specify the short name of a
feature (command line parameter <literal>--feature</literal>) and the kind of branch (command line parameter <literal>--branchType</literal>), that should be used. 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>changelog</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 previous version. It is possible to specify a 'previous' version with the command line variable <literal>--prevVersion</literal>.<?asciidoc-br?>
The tag for this version is mandatory.</simpara></entry>
</row>
</tbody>
</tgroup>
</informaltable>
<simpara>The tasks <literal>tag</literal>, <literal>branch</literal>, <literal>toVersion</literal>, <literal>release</literal> and <literal>changelog</literal> can be started with the commandline parameter
<literal>--dryRun</literal>. If this parameters is specified no changes on the remote or local repsotiroy will be done. Only
the output will provide information over posible changes.</simpara>
<simpara>All task are part of the package <literal>'com.intershop.gradle.scm.task'</literal></simpara>
</section>
<section xml:id="asciidocproject-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="asciidocmethods">
<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">user</emphasis>(Closure&lt;ScmUser&gt;) <?asciidoc-br?>
<emphasis role="strong">user</emphasis>(Action&lt;in ScmUser&gt;)</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>(Closure&lt;ScmUser&gt;)<?asciidoc-br?>
<emphasis role="strong">key</emphasis>(Action&lt;in ScmKey&gt;)</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">prefixes</emphasis>(Closure&lt;PrefixConfig&gt;)<?asciidoc-br?>
<emphasis role="strong">prefixes</emphasis>(Action&lt;in PrefixConfig&gt;)</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">version</emphasis>(Closure&lt;VersionExtension&gt;)<?asciidoc-br?>
<emphasis role="strong">version</emphasis>(Action&lt;in VersionExtension&gt;)</simpara></entry>
<entry align="left" valign="top"><simpara><link linkend="scmversion">VersionExtension</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>(Closure&lt;ChangeLogExtension&gt;)<?asciidoc-br?>
<emphasis role="strong">changelog</emphasis>(Action&lt;in ChangeLogExtension&gt;)</simpara></entry>
<entry align="left" valign="top"><simpara><link linkend="scmchangelog">ChangeLogExtension</link></simpara></entry>
<entry align="left" valign="top"><simpara>This extension contains settings for change log configuration.</simpara></entry>
</row>
</tbody>
</tgroup>
</informaltable>
</section>
<section xml:id="asciidocproperties">
<title>Properties</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">user</emphasis></simpara></entry>
<entry align="left" valign="top"><simpara><link linkend="scmuser">ScmUser</link></simpara></entry>
<entry align="left" valign="top"></entry>
<entry align="left" valign="top"><simpara>This property contains the complete user configuration.</simpara></entry>
</row>
<row>
<entry align="left" valign="top"><simpara><emphasis role="strong">key</emphasis></simpara></entry>
<entry align="left" valign="top"><simpara><link linkend="scmkey">ScmKey</link></simpara></entry>
<entry align="left" valign="top"></entry>
<entry align="left" valign="top"><simpara>This property contains the complete SSH key configuration.</simpara></entry>
</row>
<row>
<entry align="left" valign="top"><simpara><emphasis role="strong">prefixes</emphasis></simpara></entry>
<entry align="left" valign="top"><simpara><link linkend="prefixconfig">PrefixConfig</link></simpara></entry>
<entry align="left" valign="top"></entry>
<entry align="left" valign="top"><simpara>This is the container for the prefix configuration.</simpara></entry>
</row>
<row>
<entry align="left" valign="top"><simpara><emphasis role="strong">scmType</emphasis></simpara></entry>
<entry align="left" valign="top"><simpara>ScmType</simpara></entry>
<entry align="left" valign="top"></entry>
<entry align="left" valign="top"><simpara>This is the value for the identified SCM ( GIT, FILE )</simpara></entry>
</row>
<row>
<entry align="left" valign="top"><simpara><emphasis role="strong">localService</emphasis></simpara></entry>
<entry align="left" valign="top"><simpara>ScmLocalService</simpara></entry>
<entry align="left" valign="top"></entry>
<entry align="left" valign="top"><simpara>This sevices contains all main necessary methods for the working copy.</simpara></entry>
</row>
<row>
<entry align="left" valign="top"><simpara><emphasis role="strong">version</emphasis></simpara></entry>
<entry align="left" valign="top"><simpara><link linkend="scmversion">VersionExtension</link></simpara></entry>
<entry align="left" valign="top"></entry>
<entry align="left" valign="top"><simpara>This is the configuration for the version calculation.</simpara></entry>
</row>
<row>
<entry align="left" valign="top"><simpara><emphasis role="strong">changelog</emphasis></simpara></entry>
<entry align="left" valign="top"><simpara><link linkend="scmchangelog">ChangeLogExtension</link></simpara></entry>
<entry align="left" valign="top"></entry>
<entry align="left" valign="top"><simpara>This is the configuration for the change log task.</simpara></entry>
</row>
</tbody>
</tgroup>
</informaltable>
<section xml:id="asciidocauthentication">
<title>Authentication</title>
<section xml:id="asciidocuser-object-user-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 environment variable <literal>SCM_USERNAME</literal> or project or system 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 environment variable <literal>SCM_PASSWORD</literal> or project or system property <literal>scmUserPasswd</literal>.</emphasis></simpara></entry>
</row>
</tbody>
</tgroup>
</informaltable>
</section>
<section xml:id="asciidocssh-key-object-key-scmkey-only-for-git">
<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 environment variable <literal>SCM_KEYFILE</literal> or project or system 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 environment variable <literal>SCM_KEYPASSPHRASE</literal> or project or system property <literal>scmKeyPassphrase</literal>.</emphasis></simpara></entry>
</row>
</tbody>
</tgroup>
</informaltable>
</section>
</section>
<section xml:id="asciidocprefix-configuration-prefixes-prefixconfig">
<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>
<row>
<entry align="left" valign="top"><simpara><emphasis role="strong">branchPrefixSeperator</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>Separator between prefix and branch version</simpara></entry>
</row>
<row>
<entry align="left" valign="top"><simpara><emphasis role="strong">tagPrefixSeperator</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>Separator between prefix and tag version</simpara></entry>
</row>
</tbody>
</tgroup>
</informaltable>
</section>
<section xml:id="asciidocversion-object-version-versionextension">
<title>Version object 'version' (<literal>VersionExtension</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">versionService</emphasis></simpara></entry>
<entry align="left" valign="top"><simpara><literal>ScmVersionService</literal></simpara></entry>
<entry align="left" valign="top"></entry>
<entry align="left" valign="top"></entry>
<entry align="left" valign="top"><simpara>This service contains methods and properties
for the calculation of version objects from the working copy.</simpara></entry>
</row>
<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">versionType</emphasis></simpara></entry>
<entry align="left" valign="top"><simpara><literal>VersionType</literal></simpara></entry>
<entry align="left" valign="top"></entry>
<entry align="left" valign="top"><simpara><emphasis role="strong">read only</emphasis></simpara></entry>
<entry align="left" valign="top"><simpara>Get the VersionType object from the configured type.</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 system property <literal>scmVersionExt</literal> is used for the return value.</simpara></entry>
</row>
<row>
<entry align="left" valign="top"><simpara><emphasis role="strong">versionBranch</emphasis></simpara></entry>
<entry align="left" valign="top"><simpara><literal>String</literal></simpara></entry>
<entry align="left" valign="top"><simpara>'TAG'</simpara></entry>
<entry align="left" valign="top"><simpara>'TAG' + 'BRANCH'</simpara></entry>
<entry align="left" valign="top"><simpara>Set the version branch configuration of the version calculation. The branch which is primarily used for the version calculation. This can be branch or tag.</simpara></entry>
</row>
<row>
<entry align="left" valign="top"><simpara><emphasis role="strong">versionBranchType</emphasis></simpara></entry>
<entry align="left" valign="top"><simpara><literal>BranchType</literal></simpara></entry>
<entry align="left" valign="top"><simpara>'BranchType.TAG'</simpara></entry>
<entry align="left" valign="top"><simpara><emphasis role="strong">read only</emphasis></simpara></entry>
<entry align="left" valign="top"><simpara>This get the calculated BranchType object from versionBranch configuration.</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">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">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">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 environment variable <literal>INCREMENT</literal>, or system 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">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, 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.</simpara></entry>
</row>
<row>
<entry align="left" valign="top"><simpara><emphasis role="strong">disableRevExt</emphasis></simpara></entry>
<entry align="left" valign="top"></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>
</row>
<row>
<entry align="left" valign="top"><simpara>With this configuration the extension of the rev id in special cases can be disabled. It is possible to set
this configuration with the environment variable 'SCM_DISABLE_REVIDEXT' or the system or project property 'scmDisableRevIdExt'.</simpara></entry>
<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>
</row>
<row>
<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 system property <literal>'continuousRelease'</literal>.</simpara></entry>
<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>
</row>
</tbody>
</tgroup>
</informaltable>
</section>
<section xml:id="asciidocchangelog-object-changelog-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>
</tbody>
</tgroup>
</informaltable>
<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>
</tgroup>
</informaltable>
</section>
</section>
</section>
<section xml:id="asciidocexample-configurations">
<title>Example Configurations</title>
<section xml:id="asciidocsimple-configuration">
<title>Simple Configuration</title>
<programlisting language="groovy" linenumbering="unnumbered">plugins {
    id 'com.intershop.gradle.scmversion' version '6.1.0'
}


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

version = scm.version.version</programlisting>
</section>
<section xml:id="asciidocgradle-properties-with-authentication-configuration">
<title>gradle.properties with Authentication Configuration</title>
<simpara>This configuration works for Git [http(s)]. 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 Git [ssh] 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="asciidocsimple-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 '6.1.0'
}

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 -PscmVersionExt=SNAPSHOT</programlisting>
</para>
</formalpara>
<formalpara>
<title>release build:</title>
<para>
<programlisting language="properties" linenumbering="unnumbered">./gradlew publish -PscmVersionExt=RELEASE</programlisting>
</para>
</formalpara>
<note>
<simpara>After a release it is necessary to change the version manually.</simpara>
</note>
</section>
<section xml:id="asciidoctest">
<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>Git test configuration</title>
<tgroup cols="3">
<colspec colname="col_1" colwidth="33.3333*"/>
<colspec colname="col_2" colwidth="33.3333*"/>
<colspec colname="col_3" colwidth="33.3334*"/>
<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="asciidoclicense">
<title>License</title>
<simpara>Copyright 2014-2020 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 xl: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>