<?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>org.carlspring.logging</groupId>
    <artifactId>logback-configuration-rest</artifactId>
    <version>1.0</version>
    <packaging>jar</packaging>

    <name>Logging Configuration: REST API</name>
    <description>A REST API for the logback configuration library.</description>

    <url>https://github.com/carlspring/logback-configuration</url>

    <licenses>
        <license>
            <name>Apache 2.0</name>
            <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
            <distribution>repo</distribution>
            <comments>A business-friendly OSS license</comments>
        </license>
    </licenses>

    <developers>
        <developer>
            <name>Martin Todorov</name>
            <email>carlspring@gmail.com</email>
        </developer>
        <developer>
            <name>Yougeshwar Khatri</name>
            <email>ypkkhatri@gmail.com</email>
        </developer>
    </developers>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

        <version.jersey>2.22.2</version.jersey>
        <version.jetty>9.3.2.v20150730</version.jetty>

        <version.jcl>1.7.25</version.jcl>
        <version.slf4j>1.7.24</version.slf4j>
        <version.logback>1.2.3</version.logback>

        <version.spring>5.1.5.RELEASE</version.spring>
    </properties>

    <scm>
        <connection>scm:git:git@github.com:carlspring/logback-configuration.git</connection>
        <url>scm:git:git@github.com:carlspring/logback-configuration.git</url>
        <developerConnection>scm:git:git@github.com:carlspring/logback-configuration.git</developerConnection>
        <tag>HEAD</tag>
    </scm>

    <build>
        <resources>
            <resource>
                <directory>${basedir}/src/main/resources</directory>
            </resource>
            <resource>
                <directory>${basedir}</directory>
                <includes>
                    <include>README</include>
                    <include>TODO</include>
                    <include>USAGE</include>
                </includes>
            </resource>
        </resources>
        <testResources>
            <testResource>
                <directory>${basedir}/src/test/resources</directory>
                <filtering>true</filtering>
            </testResource>
        </testResources>

        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>

                <configuration>
                    <debug>true</debug>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-source-plugin</artifactId>
                <version>2.2.1</version>

                <executions>
                    <execution>
                        <id>attach-sources</id>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <dependencies>
        <dependency>
            <groupId>org.carlspring.logging</groupId>
            <artifactId>logback-configuration-core</artifactId>
            <version>${project.version}</version>
        </dependency>

        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>2.5</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpclient</artifactId>
            <version>4.5.3</version>
            <scope>test</scope>
            <exclusions>
                <!-- Exclude Commons Logging -->
                <exclusion>
                    <groupId>commons-logging</groupId>
                    <artifactId>commons-logging</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.glassfish.jersey.core</groupId>
            <artifactId>jersey-common</artifactId>
            <version>${version.jersey}</version>
        </dependency>
        <dependency>
            <groupId>org.glassfish.jersey.containers</groupId>
            <artifactId>jersey-container-servlet-core</artifactId>
            <version>${version.jersey}</version>
        </dependency>
        <dependency>
            <groupId>org.glassfish.jersey.core</groupId>
            <artifactId>jersey-client</artifactId>
            <version>${version.jersey}</version>
        </dependency>
        <dependency>
            <groupId>org.glassfish.jersey.connectors</groupId>
            <artifactId>jersey-apache-connector</artifactId>
            <version>${version.jersey}</version>
        </dependency>
        <dependency>
            <groupId>org.glassfish.jersey.ext</groupId>
            <artifactId>jersey-spring3</artifactId>
            <version>${version.jersey}</version>
            <exclusions>
                <exclusion>
                    <groupId>org.springframework</groupId>
                    <artifactId>spring-web</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.springframework</groupId>
                    <artifactId>spring-beans</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.springframework</groupId>
                    <artifactId>spring-core</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-beans</artifactId>
            <version>${version.spring}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>${version.spring}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
            <version>${version.spring}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
            <version>${version.spring}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-test</artifactId>
            <version>${version.spring}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <distributionManagement>
        <repository>
            <id>sonatype-staging</id>
            <url>https://oss.sonatype.org/service/local/staging/deploy/maven2</url>
        </repository>
        <snapshotRepository>
            <id>sonatype-snapshots</id>
            <url>https://oss.sonatype.org/content/repositories/snapshots</url>
        </snapshotRepository>
    </distributionManagement>

    <profiles>
        <!-- These two profiles need to be on top: -->
        <profile>
            <id>reserve-ports</id>
            <activation>
                <activeByDefault>false</activeByDefault>
            </activation>

            <build>
                <plugins>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>build-helper-maven-plugin</artifactId>
                        <version>1.10</version>

                        <executions>
                            <execution>
                                <id>reserve-network-port</id>
                                <goals>
                                    <goal>reserve-network-port</goal>
                                </goals>
                                <phase>initialize</phase>
                                <configuration>
                                    <portNames>
                                        <portName>port.jetty.listen</portName>
                                        <portName>port.jetty.shutdown</portName>
                                    </portNames>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>set-default-ports</id>
            <activation>
                <property>
                    <name>skipTests</name>
                    <value>!true</value>
                </property>

                <activeByDefault>true</activeByDefault>
            </activation>

            <properties>
                <!-- Default ports for local development: -->
                <port.jetty.listen>48080</port.jetty.listen>
                <port.jetty.shutdown>19081</port.jetty.shutdown>
            </properties>
        </profile>
        <!-- These two profiles need to be on top. -->

        <profile>
            <!-- Required for the sake of the integration tests: -->
            <id>set-logging-host-default</id>
            <activation>
                <property>
                    <name>!logging.host</name>
                </property>
            </activation>

            <properties>
                <logging.host>localhost</logging.host>
            </properties>
        </profile>
        <profile>
            <id>set-logging-host</id>
            <activation>
                <property>
                    <name>logging.host</name>
                </property>
            </activation>

            <properties>
                <logging.host>${logging.host}</logging.host>
            </properties>
        </profile>
        <profile>
            <!-- Required for the sake of the integration tests: -->
            <id>set-logging-port-default</id>
            <activation>
                <property>
                    <name>!logging.port</name>
                </property>
            </activation>

            <properties>
                <logging.port>${port.jetty.listen}</logging.port>
            </properties>
        </profile>

        <profile>
            <id>run-it-tests</id>
            <activation>
                <property>
                    <name>!skipTests</name>
                </property>
            </activation>

            <build>
                <plugins>
                    <plugin>
                        <groupId>org.eclipse.jetty</groupId>
                        <artifactId>jetty-maven-plugin</artifactId>

                        <configuration>
                            <daemon>true</daemon>

                            <webApp>
                                <contextPath>/</contextPath>
                                <descriptor>${basedir}/src/test/webapp/WEB-INF/web.xml</descriptor>
                            </webApp>

                            <stopPort>${port.jetty.shutdown}</stopPort>
                            <stopKey>53AS9DS1FD8E3WEFEW9GR1ER8G2ER0WE31</stopKey>
                            <stopWait>10</stopWait>
                            <useTestClasspath>true</useTestClasspath>

                            <httpConnector>
                                <port>${port.jetty.listen}</port>
                            </httpConnector>

                            <useTestScope>true</useTestScope>

                            <systemProperties>
                                <force>true</force>

                                <systemProperty>
                                    <name>logging.dir</name>
                                    <value>${project.build.directory}/logs</value>
                                </systemProperty>
                            </systemProperties>
                        </configuration>

                        <executions>
                            <execution>
                                <id>jetty-stop</id>

                                <phase>test</phase>
                                <goals>
                                    <goal>stop</goal>
                                </goals>
                            </execution>
                        </executions>

                        <dependencies>
                            <dependency>
                                <groupId>org.eclipse.jetty</groupId>
                                <artifactId>jetty-util</artifactId>
                                <version>${version.jetty}</version>
                            </dependency>
                            <dependency>
                                <groupId>org.eclipse.jetty</groupId>
                                <artifactId>jetty-runner</artifactId>
                                <version>${version.jetty}</version>
                            </dependency>
                        </dependencies>
                    </plugin>

                    <!-- JUnit 5 requires Surefire version 2.22.1 or higher -->
                    <plugin>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <version>2.22.1</version>
                        <configuration>
                            <systemPropertyVariables>
                                <logging.host>${logging.host}</logging.host>
                                <logging.port>${logging.port}</logging.port>
                                <logging.dir>${project.build.directory}/logs</logging.dir>
                                <logback.configurationFile>logback.xml</logback.configurationFile>
                            </systemPropertyVariables>
                        </configuration>
                    </plugin>

                </plugins>
            </build>
        </profile>
        <profile>
            <id>jetty-start</id>
            <activation>
                <property>
                    <name>!jetty.block</name>
                </property>
            </activation>

            <build>
                <plugins>
                    <plugin>
                        <groupId>org.eclipse.jetty</groupId>
                        <artifactId>jetty-maven-plugin</artifactId>
                        <version>${version.jetty}</version>

                        <configuration>
                            <daemon>true</daemon>
                        </configuration>

                        <executions>
                            <execution>
                                <id>jetty-start</id>

                                <phase>test-compile</phase>
                                <goals>
                                    <goal>start</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>jetty-block</id>
            <activation>
                <property>
                    <name>jetty.block</name>
                </property>
            </activation>

            <build>
                <plugins>
                    <plugin>
                        <groupId>org.eclipse.jetty</groupId>
                        <artifactId>jetty-maven-plugin</artifactId>
                        <version>${version.jetty}</version>

                        <configuration>
                            <daemon>false</daemon>
                        </configuration>

                        <executions>
                            <execution>
                                <id>jetty-run</id>

                                <phase>test-compile</phase>
                                <goals>
                                    <goal>run</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <profile>
            <id>sign-artifacts</id>
            <activation>
                <activeByDefault>false</activeByDefault>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-javadoc-plugin</artifactId>
                        <version>3.1.0</version>
                        <executions>
                            <execution>
                                <phase>package</phase>
                                <goals>
                                    <goal>jar</goal>
                                </goals>
                                <configuration>
                                    <doclint>none</doclint>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-gpg-plugin</artifactId>
                        <version>1.6</version>
                        <executions>
                            <execution>
                                <id>sign-artifacts</id>
                                <phase>verify</phase>
                                <goals>
                                    <goal>sign</goal>
                                </goals>
                                <configuration>
                                    <keyname>${gpg.keyid}</keyname>
                                    <gpgArguments>
                                        <arg>--pinentry-mode</arg>
                                        <arg>loopback</arg>
                                        <arg>--passphrase-file</arg>
                                        <arg>${gpg.passfile}</arg>
                                    </gpgArguments>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

</project>
