<?xml version="1.0" encoding="UTF-8"?>
<!--

    The MIT License (MIT)

    Copyright (c) 2016 Cloudogu GmbH

    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions:

    The above copyright notice and this permission notice shall be included in all
    copies or substantial portions of the Software.

    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
    SOFTWARE.

-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>com.cloudogu.versionName</groupId>
        <artifactId>versionName-parent</artifactId>
        <version>2.0.0</version>
    </parent>

    <artifactId>versionName-examples</artifactId>
    <packaging>pom</packaging>
    <name>versionName-examples</name>

    <properties>
        <!-- Printable version name -->
        <versionName>${project.version} (${maven.build.timestamp}, branch ${scmBranch}, commit ${buildNumber})
        </versionName>
    </properties>

    <profiles>
        <profile>
            <!-- Profile that extends the printable version number by an optional build.
                It is activated when an environment variable called BUILD_NUMBER exists (as in Jenkins) -->
            <id>versionNameBuildNumber</id>
            <activation>
                <property>
                    <name>env.BUILD_NUMBER</name>
                </property>
            </activation>
            <properties>
                <!-- @formatter:off -->
                <versionName>${project.version} build #${env.BUILD_NUMBER} (${maven.build.timestamp}, branch ${scmBranch}, commit ${buildNumber})</versionName>
                <!-- @formatter:on -->
            </properties>
        </profile>
        <profile>
            <!-- For releases, use a simple version name, consisting of the version number.
                 don't add timestamp, SCM info, build number, etc. -->
            <id>versionNameForRelease</id>
            <activation>
                <property>
                    <name>performRelease</name>
                </property>
            </activation>
            <properties>
                <versionName>${project.version}</versionName>
            </properties>
        </profile>
    </profiles>

    <build>
        <plugins>
            <!-- Write the current git revision into ${buildnumber} and populate ${scmBranch} -->
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>buildnumber-maven-plugin</artifactId>
                <version>1.4</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>create</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <!-- Get the scm revision once for all modules -->
                    <getRevisionOnlyOnce>true</getRevisionOnlyOnce>
                    <!-- Don't fail on modified local resources -->
                    <doCheck>false</doCheck>
                    <!-- Don't update SCM -->
                    <doUpdate>false</doUpdate>
                    <!-- Use short version of git revision -->
                    <shortRevisionLength>7</shortRevisionLength>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <modules>
        <module>jar</module>
        <module>war</module>
        <module>server</module>
    </modules>
</project>
