<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/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>${groupId}</groupId>
    <artifactId>${artifactId}</artifactId>
    <name>${appName}</name>
    <version>${version}</version>
    <packaging>war</packaging>

    <scm>
        <!-- TODO: Change this to your SCM URL -->
        <connection>scm:git:https://github.com/strolch-li/strolch.git</connection>
        <developerConnection>scm:git:https://github.com/strolch-li/strolch.git</developerConnection>
        <url>https://github.com/strolch-li/strolch</url>
    </scm>

    <properties>
        <appFinalName>${artifactId}</appFinalName>
        <warFinalName>${artifactId}</warFinalName>

        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.build.timestamp.format>yyyy-MM-dd HH:mm:ss</maven.build.timestamp.format>
        <buildTimestamp>${maven.build.timestamp}</buildTimestamp>

        <jdk.version>17</jdk.version>

        <!-- compile time dependencies -->
        <slf4j.version>1.7.30</slf4j.version>
        <logback.version>1.2.9</logback.version>
        <jersey.version>2.34</jersey.version>
        <gson.version>2.8.9</gson.version>
        <hikaricp.version>5.0.0</hikaricp.version>
        <postgresql.version>42.4.1</postgresql.version>
        <antlr.version>4.9.3</antlr.version>
        <annotation.version>1.3.2</annotation.version>
        <activation.version>1.1.1</activation.version>
        <javaxmail.version>1.6.2</javaxmail.version>
        <serverlet.version>4.0.1</serverlet.version>
        <jaxrs.api.version>2.1.1</jaxrs.api.version>
        <jaxrs.ri.version>2.35</jaxrs.ri.version>
        <jaxb.api.version>2.3.1</jaxb.api.version>
        <jaxws.version>2.3.3</jaxws.version>
        <jakarta.jws-api.version>2.1.0</jakarta.jws-api.version>
        <jaxp.version>1.4.2</jaxp.version>
        <tyrus.version>1.17</tyrus.version>
        <grizzly.version>2.4.4</grizzly.version>
        <websocket.version>1.1</websocket.version>
        <sax.version>2.0.1</sax.version>
        <csv.version>1.9.0</csv.version>
        <cron.version>1.6.2</cron.version>

        <!-- test time dependencies -->
        <junit.version>4.13.2</junit.version>
        <hamcrest.version>2.2</hamcrest.version>

        <!-- strolch -->
        <strolch.version>1.8.0-SNAPSHOT</strolch.version>

        <!-- maven plug-in dependencies -->
        <maven-scm-plugin.version>1.12.2</maven-scm-plugin.version>
        <buildnumber-maven-plugin.version>3.0.0</buildnumber-maven-plugin.version>
        <versions-maven-plugin.version>2.8.1</versions-maven-plugin.version>
        <maven-compiler-plugin.version>3.8.1</maven-compiler-plugin.version>
        <maven-source-plugin.version>3.2.1</maven-source-plugin.version>
        <maven-site-plugin.version>3.10.0</maven-site-plugin.version>
        <maven-eclipse-plugin.version>2.10</maven-eclipse-plugin.version>
        <maven-jar-plugin.version>3.2.0</maven-jar-plugin.version>
        <maven-war-plugin.version>3.3.2</maven-war-plugin.version>
        <tomcat7-maven-plugin.version>2.2</tomcat7-maven-plugin.version>
        <maven-javadoc-plugin.version>3.3.1</maven-javadoc-plugin.version>
        <maven-deploy-plugin.version>3.0.0-M2</maven-deploy-plugin.version>
        <maven-resources-plugin.version>3.2.0</maven-resources-plugin.version>
        <maven-dependency-plugin.version>3.2.0</maven-dependency-plugin.version>
        <maven-assembly-plugin.version>3.3.0</maven-assembly-plugin.version>
        <maven-project-info-reports-plugin.version>3.1.2</maven-project-info-reports-plugin.version>
        <maven-gpg-plugin.version>3.0.1</maven-gpg-plugin.version>
        <nexus-staging-maven-plugin.version>1.6.12</nexus-staging-maven-plugin.version>
        <maven-surefire-plugin.version>2.22.2</maven-surefire-plugin.version>
        <exec-maven-plugin.version>3.0.0</exec-maven-plugin.version>
        <archetype-packaging.version>3.2.0</archetype-packaging.version>
        <maven-clean-plugin.version>3.2.0</maven-clean-plugin.version>

    </properties>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>li.strolch</groupId>
                <artifactId>li.strolch.bom</artifactId>
                <type>pom</type>
                <version>${strolch.version}</version>
                <scope>import</scope>
            </dependency>

            <dependency>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-api</artifactId>
                <version>${slf4j.version}</version>
            </dependency>
            <dependency>
                <groupId>ch.qos.logback</groupId>
                <artifactId>logback-classic</artifactId>
                <version>${logback.version}</version>
                <scope>runtime</scope>
            </dependency>

            <dependency>
                <groupId>com.google.code.gson</groupId>
                <artifactId>gson</artifactId>
                <version>${gson.version}</version>
            </dependency>

            <!-- Restful API -->
            <dependency>
                <groupId>javax.xml.bind</groupId>
                <artifactId>jaxb-api</artifactId>
                <version>${jaxb.api.version}</version>
            </dependency>
            <dependency>
                <groupId>javax.servlet</groupId>
                <artifactId>javax.servlet-api</artifactId>
                <version>${serverlet.version}</version>
                <scope>provided</scope>
            </dependency>
            <dependency>
                <groupId>javax.ws.rs</groupId>
                <artifactId>javax.ws.rs-api</artifactId>
                <version>${jaxrs.api.version}</version>
            </dependency>
            <dependency>
                <groupId>org.glassfish.jersey.bundles</groupId>
                <artifactId>jaxrs-ri</artifactId>
                <version>${jaxrs.ri.version}</version>
            </dependency>
            <dependency>
                <groupId>org.glassfish.jersey</groupId>
                <artifactId>jersey-bom</artifactId>
                <version>${jersey.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
            <dependency>
                <groupId>org.glassfish.tyrus</groupId>
                <artifactId>tyrus-client</artifactId>
                <version>${tyrus.version}</version>
            </dependency>
            <dependency>
                <groupId>org.glassfish.tyrus</groupId>
                <artifactId>tyrus-container-grizzly-client</artifactId>
                <version>${tyrus.version}</version>
            </dependency>
            <dependency>
                <groupId>org.glassfish.tyrus</groupId>
                <artifactId>tyrus-container-grizzly-server</artifactId>
                <version>${tyrus.version}</version>
            </dependency>
            <dependency>
                <groupId>org.glassfish.grizzly</groupId>
                <artifactId>grizzly-framework</artifactId>
                <version>${grizzly.version}</version>
            </dependency>

            <!-- websocket -->
            <dependency>
                <groupId>javax.websocket</groupId>
                <artifactId>javax.websocket-api</artifactId>
                <version>${websocket.version}</version>
                <scope>provided</scope>
            </dependency>

            <!-- test -->
            <dependency>
                <groupId>junit</groupId>
                <artifactId>junit</artifactId>
                <version>${junit.version}</version>
                <scope>test</scope>
            </dependency>
            <dependency>
                <groupId>org.hamcrest</groupId>
                <artifactId>hamcrest-core</artifactId>
                <version>${hamcrest.version}</version>
                <scope>test</scope>
            </dependency>
            <dependency>
                <groupId>org.hamcrest</groupId>
                <artifactId>hamcrest-library</artifactId>
                <version>${hamcrest.version}</version>
                <scope>test</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <dependencies>

        <!-- base -->
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
        </dependency>
        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-classic</artifactId>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>com.google.code.gson</groupId>
            <artifactId>gson</artifactId>
        </dependency>

        <!-- strolch -->
        <dependency>
            <groupId>li.strolch</groupId>
            <artifactId>li.strolch.model</artifactId>
        </dependency>
        <dependency>
            <groupId>li.strolch</groupId>
            <artifactId>li.strolch.agent</artifactId>
        </dependency>
        <dependency>
            <groupId>li.strolch</groupId>
            <artifactId>li.strolch.rest</artifactId>
        </dependency>
        <dependency>
            <groupId>li.strolch</groupId>
            <artifactId>li.strolch.service</artifactId>
        </dependency>
        <dependency>
            <groupId>li.strolch</groupId>
            <artifactId>li.strolch.testbase</artifactId>
            <scope>test</scope>
        </dependency>

        <!-- web -->
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
        </dependency>
        <dependency>
            <groupId>javax.websocket</groupId>
            <artifactId>javax.websocket-api</artifactId>
        </dependency>
        <dependency>
            <groupId>org.glassfish.jersey.bundles</groupId>
            <artifactId>jaxrs-ri</artifactId>
        </dependency>
        <dependency>
            <groupId>org.glassfish.tyrus</groupId>
            <artifactId>tyrus-client</artifactId>
        </dependency>
        <dependency>
            <groupId>org.glassfish.tyrus</groupId>
            <artifactId>tyrus-container-grizzly-client</artifactId>
        </dependency>
        <dependency>
            <groupId>org.glassfish.grizzly</groupId>
            <artifactId>grizzly-framework</artifactId>
        </dependency>

        <!-- testing -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.hamcrest</groupId>
            <artifactId>hamcrest-core</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.hamcrest</groupId>
            <artifactId>hamcrest-library</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <finalName>${appFinalName}</finalName>

        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
                <includes>
                    <include>**/*.properties</include>
                    <include>StrolchBootstrap.xml</include>
                </includes>
            </resource>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>false</filtering>
                <excludes>
                    <exclude>**/*.properties</exclude>
                    <exclude>StrolchBootstrap.xml</exclude>
                </excludes>
            </resource>
        </resources>

        <plugins>

            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>buildnumber-maven-plugin</artifactId>
                <version>${buildnumber-maven-plugin.version}</version>
                <executions>
                    <execution>
                        <phase>validate</phase>
                        <goals>
                            <goal>create</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <doCheck>false</doCheck>
                    <doUpdate>false</doUpdate>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>${maven-compiler-plugin.version}</version>
                <configuration>
                    <source>${jdk.version}</source>
                    <target>${jdk.version}</target>
                    <showDeprecation>true</showDeprecation>
                    <showWarnings>true</showWarnings>
                    <compilerArgument>-Xlint:all</compilerArgument>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>${maven-war-plugin.version}</version>
                <configuration>
                    <failOnMissingWebXml>false</failOnMissingWebXml>
                    <warName>${warFinalName}</warName>
                </configuration>
            </plugin>

        </plugins>
    </build>

    <profiles>

        <!-- for dev: always enable strolch environment "dev" -->
        <profile>
            <id>dev.local</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <properties>
                <strolch.env>dev.local</strolch.env>
            </properties>
        </profile>

        <profile>
            <id>release</id>
            <activation>
                <activeByDefault>false</activeByDefault>
            </activation>
            <build>
                <plugins>

                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-clean-plugin</artifactId>
                        <version>${maven-clean-plugin.version}</version>
                        <configuration>
                            <filesets>
                                <fileset>
                                    <directory>src/main/webapp/app/bower_components</directory>
                                    <includes>
                                        <include>**</include>
                                    </includes>
                                    <followSymlinks>false</followSymlinks>
                                </fileset>
                            </filesets>
                        </configuration>
                    </plugin>

                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>exec-maven-plugin</artifactId>
                        <version>${exec-maven-plugin.version}</version>
                        <executions>
                            <execution>
                                <id>exec-npm-install</id>
                                <phase>generate-sources</phase>
                                <configuration>
                                    <executable>npm</executable>
                                    <arguments>
                                        <argument>install</argument>
                                    </arguments>
                                    <workingDirectory>${basedir}/src/main/webapp</workingDirectory>
                                </configuration>
                                <goals>
                                    <goal>exec</goal>
                                </goals>
                            </execution>
                            <execution>
                                <id>exec-gulp</id>
                                <phase>generate-sources</phase>
                                <configuration>
                                    <executable>gulp</executable>
                                    <workingDirectory>${basedir}/src/main/webapp</workingDirectory>
                                </configuration>
                                <goals>
                                    <goal>exec</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>

                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-war-plugin</artifactId>
                        <configuration>
                            <failOnMissingWebXml>false</failOnMissingWebXml>
                            <warName>${warFinalName}</warName>
                            <packagingExcludes>app/**/*,node_modules/**/*</packagingExcludes>
                        </configuration>
                    </plugin>

                </plugins>
            </build>
        </profile>

    </profiles>
</project>
