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

    Copyright (C) 2015 The Gravitee team (http://gravitee.io)

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

    <parent>
        <groupId>io.gravitee.apim.gateway.standalone</groupId>
        <artifactId>gravitee-apim-gateway-standalone</artifactId>
        <version>3.13.2</version>
    </parent>

    <artifactId>gravitee-apim-gateway-standalone-container</artifactId>
    <name>Gravitee.io APIM - Gateway - Standalone - Container</name>

    <properties>
        <jetty94.wiremock.version>9.4.41.v20210516</jetty94.wiremock.version>
        <gravitee-connector-http.version>1.0.0</gravitee-connector-http.version>
    </properties>

    <dependencyManagement>
        <dependencies>
            <!-- Need to downgrade jetty to a compatible version with wiremock (jetty is only use for tests purpose) -->
            <dependency>
                <groupId>org.eclipse.jetty</groupId>
                <artifactId>jetty-server</artifactId>
                <version>${jetty94.wiremock.version}</version>
            </dependency>
            <dependency>
                <groupId>org.eclipse.jetty</groupId>
                <artifactId>jetty-http</artifactId>
                <version>${jetty94.wiremock.version}</version>
            </dependency>
            <dependency>
                <groupId>org.eclipse.jetty</groupId>
                <artifactId>jetty-util</artifactId>
                <version>${jetty94.wiremock.version}</version>
            </dependency>
            <dependency>
                <groupId>org.eclipse.jetty</groupId>
                <artifactId>jetty-io</artifactId>
                <version>${jetty94.wiremock.version}</version>
            </dependency>
            <dependency>
                <groupId>org.eclipse.jetty</groupId>
                <artifactId>jetty-servlet</artifactId>
                <version>${jetty94.wiremock.version}</version>
            </dependency>
            <dependency>
                <groupId>org.eclipse.jetty</groupId>
                <artifactId>jetty-servlets</artifactId>
                <version>${jetty94.wiremock.version}</version>
            </dependency>
            <dependency>
                <groupId>org.eclipse.jetty</groupId>
                <artifactId>jetty-continuation</artifactId>
                <version>${jetty94.wiremock.version}</version>
            </dependency>
            <dependency>
                <groupId>org.eclipse.jetty</groupId>
                <artifactId>jetty-security</artifactId>
                <version>${jetty94.wiremock.version}</version>
            </dependency>
            <dependency>
                <groupId>org.eclipse.jetty</groupId>
                <artifactId>jetty-webapp</artifactId>
                <version>${jetty94.wiremock.version}</version>
            </dependency>
            <dependency>
                <groupId>org.eclipse.jetty</groupId>
                <artifactId>jetty-xml</artifactId>
                <version>${jetty94.wiremock.version}</version>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <dependencies>
        <!-- Gravitee.io -->
        <dependency>
            <groupId>io.gravitee.node</groupId>
            <artifactId>gravitee-node-container</artifactId>
        </dependency>

        <dependency>
            <groupId>io.gravitee.node</groupId>
            <artifactId>gravitee-node-api</artifactId>
        </dependency>

        <dependency>
            <groupId>io.gravitee.node</groupId>
            <artifactId>gravitee-node-cluster</artifactId>
        </dependency>

        <dependency>
            <groupId>io.gravitee.node</groupId>
            <artifactId>gravitee-node-vertx</artifactId>
        </dependency>

        <dependency>
            <groupId>io.gravitee.apim.gateway</groupId>
            <artifactId>gravitee-apim-gateway-reactor</artifactId>
            <version>${project.version}</version>
        </dependency>

        <dependency>
            <groupId>io.gravitee.apim.gateway.handlers</groupId>
            <artifactId>gravitee-apim-gateway-handlers-api</artifactId>
            <version>${project.version}</version>
        </dependency>

        <dependency>
            <groupId>io.gravitee.apim.gateway</groupId>
            <artifactId>gravitee-apim-gateway-platform</artifactId>
            <version>${project.version}</version>
        </dependency>

        <dependency>
            <groupId>io.gravitee.apim.gateway</groupId>
            <artifactId>gravitee-apim-gateway-buffer</artifactId>
            <version>${project.version}</version>
        </dependency>

        <dependency>
            <groupId>io.gravitee.apim.gateway</groupId>
            <artifactId>gravitee-apim-gateway-env</artifactId>
            <version>${project.version}</version>
        </dependency>

        <dependency>
            <groupId>io.gravitee.apim.gateway</groupId>
            <artifactId>gravitee-apim-gateway-repository</artifactId>
            <version>${project.version}</version>
        </dependency>

        <dependency>
            <groupId>io.gravitee.apim.gateway</groupId>
            <artifactId>gravitee-apim-gateway-dictionary</artifactId>
            <version>${project.version}</version>
        </dependency>

        <dependency>
            <groupId>io.gravitee.apim.gateway</groupId>
            <artifactId>gravitee-apim-gateway-reporting</artifactId>
            <version>${project.version}</version>
        </dependency>

        <dependency>
            <groupId>io.gravitee.apim.gateway</groupId>
            <artifactId>gravitee-apim-gateway-connector</artifactId>
            <version>${project.version}</version>
        </dependency>

        <dependency>
            <groupId>io.gravitee.definition</groupId>
            <artifactId>gravitee-definition-jackson</artifactId>
        </dependency>

        <dependency>
            <groupId>io.gravitee.plugin</groupId>
            <artifactId>gravitee-plugin-alert</artifactId>
        </dependency>

        <dependency>
            <groupId>io.gravitee.plugin</groupId>
            <artifactId>gravitee-plugin-service-discovery</artifactId>
        </dependency>

        <dependency>
            <groupId>io.gravitee.resource</groupId>
            <artifactId>gravitee-resource-oauth2-provider-api</artifactId>
        </dependency>

        <dependency>
            <groupId>io.gravitee.resource</groupId>
            <artifactId>gravitee-resource-cache-provider-api</artifactId>
        </dependency>

        <!-- Jackson-->
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <scope>compile</scope>
        </dependency>

        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-annotations</artifactId>
            <scope>compile</scope>
        </dependency>

        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-core</artifactId>
            <scope>compile</scope>
        </dependency>

        <!-- Vert.x -->
        <dependency>
            <groupId>io.vertx</groupId>
            <artifactId>vertx-core</artifactId>
        </dependency>

        <dependency>
            <groupId>io.vertx</groupId>
            <artifactId>vertx-web-client</artifactId>
        </dependency>

        <dependency>
            <groupId>io.vertx</groupId>
            <artifactId>vertx-rx-java2</artifactId>
        </dependency>

        <dependency>
            <groupId>io.netty</groupId>
            <artifactId>netty-codec-haproxy</artifactId>
        </dependency>

        <!-- Logging -->
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-classic</artifactId>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-core</artifactId>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>ch.qos.logback.contrib</groupId>
            <artifactId>logback-jackson</artifactId>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>ch.qos.logback.contrib</groupId>
            <artifactId>logback-json-classic</artifactId>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>ch.qos.logback.contrib</groupId>
            <artifactId>logback-json-core</artifactId>
            <scope>compile</scope>
        </dependency>

        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
        </dependency>

        <!-- Spring -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>commons-logging</groupId>
                    <artifactId>commons-logging</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>jcl-over-slf4j</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-beans</artifactId>
        </dependency>
        <dependency>
            <groupId>io.gravitee.connector</groupId>
            <artifactId>gravitee-connector-http</artifactId>
            <version>${gravitee-connector-http.version}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-test</artifactId>
            <scope>test</scope>
        </dependency>

        <!-- Unit Tests -->
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>fluent-hc</artifactId>
            <version>${httpclient.version}</version>
            <scope>test</scope>
        </dependency>

        <!-- Wiremock -->
        <dependency>
            <groupId>com.github.tomakehurst</groupId>
            <artifactId>wiremock-jre8</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>io.vertx</groupId>
            <artifactId>vertx-unit</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>io.vertx</groupId>
            <artifactId>vertx-grpc</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>com.google.protobuf</groupId>
            <artifactId>protobuf-java-util</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>javax.annotation</groupId>
            <artifactId>javax.annotation-api</artifactId>
        </dependency>

        <dependency>
            <groupId>javax.xml.bind</groupId>
            <artifactId>jaxb-api</artifactId>
        </dependency>

        <dependency>
            <groupId>javax.activation</groupId>
            <artifactId>javax.activation-api</artifactId>
        </dependency>

        <dependency>
            <groupId>com.sun.xml.bind</groupId>
            <artifactId>jaxb-impl</artifactId>
        </dependency>

        <!-- Netty native transport -->
        <dependency>
            <groupId>io.netty</groupId>
            <artifactId>netty-transport-native-epoll</artifactId>
            <classifier>linux-x86_64</classifier>
        </dependency>

        <dependency>
            <groupId>io.netty</groupId>
            <artifactId>netty-tcnative-boringssl-static</artifactId>
            <classifier>linux-x86_64</classifier>
        </dependency>

        <dependency>
            <groupId>io.netty</groupId>
            <artifactId>netty-transport-native-kqueue</artifactId>
            <classifier>osx-x86_64</classifier>
        </dependency>
    </dependencies>

    <build>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
            </resource>
        </resources>

        <extensions>
            <extension>
                <groupId>kr.motd.maven</groupId>
                <artifactId>os-maven-plugin</artifactId>
                <version>1.4.1.Final</version>
            </extension>
        </extensions>

        <plugins>
            <plugin>
                <groupId>org.xolstice.maven.plugins</groupId>
                <artifactId>protobuf-maven-plugin</artifactId>
                <version>0.6.1</version>
                <configuration>
                    <!--
                      The version of protoc must match protobuf-java. If you don't depend on
                      protobuf-java directly, you will be transitively depending on the
                      protobuf-java version that grpc depends on.
                    -->
                    <protoTestSourceRoot>src/test/resources</protoTestSourceRoot>
                    <protocArtifact>com.google.protobuf:protoc:${protobuf-java.version}:exe:${os.detected.classifier}</protocArtifact>
                    <pluginId>grpc-java</pluginId>
                    <pluginArtifact>io.grpc:protoc-gen-grpc-java:1.37.0:exe:${os.detected.classifier}</pluginArtifact>
                    <protocPlugins>
                        <protocPlugin>
                            <id>vertx-grpc-protoc-plugin</id>
                            <groupId>io.vertx</groupId>
                            <artifactId>vertx-grpc-protoc-plugin</artifactId>
                            <version>${vertx.version}</version>
                            <mainClass>io.vertx.grpc.protoc.plugin.VertxGrpcGenerator</mainClass>
                        </protocPlugin>
                    </protocPlugins>
                </configuration>
                <executions>
                    <execution>
                        <id>compile</id>
                        <goals>
                            <goal>test-compile</goal>
                            <goal>test-compile-custom</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>java8</id>
            <activation>
                <jdk>1.8</jdk>
            </activation>
            <dependencies>
                <!--
                This is required because of JDK issue: https://bugs.openjdk.java.net/browse/JDK-8152174
                -->
                <dependency>
                    <groupId>io.vertx</groupId>
                    <artifactId>vertx-codegen</artifactId>
                    <scope>test</scope>
                </dependency>
            </dependencies>
        </profile>

        <profile>
            <id>dev</id>

            <properties>
                <workspace>${project.build.directory}/temp</workspace>
                <workspace.plugins>${workspace}/plugins</workspace.plugins>
                <workspace.logs>${workspace}/logs</workspace.logs>
                <gravitee.gateway.log.dir>${workspace}/logs</gravitee.gateway.log.dir>
            </properties>

            <build>
                <resources>
                    <resource>
                        <directory>../gravitee-apim-gateway-standalone-distribution/src/main/resources/</directory>
                        <includes>
                            <include>config/*</include>
                            <include>templates/*</include>
                        </includes>
                        <targetPath>${workspace}</targetPath>
                        <filtering>true</filtering>
                    </resource>
                </resources>

                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-dependency-plugin</artifactId>
                        <version>2.10</version>
                        <executions>
                            <execution>
                                <id>copy-plugins</id>
                                <phase>process-resources</phase>
                                <goals>
                                    <goal>copy</goal>
                                </goals>
                                <configuration>
                                    <artifactItems>
                                        <!-- REPOSITORIES -->
                                        <artifactItem>
                                            <groupId>io.gravitee.apim.repository</groupId>
                                            <artifactId>gravitee-apim-repository-mongodb</artifactId>
                                            <version>LATEST</version>
                                            <type>zip</type>
                                            <overWrite>false</overWrite>
                                        </artifactItem>
                                        <artifactItem>
                                            <groupId>io.gravitee.repository</groupId>
                                            <artifactId>gravitee-repository-elasticsearch</artifactId>
                                            <version>LATEST</version>
                                            <type>zip</type>
                                            <overWrite>false</overWrite>
                                        </artifactItem>
                                        <!-- POLICIES -->
                                        <artifactItem>
                                            <groupId>io.gravitee.policy</groupId>
                                            <artifactId>gravitee-policy-apikey</artifactId>
                                            <version>LATEST</version>
                                            <type>zip</type>
                                            <overWrite>false</overWrite>
                                        </artifactItem>
                                    </artifactItems>
                                    <outputDirectory>${workspace.plugins}</outputDirectory>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>

                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-antrun-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>init-dir</id>
                                <phase>process-resources</phase>
                                <configuration>
                                    <tasks>
                                        <mkdir dir="${workspace.logs}"/>
                                        <mkdir dir="${workspace.plugins}"/>
                                    </tasks>
                                </configuration>
                                <goals>
                                    <goal>run</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>

                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>exec-maven-plugin</artifactId>
                        <version>1.5.0</version>
                        <executions>
                            <execution>
                                <goals>
                                    <goal>java</goal>
                                </goals>
                            </execution>
                        </executions>
                        <configuration>
                            <includeProjectDependencies>true</includeProjectDependencies>
                            <mainClass>io.gravitee.apim.gateway.standalone.GatewayContainer</mainClass>
                            <systemProperties>
                                <systemProperty>
                                    <key>gravitee.home</key>
                                    <value>${workspace}</value>
                                </systemProperty>
                            </systemProperties>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>ee</id>
            <activation>
                <activeByDefault>false</activeByDefault>
            </activation>
            <dependencies>
                <!-- GraviteeSource dependencies -->
                <dependency>
                    <groupId>com.graviteesource.license</groupId>
                    <artifactId>gravitee-license-node</artifactId>
                </dependency>
            </dependencies>
        </profile>
    </profiles>

</project>
