<?xml version="1.0" encoding="UTF-8"?>
<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>
    <groupId>tigase</groupId>
    <artifactId>iot-hub</artifactId>
    <version>2.0-SNAPSHOT</version>
    <name>Tigase IoT Hub</name>
    <packaging>pom</packaging>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
    </properties>

    <modules>
        <module>hub-local</module>
        <module>connector</module>
        <module>documentation</module>
        <module>distribution</module>
    </modules>

    <scm>
        <connection>scm:git:https://repository.tigase.org/git/iot-xmpp-hub</connection>
        <developerConnection>scm:git:https://repository.tigase.org/git/iot-xmpp-hub</developerConnection>
        <url>https://projects.tigase.org/projects/iot-xmpp-hub/repository</url>
        <tag>HEAD</tag>
    </scm>

    <build>
        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>buildnumber-maven-plugin</artifactId>
                <version>1.1</version>
                <configuration>
                    <timestampFormat>{0,date} {0,time}</timestampFormat>
                    <doCheck>false</doCheck>
                    <doUpdate>false</doUpdate>
                    <shortRevisionLength>8</shortRevisionLength>
                </configuration>
                <executions>
                    <execution>
                        <phase>validate</phase>
                        <goals>
                            <goal>create</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.codehaus.gmaven</groupId>
                <artifactId>gmaven-plugin</artifactId>
                <version>1.5</version>
                <executions>
                    <execution>
                        <id>gitver</id>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>execute</goal>
                        </goals>
                        <configuration>
                            <providerSelection>2.0</providerSelection>
                            <properties>
                                <script>git rev-list HEAD --count</script>
                            </properties>
                            <source>
                                def version
                                try {
                                    def command = project.properties.script
                                    def process = command.execute()
                                    process.waitFor()

                                    version = process.in.text.trim()
                                } catch (Exception e) {
                                    version = '0'
                                }
                                println "setting revision to: " + version

                                project.properties.setProperty('gitVersion', version)

                            </source>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>3.0.2</version>
                <extensions>true</extensions>
                <configuration>
                    <archive>
                        <manifestEntries>
                            <Implementation-Title>${project.name}</Implementation-Title>
                            <Implementation-Version>${project.version}-b${gitVersion}/${buildNumber}
                            </Implementation-Version>
                            <Implementation-Build>${gitVersion}/${buildNumber} (${maven.build.timestamp})
                            </Implementation-Build>
                            <Tigase-Required-Dependencies>tigase.server=${project.dependencies[0].version}
                            </Tigase-Required-Dependencies>
                        </manifestEntries>
                    </archive>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <repositories>
        <repository>
            <id>tigase</id>
            <name>Tigase repository</name>
            <url>http://maven-repo.tigase.org/repository/release</url>
        </repository>
        <repository>
            <id>tigase-snapshot</id>
            <name>Tigase repository</name>
            <url>http://maven-repo.tigase.org/repository/snapshot</url>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </repository>
    </repositories>
    <distributionManagement>
        <repository>
            <id>tigase</id>
            <name>Tigase repository</name>
            <url>http://maven-repo.tigase.org/repository/release</url>
        </repository>
        <snapshotRepository>
            <id>tigase-snapshot</id>
            <name>Tigase snapshot repository</name>
            <url>http://maven-repo.tigase.org/repository/snapshot</url>
        </snapshotRepository>
    </distributionManagement>

</project>