<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements.  See the NOTICE file
distributed with this work for additional information
regarding copyright ownership.  The ASF licenses this file
to you 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>org.apache.flink</groupId>
        <artifactId>flink-kubernetes-operator-parent</artifactId>
        <version>1.15.0</version>
        <relativePath>..</relativePath>
    </parent>

    <artifactId>flink-kubernetes-operator</artifactId>
    <name>Flink Kubernetes Operator</name>
    <packaging>jar</packaging>

    <properties>
        <plugins.tmp.dir>${project.build.directory}/plugins</plugins.tmp.dir>
        <surefire.module.config>
            <!-- required by FlinkConfigManagerTest -->
            --add-opens=java.base/java.util=ALL-UNNAMED
        </surefire.module.config>
    </properties>

    <dependencies>
        <dependency>
            <groupId>io.javaoperatorsdk</groupId>
            <artifactId>operator-framework</artifactId>
            <version>${operator.sdk.version}</version>
            <exclusions>
                <exclusion>
                    <groupId>io.fabric8</groupId>
                    <artifactId>kubernetes-httpclient-okhttp</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>org.apache.flink</groupId>
            <artifactId>flink-kubernetes-operator-api</artifactId>
            <version>${project.version}</version>
        </dependency>

        <dependency>
            <groupId>org.apache.flink</groupId>
            <artifactId>flink-autoscaler</artifactId>
            <version>${project.version}</version>
        </dependency>

        <dependency>
            <!-- https://github.com/fabric8io/kubernetes-client/blob/main/doc/FAQ.md#what-artifacts-should-my-project-depend-on-->
            <groupId>io.fabric8</groupId>
            <artifactId>kubernetes-httpclient-${fabric8.httpclient.impl}</artifactId>
            <version>${fabric8.version}</version>
            <exclusions>
                <exclusion>
                    <groupId>com.squareup.okhttp3</groupId>
                    <artifactId>okhttp</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <!-- Flink -->
        <dependency>
            <groupId>org.apache.flink</groupId>
            <artifactId>flink-kubernetes</artifactId>
            <version>${flink.version}</version>
        </dependency>

        <dependency>
            <groupId>org.apache.flink</groupId>
            <artifactId>flink-clients</artifactId>
            <version>${flink.version}</version>
        </dependency>

        <dependency>
            <groupId>org.apache.flink</groupId>
            <artifactId>flink-core</artifactId>
            <version>${flink.version}</version>
        </dependency>

        <dependency>
            <groupId>org.apache.flink</groupId>
            <artifactId>flink-runtime-web</artifactId>
            <version>${flink.version}</version>
        </dependency>

        <dependency>
            <groupId>org.apache.flink</groupId>
            <artifactId>flink-metrics-core</artifactId>
            <version>${flink.version}</version>
        </dependency>

        <dependency>
            <groupId>org.apache.flink</groupId>
            <artifactId>flink-kubernetes-standalone</artifactId>
            <version>${project.version}</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>${lombok.version}</version>
            <scope>provided</scope>
        </dependency>

        <!-- Logging: SLF4J API and Log4j2 implementation are shaded into the operator JAR.
             Only the SLF4J bindings (log4j-slf4j-impl / logback-classic) are excluded
             and shipped as separate JARs so the entrypoint can pick one. -->

        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>${slf4j.version}</version>
        </dependency>

        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-slf4j-impl</artifactId>
            <version>${log4j.version}</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-api</artifactId>
            <version>${log4j.version}</version>
        </dependency>

        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-core</artifactId>
            <version>${log4j.version}</version>
        </dependency>

        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-1.2-api</artifactId>
            <version>${log4j.version}</version>
        </dependency>

        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-classic</artifactId>
            <version>${logback.version}</version>
            <scope>provided</scope>
        </dependency>


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

        <!-- Test -->
        <dependency>
            <groupId>org.apache.flink</groupId>
            <artifactId>flink-autoscaler</artifactId>
            <version>${project.version}</version>
            <type>test-jar</type>
            <classifier>tests</classifier>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.awaitility</groupId>
            <artifactId>awaitility</artifactId>
            <version>${awaitility.version}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>io.fabric8</groupId>
            <artifactId>kubernetes-server-mock</artifactId>
            <version>${fabric8.version}</version>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>com.squareup.okhttp3</groupId>
                    <artifactId>mockwebserver</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>io.fabric8</groupId>
            <artifactId>kube-api-test-client-inject</artifactId>
            <version>${fabric8.version}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>com.squareup.okhttp3</groupId>
            <artifactId>mockwebserver</artifactId>
            <version>${okhttp.version}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.apache.flink</groupId>
            <artifactId>flink-test-utils</artifactId>
            <version>${flink.version}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.apache.curator</groupId>
            <artifactId>curator-test</artifactId>
            <version>${curator-test.version}</version>
            <scope>test</scope>
            <exclusions>
                <!-- Exclude an older version of junit-jupiter-api -->
                <exclusion>
                    <groupId>org.junit.jupiter</groupId>
                    <artifactId>*</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>log4j</groupId>
                    <artifactId>log4j</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>org.apache.flink</groupId>
            <artifactId>flink-kubernetes-operator-api</artifactId>
            <version>${project.version}</version>
            <classifier>tests</classifier>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-params</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>false</filtering>
            </resource>
            <resource>
                <directory>src/main/resources-filtered</directory>
                <filtering>true</filtering>
            </resource>
        </resources>

        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <executions>
                    <execution>
                        <id>shade-flink-operator</id>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                        <configuration>
                            <shadedArtifactAttached>true</shadedArtifactAttached>
                            <filters combine.children="append">
                                <filter>
                                    <artifact>*:*</artifact>
                                    <excludes>
                                        <exclude>META-INF/**/module-info.class</exclude>
                                    </excludes>
                                </filter>
                                <filter>
                                    <artifact>org.apache.flink:flink-kubernetes</artifact>
                                    <excludes>
                                        <exclude>META-INF/versions/**/com/fasterxml/jackson/core/io/doubleparser/**</exclude>
                                    </excludes>
                                </filter>
                            </filters>
                            <artifactSet>
                                <includes combine.children="append">
                                    <include>*:*</include>
                                </includes>
                            </artifactSet>
                            <transformers combine.children="append">
                                <transformer
                                        implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                    <mainClass>org.apache.flink.kubernetes.operator.FlinkOperator</mainClass>
                                </transformer>
                            </transformers>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <id>copy</id>
                        <phase>package</phase>
                        <goals>
                            <goal>copy</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <artifactItems>
                        <!-- Log4j2 SLF4J binding (default logging framework) -->
                        <artifactItem>
                            <groupId>org.apache.logging.log4j</groupId>
                            <artifactId>log4j-slf4j-impl</artifactId>
                            <version>${log4j.version}</version>
                            <outputDirectory>${project.build.directory}/log4j</outputDirectory>
                        </artifactItem>
                        <!-- Logback SLF4J binding (alternative logging framework) -->
                        <artifactItem>
                            <groupId>ch.qos.logback</groupId>
                            <artifactId>logback-classic</artifactId>
                            <version>${logback.version}</version>
                            <outputDirectory>${project.build.directory}/logback</outputDirectory>
                        </artifactItem>
                        <artifactItem>
                            <groupId>ch.qos.logback</groupId>
                            <artifactId>logback-core</artifactId>
                            <version>${logback.version}</version>
                            <outputDirectory>${project.build.directory}/logback</outputDirectory>
                        </artifactItem>
                        <!-- Metrics plugins -->
                        <artifactItem>
                            <groupId>org.apache.flink</groupId>
                            <artifactId>flink-metrics-datadog</artifactId>
                            <version>${flink.version}</version>
                            <outputDirectory>${plugins.tmp.dir}/flink-metrics-datadog</outputDirectory>
                        </artifactItem>
                        <artifactItem>
                            <groupId>org.apache.flink</groupId>
                            <artifactId>flink-metrics-graphite</artifactId>
                            <version>${flink.version}</version>
                            <outputDirectory>${plugins.tmp.dir}/flink-metrics-graphite</outputDirectory>
                        </artifactItem>
                        <artifactItem>
                            <groupId>org.apache.flink</groupId>
                            <artifactId>flink-metrics-influxdb</artifactId>
                            <version>${flink.version}</version>
                            <outputDirectory>${plugins.tmp.dir}/flink-metrics-influxdb</outputDirectory>
                        </artifactItem>
                        <artifactItem>
                            <groupId>org.apache.flink</groupId>
                            <artifactId>flink-metrics-prometheus</artifactId>
                            <version>${flink.version}</version>
                            <outputDirectory>${plugins.tmp.dir}/flink-metrics-prometheus</outputDirectory>
                        </artifactItem>
                        <artifactItem>
                            <groupId>org.apache.flink</groupId>
                            <artifactId>flink-metrics-slf4j</artifactId>
                            <version>${flink.version}</version>
                            <outputDirectory>${plugins.tmp.dir}/flink-metrics-slf4j</outputDirectory>
                        </artifactItem>
                        <artifactItem>
                            <groupId>org.apache.flink</groupId>
                            <artifactId>flink-metrics-statsd</artifactId>
                            <version>${flink.version}</version>
                            <outputDirectory>${plugins.tmp.dir}/flink-metrics-statsd</outputDirectory>
                        </artifactItem>
                        <artifactItem>
                            <groupId>org.apache.flink</groupId>
                            <artifactId>flink-metrics-jmx</artifactId>
                            <version>${flink.version}</version>
                            <outputDirectory>${plugins.tmp.dir}/flink-metrics-jmx</outputDirectory>
                        </artifactItem>
                        <artifactItem>
                            <groupId>org.apache.flink</groupId>
                            <artifactId>flink-metrics-dropwizard</artifactId>
                            <version>${flink.version}</version>
                            <outputDirectory>${plugins.tmp.dir}/flink-metrics-dropwizard</outputDirectory>
                        </artifactItem>
                        <!--
                        flink-metrics-otel is only published from Flink 2.0.0 onwards on Maven Central.
                        While this repo still pins flink.version=1.20.1 the artifact cannot be resolved
                        and breaks the build. Restore this block once flink.version is bumped to >= 2.0.0
                        (introduced by FLINK-39541).
                        <artifactItem>
                            <groupId>org.apache.flink</groupId>
                            <artifactId>flink-metrics-otel</artifactId>
                            <version>${flink.version}</version>
                            <outputDirectory>${plugins.tmp.dir}/flink-metrics-otel</outputDirectory>
                        </artifactItem>
                        -->
                    </artifactItems>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-assembly-plugin</artifactId>
                <executions>
                    <execution>
                        <id>create-test-plugin-jar</id>
                        <phase>process-test-classes</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                        <configuration>
                            <finalName>test-plugins</finalName>
                            <attach>false</attach>
                            <descriptors>
                                <descriptor>src/test/assembly/test-plugins-assembly.xml</descriptor>
                            </descriptors>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>3.3.0</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>test-jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <!-- Description: https://github.com/git-commit-id/git-commit-id-maven-plugin
                    Used to show the git ref when starting the Flink Kubernetes operator. -->
                <groupId>io.github.git-commit-id</groupId>
                <artifactId>git-commit-id-maven-plugin</artifactId>
                <version>${git-commit-id-maven-plugin.version}</version>
                <executions>
                    <execution>
                        <id>get-the-git-infos</id>
                        <phase>validate</phase>
                        <goals>
                            <goal>revision</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <skipPoms>false</skipPoms>
                    <failOnNoGitDirectory>false</failOnNoGitDirectory>
                    <failOnUnableToExtractRepoInfo>false</failOnUnableToExtractRepoInfo>
                    <generateGitPropertiesFile>true</generateGitPropertiesFile>
                    <generateGitPropertiesFilename>${project.build.outputDirectory}/git.properties
                    </generateGitPropertiesFilename>
                    <includeOnlyProperties>
                        <includeOnlyProperty>^git.commit.id.abbrev$</includeOnlyProperty>
                        <includeOnlyProperty>^git.commit.time$</includeOnlyProperty>
                    </includeOnlyProperties>
                    <commitIdGenerationMode>full</commitIdGenerationMode>
                </configuration>
            </plugin>
        </plugins>
    </build>
    <profiles>
        <profile>
            <id>apache-release</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-shade-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>shade-flink-operator</id>
                                <phase>none</phase>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

</project>
