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

    Copyright © 2024 DataSQRL (contact@datasqrl.com)

    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>

  <groupId>com.datasqrl.flinkrunner</groupId>
  <artifactId>flink-sql-runner-parent</artifactId>
  <version>0.6.0</version>
  <packaging>pom</packaging>
  <description>Flink SQL Runner: a tool for running Flink SQL scripts easily.</description>
  <url>https://github.com/DataSQRL/flink-sql-runner/</url>

  <inceptionYear>2024</inceptionYear>

  <licenses>
    <license>
      <name>Apache License, Version 2.0</name>
      <url>https://www.apache.org/licenses/LICENSE-2.0.txt</url>
      <distribution>repo</distribution>
    </license>
  </licenses>

  <developers>
    <developer>
      <name>Daniel Henneberger</name>
      <email>daniel@datasqrl.com</email>
      <url>https://github.com/henneberger</url>
    </developer>
    <developer>
      <name>Marvin Froeder</name>
      <email>marvin@datasqrl.com</email>
      <url>https://github.com/velo</url>
    </developer>
  </developers>

  <modules>
    <module>formats</module>
    <module>functions</module>
    <module>types</module>
    <module>connectors</module>
    <module>testing</module>
    <module>flink-sql-runner</module>
  </modules>

  <scm>
    <connection>scm:git:git://github.com/DataSQRL/flink-sql-runner.git</connection>
    <developerConnection>scm:git:git@github.com:DataSQRL/flink-sql-runner.git</developerConnection>
    <tag>HEAD</tag>
    <url>https://github.com/DataSQRL/flink-sql-runner</url>
  </scm>

  <distributionManagement>
    <snapshotRepository>
      <id>github</id>
      <url>https://maven.pkg.github.com/DataSQRL/flink-sql-runner</url>
    </snapshotRepository>
  </distributionManagement>

  <properties>
    <!-- Plugin versions -->
    <license-maven-plugin.version>5.0.0</license-maven-plugin.version>
    <git-code-format-maven-plugin.version>5.3</git-code-format-maven-plugin.version>
    <maven-jar-plugin.version>3.3.0</maven-jar-plugin.version>
    <surefire-plugin.version>3.5.3</surefire-plugin.version>
    <maven-enforcer-plugin.version>3.5.0</maven-enforcer-plugin.version>
    <maven-javadoc-plugin.version>3.11.2</maven-javadoc-plugin.version>
    <maven-source-plugin.version>3.3.1</maven-source-plugin.version>
    <maven-gpg-plugin.version>3.2.7</maven-gpg-plugin.version>
    <docker-compose-plugin.version>5.0.0</docker-compose-plugin.version>
    <sortpom.plugin.version>4.0.0</sortpom.plugin.version>
    <exec.plugin.version>3.5.0</exec.plugin.version>
    <build-helper-maven-plugin.verison>3.6.0</build-helper-maven-plugin.verison>

    <slf4j.version>2.0.17</slf4j.version>
    <log4j.version>2.24.3</log4j.version>
    <feign.version>13.5</feign.version>
    <picocli.version>4.7.7</picocli.version>
    <flink.version>1.19.2</flink.version>
    <postgres.version>42.7.5</postgres.version>
    <testcontainers.version>1.21.0</testcontainers.version>
    <kafka.version>3.2.0-1.19</kafka.version>
    <jdbc.version>3.2.0-1.19</jdbc.version>
    <lombok.version>1.18.38</lombok.version>
    <auto.service.version>1.1.1</auto.service.version>
    <mockito.version>5.17.0</mockito.version>
    <assertj.version>3.27.3</assertj.version>

    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.source>17</maven.compiler.source>
    <maven.compiler.target>17</maven.compiler.target>

    <!-- Example: skip install hooks, etc. -->
    <gcf.skipInstallHooks>true</gcf.skipInstallHooks>
  </properties>

  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>org.junit</groupId>
        <artifactId>junit-bom</artifactId>
        <version>5.12.2</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
      <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-bom</artifactId>
        <version>${slf4j.version}</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
      <dependency>
        <groupId>com.google.auto.service</groupId>
        <artifactId>auto-service</artifactId>
        <version>${auto.service.version}</version>
      </dependency>
    </dependencies>
  </dependencyManagement>

  <dependencies>
    <!-- General Dependencies -->
    <dependency>
      <groupId>org.projectlombok</groupId>
      <artifactId>lombok</artifactId>
      <version>${lombok.version}</version>
      <scope>provided</scope>
    </dependency>

    <!-- common test infra-->
    <dependency>
      <groupId>org.junit.platform</groupId>
      <artifactId>junit-platform-launcher</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.junit.vintage</groupId>
      <artifactId>junit-vintage-engine</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.junit.jupiter</groupId>
      <artifactId>junit-jupiter-engine</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.junit.jupiter</groupId>
      <artifactId>junit-jupiter-params</artifactId>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <plugin>
        <groupId>com.cosium.code</groupId>
        <artifactId>git-code-format-maven-plugin</artifactId>
        <version>${git-code-format-maven-plugin.version}</version>
        <dependencies>
          <dependency>
            <groupId>com.cosium.code</groupId>
            <artifactId>google-java-format</artifactId>
            <version>${git-code-format-maven-plugin.version}</version>
          </dependency>
        </dependencies>
        <executions>
          <!-- On commit, format the modified files -->
          <execution>
            <id>install-formatter-hook</id>
            <goals>
              <goal>install-hooks</goal>
            </goals>
            <!-- inherited = false means it won't re-run in submodules if not desired -->
            <inherited>false</inherited>
          </execution>
          <!-- On Maven verify, fail if code is not formatted -->
          <execution>
            <id>validate-code-format</id>
            <goals>
              <goal>validate-code-format</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <groupId>com.github.ekryd.sortpom</groupId>
        <artifactId>sortpom-maven-plugin</artifactId>
        <version>${sortpom.plugin.version}</version>
        <configuration>
          <keepBlankLines>true</keepBlankLines>
          <lineSeparator>\n</lineSeparator>
          <predefinedSortOrder>recommended_2008_06</predefinedSortOrder>
          <createBackupFile>false</createBackupFile>
        </configuration>
      </plugin>

      <plugin>
        <groupId>com.mycila</groupId>
        <artifactId>license-maven-plugin</artifactId>
        <version>${license-maven-plugin.version}</version>
        <configuration>
          <properties>
            <owner>DataSQRL</owner>
            <email>contact@datasqrl.com</email>
          </properties>
          <licenseSets>
            <licenseSet>
              <header>com/mycila/maven/plugin/license/templates/APACHE-2.txt</header>
              <excludes>
                <exclude>src/test/resources/**</exclude>
                <exclude>m2e-target/**</exclude>
                <exclude>bin/**</exclude>
              </excludes>
            </licenseSet>
          </licenseSets>
          <strictCheck>true</strictCheck>
        </configuration>
        <dependencies>
          <dependency>
            <groupId>com.mycila</groupId>
            <artifactId>license-maven-plugin-git</artifactId>
            <version>${license-maven-plugin.version}</version>
          </dependency>
        </dependencies>
        <executions>
          <execution>
            <id>check</id>
            <goals>
              <goal>check</goal>
            </goals>
            <phase>compile</phase>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-enforcer-plugin</artifactId>
        <version>${maven-enforcer-plugin.version}</version>
        <executions>
          <execution>
            <id>ban-sqrl-dependencies</id>
            <goals>
              <goal>enforce</goal>
            </goals>
            <configuration>
              <rules>
                <bannedDependencies>
                  <searchTransitive>true</searchTransitive>
                  <excludes>
                    <exclude>com.datasqrl:*:*</exclude>
                  </excludes>
                  <message>SQRL depends on this project, so we can't have circular dependencies</message>
                </bannedDependencies>
              </rules>
              <fail>true</fail>
            </configuration>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>${surefire-plugin.version}</version>
        <configuration>
          <failIfNoSpecifiedTests>false</failIfNoSpecifiedTests>
          <redirectTestOutputToFile>true</redirectTestOutputToFile>
          <forkCount>0.5C</forkCount>
        </configuration>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-failsafe-plugin</artifactId>
        <version>${surefire-plugin.version}</version>
        <configuration>
          <failIfNoSpecifiedTests>false</failIfNoSpecifiedTests>
          <redirectTestOutputToFile>true</redirectTestOutputToFile>
        </configuration>
        <executions>
          <execution>
            <goals>
              <goal>integration-test</goal>
              <goal>verify</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <groupId>com.marvinformatics.jacoco</groupId>
        <artifactId>easy-jacoco-maven-plugin</artifactId>
        <version>0.1.3</version>
        <configuration>
          <projectRules>
            <rule>
              <limits>
                <limit>
                  <counter>INSTRUCTION</counter>
                  <value>COVEREDRATIO</value>
                  <minimum>0.70</minimum>
                </limit>
              </limits>
            </rule>
          </projectRules>
          <projectExtraProperties>
            <license.skip>true</license.skip>
          </projectExtraProperties>
        </configuration>
      </plugin>

      <plugin>
        <groupId>io.sundr</groupId>
        <artifactId>sundr-maven-plugin</artifactId>
        <version>0.200.3</version>
        <inherited>false</inherited>
        <configuration>
          <boms>
            <bom>
              <artifactId>flinkrunner-bom</artifactId>
              <name>flinkrunner-bom</name>

              <properties>
                <license.skip>true</license.skip>
              </properties>

              <modules>
                <includes>
                  <include>com.datasqrl.flinkrunner:*</include>
                </includes>
                <excludes>
                  <exclude>*:testing</exclude>
                  <exclude>*:*-sample</exclude>
                </excludes>
              </modules>
            </bom>
          </boms>
        </configuration>
        <executions>
          <execution>
            <goals>
              <goal>generate-bom</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

  <profiles>
    <!-- Useful profile for local dev (forces code format, etc.) -->
    <profile>
      <id>dev</id>
      <properties>
        <gcf.skipInstallHooks>false</gcf.skipInstallHooks>
        <flink.version>1.19.2</flink.version>
        <jdbc.version>3.2.0-1.19</jdbc.version>
        <kafka.version>3.2.0-1.19</kafka.version>
        <flink-base-image>1.19.2-scala_2.12-java17</flink-base-image>
      </properties>
      <build>
        <plugins>
          <plugin>
            <groupId>com.cosium.code</groupId>
            <artifactId>git-code-format-maven-plugin</artifactId>
            <executions>
              <execution>
                <id>format-code</id>
                <goals>
                  <goal>format-code</goal>
                </goals>
                <phase>initialize</phase>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <groupId>com.github.ekryd.sortpom</groupId>
            <artifactId>sortpom-maven-plugin</artifactId>
            <executions>
              <execution>
                <id>format</id>
                <goals>
                  <goal>sort</goal>
                </goals>
                <phase>initialize</phase>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <groupId>com.mycila</groupId>
            <artifactId>license-maven-plugin</artifactId>
            <executions>
              <execution>
                <id>format</id>
                <goals>
                  <goal>format</goal>
                </goals>
                <phase>initialize</phase>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>

    <!--  Flink specific profiles  -->
    <profile>
      <id>flink-2.0</id>
      <properties>
        <flink.version>2.0-preview1</flink.version>
        <jdbc.version>3.2.0-1.19</jdbc.version>
        <kafka.version>3.2.0-1.19</kafka.version>
        <flink-base-image>2.0-preview1-scala_2.12-java17</flink-base-image>
      </properties>
      <build>
        <plugins>
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>build-helper-maven-plugin</artifactId>
            <version>${build-helper-maven-plugin.verison}</version>
            <executions>
              <execution>
                <id>add-flink-1.20+-specific-source</id>
                <goals>
                  <goal>add-source</goal>
                </goals>
                <phase>generate-sources</phase>
                <configuration>
                  <sources>
                    <source>${basedir}/src/main/flink120+</source>
                  </sources>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
    <profile>
      <id>flink-1.20</id>
      <properties>
        <flink.version>1.20.1</flink.version>
        <jdbc.version>3.2.0-1.19</jdbc.version>
        <kafka.version>3.2.0-1.19</kafka.version>
        <flink-base-image>1.20.0-scala_2.12-java17</flink-base-image>
      </properties>
    </profile>
    <profile>
      <id>flink-1.19</id>
      <activation>
        <activeByDefault>true</activeByDefault>
      </activation>
      <properties>
        <flink.version>1.19.2</flink.version>
        <jdbc.version>3.2.0-1.19</jdbc.version>
        <kafka.version>3.2.0-1.19</kafka.version>
        <flink-base-image>1.19.2-scala_2.12-java17</flink-base-image>
      </properties>
    </profile>

    <!-- Extra tasks only meant to be executed by CI -->
    <profile>
      <id>ci</id>
      <properties>
        <gcf.skip>true</gcf.skip>
      </properties>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-gpg-plugin</artifactId>
            <version>${maven-gpg-plugin.version}</version>
            <executions>
              <execution>
                <id>sign-artifacts</id>
                <goals>
                  <goal>sign</goal>
                </goals>
                <phase>verify</phase>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-source-plugin</artifactId>
            <version>${maven-source-plugin.version}</version>
            <executions>
              <execution>
                <id>attach-sources</id>
                <goals>
                  <goal>jar-no-fork</goal>
                </goals>
                <phase>package</phase>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-javadoc-plugin</artifactId>
            <version>${maven-javadoc-plugin.version}</version>
            <configuration>
              <failOnError>false</failOnError>
            </configuration>
            <executions>
              <execution>
                <id>attach-javadocs</id>
                <goals>
                  <goal>jar</goal>
                </goals>
                <phase>package</phase>
                <configuration>
                  <show>public</show>
                  <failOnError>false</failOnError>
                  <detectOfflineLinks>false</detectOfflineLinks>
                  <doclint>all,-missing</doclint>
                  <nohelp>true</nohelp>
                  <excludePackageNames>*.internal.*,testutil,demo</excludePackageNames>
                  <quiet>true</quiet>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
    <profile>
      <!-- just compile, skip all other checks -->
      <id>quickbuild</id>
      <properties>
        <skipTests>true</skipTests>
        <enforcer.skip>true</enforcer.skip>
        <maven.javadoc.skip>true</maven.javadoc.skip>
        <gcf.skip>true</gcf.skip>
        <license.skip>true</license.skip>
      </properties>
    </profile>
    <profile>
      <!-- helper profile to proper configure eclipse -->
      <id>m2e</id>
      <activation>
        <property>
          <name>m2e.version</name>
        </property>
      </activation>
      <build>
        <directory>${project.basedir}/m2e-target</directory>
        <plugins>
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>build-helper-maven-plugin</artifactId>
            <version>${build-helper-maven-plugin.verison}</version>
            <executions>
              <execution>
                <id>add-source</id>
                <goals>
                  <goal>add-source</goal>
                </goals>
                <phase>generate-sources</phase>
                <configuration>
                  <sources>
                    <source>target/generated-sources/annotations</source>
                    <source>target/generated-sources/java</source>
                    <source>${basedir}/src/main/flink119</source>
                  </sources>
                </configuration>
              </execution>
              <execution>
                <id>add-google-auto</id>
                <goals>
                  <goal>add-resource</goal>
                </goals>
                <phase>generate-sources</phase>
                <configuration>
                  <resources>
                    <resource>
                      <directory>target/classes</directory>
                      <excludes>
                        <exclude>**/*.class</exclude>
                      </excludes>
                    </resource>
                  </resources>
                </configuration>
              </execution>
              <execution>
                <id>add-test-source</id>
                <goals>
                  <goal>add-test-source</goal>
                </goals>
                <phase>generate-test-sources</phase>
                <configuration>
                  <sources>
                    <source>target/generated-test-sources/test-annotations</source>
                  </sources>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
    <profile>
      <id>release</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.sonatype.central</groupId>
            <artifactId>central-publishing-maven-plugin</artifactId>
            <version>0.7.0</version>
            <extensions>true</extensions>
            <configuration>
              <publishingServerId>central</publishingServerId>

              <excludeArtifacts>
                <!-- artifacts that only exists to support integration tests and as samples-->
                <excludeArtifact>helpers</excludeArtifact>
                <excludeArtifact>system-functions-sample</excludeArtifact>
                <excludeArtifact>udf-sample</excludeArtifact>
              </excludeArtifacts>

              <autoPublish>true</autoPublish>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>

</project>
