<?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-api</artifactId>
    <name>Flink Kubernetes Operator Api</name>
    <packaging>jar</packaging>

    <properties>
        <plugins.tmp.dir>${project.build.directory}/plugins</plugins.tmp.dir>
    </properties>

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

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

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

        <!-- Fabric 8 -->
        <dependency>
            <groupId>io.fabric8</groupId>
            <artifactId>crd-generator-api-v2</artifactId>
            <version>${fabric8.version}</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>io.fabric8</groupId>
            <artifactId>kubernetes-client</artifactId>
        </dependency>
        
        <!-- Utils -->
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <version>${commons-lang3.version}</version>
        </dependency>

        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
            <version>${commons-io.version}</version>
        </dependency>

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

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

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

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

        <!-- Test -->
        <dependency>
            <groupId>org.apache.flink</groupId>
            <artifactId>flink-kubernetes</artifactId>
            <version>${flink.version}</version>
            <scope>test</scope>
        </dependency>
        
        <dependency>
            <groupId>org.apache.flink</groupId>
            <artifactId>flink-runtime</artifactId>
            <version>${flink.version}</version>
            <scope>test</scope>
        </dependency>

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

        <dependency>
            <groupId>org.assertj</groupId>
            <artifactId>assertj-core</artifactId>
            <version>${assertj.version}</version>
            <scope>test</scope>
        </dependency>

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

        <dependency>
            <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>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <profiles>
        <profile>
            <id>generate-docs</id>
            <activation>
                <activeByDefault>false</activeByDefault>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-javadoc-plugin</artifactId>
                        <version>${maven-javadoc-plugin.version}</version>
                        <executions>
                            <execution>
                                <id>doc-crd</id>
                                <phase>package</phase>
                                <goals>
                                    <goal>javadoc</goal>
                                </goals>
                                <configuration>
                                    <doclet>org.apache.flink.kubernetes.operator.api.docs.CrdReferenceDoclet</doclet>
                                    <docletArtifacts>
                                        <docletArtifact>
                                            <groupId>org.apache.flink</groupId>
                                            <artifactId>flink-kubernetes-operator-api</artifactId>
                                            <version>${project.version}</version>
                                        </docletArtifact>
                                    </docletArtifacts>
                                    <additionalOptions>
                                        <additionalOption>--outputFile</additionalOption>
                                        <additionalOption>${project.basedir}/../docs/content/docs/custom-resource/reference.md
                                        </additionalOption>
                                        <additionalOption>--templateFile</additionalOption>
                                        <additionalOption>${project.basedir}/../docs/template/crd-ref.template</additionalOption>
                                    </additionalOptions>
                                    <useStandardDocletOptions>false</useStandardDocletOptions>
                                </configuration>
                            </execution>
                            <execution>
                                <id>doc</id>
                                <phase>package</phase>
                                <goals>
                                    <goal>javadoc</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
    <build>
        <plugins>
            <plugin>
                <artifactId>maven-resources-plugin</artifactId>
                <version>${maven-resources-plugin.version}</version>
                <executions>
                    <execution>
                        <id>copy-resources</id>
                        <phase>process-classes</phase>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${project.basedir}/../helm/flink-kubernetes-operator/crds</outputDirectory>
                            <resources>
                                <resource>
                                    <directory>${project.build.outputDirectory}/META-INF/fabric8</directory>
                                    <includes>
                                        <include>flinkdeployments.flink.apache.org-v1.yml</include>
                                        <include>flinksessionjobs.flink.apache.org-v1.yml</include>
                                        <include>flinkstatesnapshots.flink.apache.org-v1.yml</include>
                                        <include>flinkbluegreendeployments.flink.apache.org-v1.yml</include>
                                    </includes>
                                    <filtering>false</filtering>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <artifactId>maven-antrun-plugin</artifactId>
                <executions>
                    <execution>
                        <id>deployment-crd-compatibility-check</id>
                        <phase>package</phase>
                        <goals>
                            <goal>run</goal>
                        </goals>
                        <configuration>
                            <target>
                                <java classname="org.apache.flink.kubernetes.operator.api.validation.CrdCompatibilityChecker"
                                      fork="true" failonerror="true">
                                    <classpath refid="maven.compile.classpath"/>
                                    <arg value="file://${rootDir}/helm/flink-kubernetes-operator/crds/flinkdeployments.flink.apache.org-v1.yml"/>
                                    <arg value="https://raw.githubusercontent.com/apache/flink-kubernetes-operator/release-1.9.0/helm/flink-kubernetes-operator/crds/flinkdeployments.flink.apache.org-v1.yml"/>
                                    <arg value="https://raw.githubusercontent.com/apache/flink-kubernetes-operator/release-1.10.0/helm/flink-kubernetes-operator/crds/flinkdeployments.flink.apache.org-v1.yml"/>
                                    <arg value="https://raw.githubusercontent.com/apache/flink-kubernetes-operator/release-1.11.0/helm/flink-kubernetes-operator/crds/flinkdeployments.flink.apache.org-v1.yml"/>
                                    <arg value="https://raw.githubusercontent.com/apache/flink-kubernetes-operator/release-1.12.0/helm/flink-kubernetes-operator/crds/flinkdeployments.flink.apache.org-v1.yml"/>
                                    <arg value="https://raw.githubusercontent.com/apache/flink-kubernetes-operator/release-1.13.0/helm/flink-kubernetes-operator/crds/flinkdeployments.flink.apache.org-v1.yml"/>
                                    <arg value="https://raw.githubusercontent.com/apache/flink-kubernetes-operator/release-1.14.0/helm/flink-kubernetes-operator/crds/flinkdeployments.flink.apache.org-v1.yml"/>
                                </java>
                            </target>
                        </configuration>
                    </execution>
                    <execution>
                        <id>sessionjob-crd-compatibility-check</id>
                        <phase>package</phase>
                        <goals>
                            <goal>run</goal>
                        </goals>
                        <configuration>
                            <target>
                                <java classname="org.apache.flink.kubernetes.operator.api.validation.CrdCompatibilityChecker"
                                      fork="true" failonerror="true">
                                    <classpath refid="maven.compile.classpath"/>
                                    <arg value="file://${rootDir}/helm/flink-kubernetes-operator/crds/flinksessionjobs.flink.apache.org-v1.yml"/>
                                    <arg value="https://raw.githubusercontent.com/apache/flink-kubernetes-operator/release-1.9.0/helm/flink-kubernetes-operator/crds/flinksessionjobs.flink.apache.org-v1.yml"/>
                                    <arg value="https://raw.githubusercontent.com/apache/flink-kubernetes-operator/release-1.10.0/helm/flink-kubernetes-operator/crds/flinksessionjobs.flink.apache.org-v1.yml"/>
                                    <arg value="https://raw.githubusercontent.com/apache/flink-kubernetes-operator/release-1.11.0/helm/flink-kubernetes-operator/crds/flinksessionjobs.flink.apache.org-v1.yml"/>
                                    <arg value="https://raw.githubusercontent.com/apache/flink-kubernetes-operator/release-1.12.0/helm/flink-kubernetes-operator/crds/flinksessionjobs.flink.apache.org-v1.yml"/>
                                    <arg value="https://raw.githubusercontent.com/apache/flink-kubernetes-operator/release-1.13.0/helm/flink-kubernetes-operator/crds/flinksessionjobs.flink.apache.org-v1.yml"/>
                                    <arg value="https://raw.githubusercontent.com/apache/flink-kubernetes-operator/release-1.14.0/helm/flink-kubernetes-operator/crds/flinksessionjobs.flink.apache.org-v1.yml"/>
                                </java>
                            </target>
                        </configuration>
                    </execution>
                    <execution>
                        <id>flinkbgdeployments-remove-scale-subresource</id>
                        <phase>package</phase>
                        <goals>
                            <goal>run</goal>
                        </goals>
                        <configuration>
                            <target>
                                <java classname="org.apache.flink.kubernetes.operator.api.utils.RemoveScaleSubResource"
                                      fork="true" failonerror="true">
                                    <classpath refid="maven.compile.classpath"/>
                                    <arg value="${rootDir}/helm/flink-kubernetes-operator/crds/flinkbluegreendeployments.flink.apache.org-v1.yml"/>
                                </java>
                            </target>
                        </configuration>
                    </execution>
                    <execution>
                        <id>statesnapshot-crd-compatibility-check</id>
                        <phase>package</phase>
                        <goals>
                            <goal>run</goal>
                        </goals>
                        <configuration>
                            <target>
                                <java classname="org.apache.flink.kubernetes.operator.api.validation.CrdCompatibilityChecker"
                                      fork="true" failonerror="true">
                                    <classpath refid="maven.compile.classpath"/>
                                    <arg value="file://${rootDir}/helm/flink-kubernetes-operator/crds/flinkstatesnapshots.flink.apache.org-v1.yml"/>
                                    <arg value="https://raw.githubusercontent.com/apache/flink-kubernetes-operator/release-1.10.0/helm/flink-kubernetes-operator/crds/flinkstatesnapshots.flink.apache.org-v1.yml"/>
                                    <arg value="https://raw.githubusercontent.com/apache/flink-kubernetes-operator/release-1.11.0/helm/flink-kubernetes-operator/crds/flinkstatesnapshots.flink.apache.org-v1.yml"/>
                                    <arg value="https://raw.githubusercontent.com/apache/flink-kubernetes-operator/release-1.12.0/helm/flink-kubernetes-operator/crds/flinkstatesnapshots.flink.apache.org-v1.yml"/>
                                    <arg value="https://raw.githubusercontent.com/apache/flink-kubernetes-operator/release-1.13.0/helm/flink-kubernetes-operator/crds/flinkstatesnapshots.flink.apache.org-v1.yml"/>
                                    <arg value="https://raw.githubusercontent.com/apache/flink-kubernetes-operator/release-1.14.0/helm/flink-kubernetes-operator/crds/flinkstatesnapshots.flink.apache.org-v1.yml"/>
                                </java>
                            </target>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>${maven-jar-plugin.version}</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>test-jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>io.fabric8</groupId>
                <artifactId>crd-generator-maven-plugin</artifactId>
                <version>${fabric8.version}</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>
