<?xml version="1.0" encoding="UTF-8"?>
<!--
  ~ Copyright 2019 ABSA Group Limited
  ~
  ~ 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
  ~
  ~     http://www.apache.org/licenses/LICENSE-2.0
  ~
  ~ 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.
  -->

<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>za.co.absa.spline</groupId>
        <artifactId>parent-pom</artifactId>
        <relativePath>../build/parent-pom/pom.xml</relativePath>
        <version>0.8.2</version>
    </parent>

    <artifactId>rest-gateway</artifactId>
    <packaging>war</packaging>

    <name>Spline REST Gateway</name>

    <properties>
        <swagger.docs.path>${project.build.directory}/api/docs</swagger.docs.path>
        <timestamp>${maven.build.timestamp}</timestamp>
        <maven.build.timestamp.format>yyyy-MM-dd'T'HH:mm:ssX</maven.build.timestamp.format>
        <dockerfile.imageName>spline-rest-server</dockerfile.imageName>
    </properties>

    <dependencies>
        <dependency>
            <groupId>za.co.absa.spline</groupId>
            <artifactId>commons</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>za.co.absa.spline</groupId>
            <artifactId>consumer-rest-core</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>za.co.absa.spline</groupId>
            <artifactId>producer-rest-core</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-classic</artifactId>
        </dependency>
    </dependencies>

    <build>
        <finalName>spline-rest-server-${project.version}</finalName>
        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>3.5.0</version>
                <dependencies>
                    <dependency>
                        <groupId>za.co.absa.utils</groupId>
                        <artifactId>rest-api-doc-generator_${scala.compat.version}</artifactId>
                        <version>1.1.2</version>
                    </dependency>
                </dependencies>
                <configuration>
                    <includePluginDependencies>true</includePluginDependencies>
                    <executable>java</executable>
                    <arguments combine.children="append">
                        <argument>--add-opens=java.base/sun.net.www.protocol.jar=ALL-UNNAMED</argument>
                        <argument>-classpath</argument>
                        <classpath />
                        <argument>za.co.absa.rapidgen.RapidGenCLI</argument>
                    </arguments>
                </configuration>
                <executions>
                    <execution>
                        <id>gen-swagger-consumer-json</id>
                        <phase>process-classes</phase>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                        <configuration>
                            <arguments>
                                <argument>swagger</argument>
                                <argument>-o</argument>
                                <argument>${swagger.docs.path}/producer.swagger.json</argument>
                                <argument>za.co.absa.spline.producer.rest.ProducerRESTConfig</argument>
                            </arguments>
                        </configuration>
                    </execution>
                    <execution>
                        <id>gen-swagger-producer-json</id>
                        <phase>process-classes</phase>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                        <configuration>
                            <arguments>
                                <argument>swagger</argument>
                                <argument>-o</argument>
                                <argument>${swagger.docs.path}/consumer.swagger.json</argument>
                                <argument>za.co.absa.spline.consumer.rest.ConsumerRESTConfig</argument>
                            </arguments>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>com.github.eirslett</groupId>
                <artifactId>frontend-maven-plugin</artifactId>
                <configuration>
                    <skip>false</skip>
                </configuration>
                <executions>
                    <execution>
                        <id>gen-swagger-docs</id>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>npm</goal>
                        </goals>
                        <configuration>
                            <arguments>run gen-api-doc:all --docs_dir=${swagger.docs.path}</arguments>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>3.2.3</version>
                <configuration>
                    <failOnMissingWebXml>false</failOnMissingWebXml>
                    <archive>
                        <manifestEntries>
                            <Build-Time>${maven.build.timestamp}</Build-Time>
                        </manifestEntries>
                    </archive>
                    <webResources>
                        <resource>
                            <directory>${project.build.directory}/api/</directory>
                        </resource>
                    </webResources>
                </configuration>
            </plugin>
            <plugin>
                <groupId>io.fabric8</groupId>
                <artifactId>docker-maven-plugin</artifactId>
                <configuration>
                    <skip>false</skip>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>
