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

    Copyright © 2025 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.7.0</version>
  <packaging>pom</packaging>

  <name>Flink SQL Runner</name>
  <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>

    <developer>
      <name>Ferenc Csaky</name>
      <email>ferenc@datasqrl.com</email>
      <url>https://github.com/ferenc-csaky</url>
    </developer>
  </developers>

  <modules>
    <module>formats</module>
    <module>stdlib</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>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.source>11</maven.compiler.source>
    <maven.compiler.target>11</maven.compiler.target>

    <!-- Flink versions -->
    <flink.version>1.19.3</flink.version>
    <jdbc.conn.version>3.2.0-1.19</jdbc.conn.version>
    <kafka.conn.version>3.2.0-1.19</kafka.conn.version>

    <!-- Dependency versions -->
    <assertj.version>3.27.3</assertj.version>
    <auto.service.version>1.1.1</auto.service.version>
    <awaitility.version>4.3.0</awaitility.version>
    <commons-exec.version>1.5.0</commons-exec.version>
    <commons-math3.version>3.6.1</commons-math3.version>
    <feign.version>13.5</feign.version>
    <jacoco.version>0.8.13</jacoco.version>
    <jdbi3.version>3.49.5</jdbi3.version>
    <json-path.version>2.9.0</json-path.version>
    <junit.version>5.13.3</junit.version>
    <log4j.version>2.25.0</log4j.version>
    <lombok.version>1.18.38</lombok.version>
    <mockito.version>5.18.0</mockito.version>
    <nextbreakpoint.flink.client.version>1.1.4</nextbreakpoint.flink.client.version>
    <picocli.version>4.7.7</picocli.version>
    <postgres.version>42.7.7</postgres.version>
    <slf4j.version>1.7.36</slf4j.version>
    <testcontainers.version>1.21.3</testcontainers.version>

    <!-- Plugin versions -->
    <build-helper-maven-plugin.version>3.6.1</build-helper-maven-plugin.version>
    <central-publishing-maven-plugin.version>0.8.0</central-publishing-maven-plugin.version>
    <exec-maven-plugin.version>3.5.1</exec-maven-plugin.version>
    <license-maven-plugin.version>5.0.0</license-maven-plugin.version>
    <maven-enforcer-plugin.version>3.6.0</maven-enforcer-plugin.version>
    <maven-gpg-plugin.version>3.2.8</maven-gpg-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-surefire-plugin.version>3.5.3</maven-surefire-plugin.version>
    <spotless-maven-plugin>2.45.0</spotless-maven-plugin>
    <sundr-maven-plugin.version>0.200.4</sundr-maven-plugin.version>
  </properties>

  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>org.junit</groupId>
        <artifactId>junit-bom</artifactId>
        <version>${junit.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>

      <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <version>${slf4j.version}</version>
      </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-slf4j-impl</artifactId>
        <version>${log4j.version}</version>
      </dependency>
    </dependencies>
  </dependencyManagement>

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

    <!-- Common test dependencies-->
    <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>

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

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

    <dependency>
      <groupId>org.mockito</groupId>
      <artifactId>mockito-junit-jupiter</artifactId>
      <version>${mockito.version}</version>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <build>
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>com.diffplug.spotless</groupId>
          <artifactId>spotless-maven-plugin</artifactId>
          <version>${spotless-maven-plugin}</version>
        </plugin>

        <plugin>
          <groupId>com.mycila</groupId>
          <artifactId>license-maven-plugin</artifactId>
          <version>${license-maven-plugin.version}</version>
        </plugin>

        <plugin>
          <groupId>io.sundr</groupId>
          <artifactId>sundr-maven-plugin</artifactId>
          <version>${sundr-maven-plugin.version}</version>
        </plugin>

        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-enforcer-plugin</artifactId>
          <version>${maven-enforcer-plugin.version}</version>
        </plugin>

        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-failsafe-plugin</artifactId>
          <version>${maven-surefire-plugin.version}</version>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-gpg-plugin</artifactId>
          <version>${maven-gpg-plugin.version}</version>
        </plugin>

        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-javadoc-plugin</artifactId>
          <version>${maven-javadoc-plugin.version}</version>
        </plugin>

        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-source-plugin</artifactId>
          <version>${maven-source-plugin.version}</version>
        </plugin>

        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-surefire-plugin</artifactId>
          <version>${maven-surefire-plugin.version}</version>
        </plugin>

        <plugin>
          <groupId>org.codehaus.mojo</groupId>
          <artifactId>build-helper-maven-plugin</artifactId>
          <version>${build-helper-maven-plugin.version}</version>
        </plugin>

        <plugin>
          <groupId>org.sonatype.central</groupId>
          <artifactId>central-publishing-maven-plugin</artifactId>
          <version>${central-publishing-maven-plugin.version}</version>
        </plugin>
      </plugins>
    </pluginManagement>

    <plugins>
      <plugin>
        <groupId>com.diffplug.spotless</groupId>
        <artifactId>spotless-maven-plugin</artifactId>
        <configuration>
          <pom>
            <sortPom>
              <expandEmptyElements>false</expandEmptyElements>
            </sortPom>
          </pom>
          <java>
            <excludes>
              <exclude>**/org/apache/flink/**/*.java</exclude>
            </excludes>
            <googleJavaFormat/>
            <removeUnusedImports/>
          </java>
        </configuration>
        <executions>
          <execution>
            <id>spotless-default</id>
            <goals>
              <goal>check</goal>
            </goals>
            <phase>validate</phase>
          </execution>
          <execution>
            <id>spotless-flink</id>
            <goals>
              <goal>check</goal>
            </goals>
            <phase>validate</phase>
            <configuration>
              <java>
                <includes>
                  <include>**/org/apache/flink/**/*.java</include>
                </includes>
                <googleJavaFormat>
                  <version>1.8</version>
                  <style>AOSP</style>
                </googleJavaFormat>
                <!-- \# refers to the static imports -->
                <importOrder>
                  <order>org.apache.flink,org.apache.flink.shaded,,javax,java,scala,\#</order>
                </importOrder>
                <removeUnusedImports/>
              </java>
            </configuration>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <groupId>com.mycila</groupId>
        <artifactId>license-maven-plugin</artifactId>
        <configuration>
          <properties>
            <owner>DataSQRL</owner>
            <email>contact@datasqrl.com</email>
            <year>2025</year>
          </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>
        <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>
          <execution>
            <id>ban-slf4j2-dependencies</id>
            <goals>
              <goal>enforce</goal>
            </goals>
            <configuration>
              <rules>
                <bannedDependencies>
                  <searchTransitive>true</searchTransitive>
                  <excludes>
                    <!-- Ban SLF4J 2.x bridge to ensure only SLF4J 1.x is used -->
                    <exclude>org.apache.logging.log4j:log4j-slf4j2-impl</exclude>
                    <exclude>org.slf4j:slf4j-reload4j</exclude>
                  </excludes>
                  <message>SLF4J 2.x is not allowed. Use log4j-slf4j-impl instead of log4j-slf4j2-impl</message>
                </bannedDependencies>
              </rules>
            </configuration>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <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>${maven-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.4</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>
            <spotless.check.skip>true</spotless.check.skip>
          </projectExtraProperties>
        </configuration>
      </plugin>

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

              <properties>
                <license.skip>true</license.skip>
                <spotless.check.skip>true</spotless.check.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>
    <!-- Skip code format, license checks, tests, and enforced rules -->
    <profile>
      <id>fast</id>
      <activation>
        <property>
          <name>fast</name>
        </property>
      </activation>
      <properties>
        <skipTests>true</skipTests>
        <enforcer.skip>true</enforcer.skip>
        <maven.javadoc.skip>true</maven.javadoc.skip>
        <license.skip>true</license.skip>
        <spotless.check.skip>true</spotless.check.skip>
      </properties>
    </profile>

    <!-- Flink specific profiles -->
    <profile>
      <id>flink-2.0</id>
      <properties>
        <flink.version>2.0.0</flink.version>
        <jdbc.conn.version>3.2.0-1.19</jdbc.conn.version>
        <kafka.conn.version>3.2.0-1.19</kafka.conn.version>
        <flink-base-image>2.0.0-scala_2.12-java17</flink-base-image>
      </properties>
    </profile>

    <profile>
      <id>flink-1.20</id>
      <properties>
        <flink.version>1.20.2</flink.version>
        <jdbc.conn.version>3.2.0-1.19</jdbc.conn.version>
        <kafka.conn.version>3.2.0-1.19</kafka.conn.version>
        <flink-base-image>1.20.2-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.3</flink.version>
        <jdbc.conn.version>3.2.0-1.19</jdbc.conn.version>
        <kafka.conn.version>3.2.0-1.19</kafka.conn.version>
        <flink-base-image>1.19.3-scala_2.12-java17</flink-base-image>
      </properties>
    </profile>

    <!-- Extra tasks only meant to be executed by CI -->
    <profile>
      <id>ci</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-gpg-plugin</artifactId>
            <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>
            <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>
      <!-- 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>
            <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>
            <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>
