<?xml version="1.0" encoding="UTF-8"?>
<!--
  ~ Yet Another UserAgent Analyzer
  ~ Copyright (C) 2013-2022 Niels Basjes
  ~
  ~ 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
  ~
  ~ https://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">
  <parent>
    <artifactId>yauaa-parent</artifactId>
    <groupId>nl.basjes.parse.useragent</groupId>
    <version>6.7</version>
  </parent>
  <modelVersion>4.0.0</modelVersion>
  <packaging>pom</packaging>

  <artifactId>yauaa-udf-parent</artifactId>
  <name>Yauaa : UDF : </name>

  <!-- ================================================================================================ -->
  <!-- These 3 dependencies are excluded by all UDFs because of dependency/shading/ relocating problems -->
  <!-- But they do need them for the compilation and testing ... -->
  <!-- Documentation of the used shading construct: https://yauaa.basjes.nl/NOTES-shading-dependencies.html -->
  <dependencyManagement>
    <dependencies>

      <dependency>
        <groupId>nl.basjes.parse.useragent</groupId>
        <artifactId>yauaa</artifactId>
        <version>${project.version}</version>
        <exclusions>
          <exclusion>
            <groupId>org.antlr</groupId>
            <artifactId>antlr4-runtime</artifactId>
          </exclusion>
          <exclusion>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
          </exclusion>
          <exclusion>
            <groupId>org.yaml</groupId>
            <artifactId>snakeyaml</artifactId>
          </exclusion>
        </exclusions>
      </dependency>

    </dependencies>
  </dependencyManagement>

  <dependencies>

    <dependency>
      <groupId>org.antlr</groupId>
      <artifactId>antlr4-runtime</artifactId>
      <version>${antlr.version}</version>
      <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-core</artifactId>
      <version>${spring.version}</version>
      <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>org.yaml</groupId>
      <artifactId>snakeyaml</artifactId>
      <version>${snakeyaml.version}</version>
      <scope>provided</scope>
    </dependency>

  </dependencies>

  <!-- ======================================================= -->

  <modules>
    <module>logparser</module>
    <module>pig</module>
    <module>flink</module>
<!--    <module>flink-table</module> -->
    <module>beam</module>
    <module>beam-sql</module>
<!--    <module>hive</module> -->
    <module>drill</module>
    <module>nifi</module>
    <module>elasticsearch</module>
    <module>snowflake</module>
  </modules>

  <profiles>
    <profile>
      <id>JDK11</id>
      <activation><jdk>[11,12)</jdk></activation>
      <!-- Some udfs will only build on JDK 11 because of the much strikter module enforcement  -->
      <!-- Building these under JDK 17 will fail with Exceptions like:                          -->
      <!--    Caused by: java.lang.reflect.InaccessibleObjectException:                         -->
      <!--        Unable to ... accessible: module java.base does not "opens java.util" to ...  -->
      <modules>
        <module>flink-table</module>
        <module>hive</module>
      </modules>
    </profile>

    <profile>
      <id>NewerThanJDK11</id>
      <activation><jdk>[12,)</jdk></activation>
      <!-- Some udfs will only build on JDK 11 because of the much strikter module enforcement  -->
      <!-- Building these under JDK 17 will fail with Exceptions like:                          -->
      <!--    Caused by: java.lang.reflect.InaccessibleObjectException:                         -->
      <!--        Unable to ... accessible: module java.base does not "opens java.util" to ...  -->
      <build>
        <plugins>
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>exec-maven-plugin</artifactId>
            <version>${exec-maven-plugin.version}</version>
            <executions>
              <execution>
                <id>Warn about too new JDK version.</id>
                <phase>validate</phase>
                <goals>
                  <goal>exec</goal>
                </goals>
                <configuration>
                  <executable>bash</executable>
                  <arguments>
                    <argument>-c</argument>
                    <argument>echo -e "\e[1;91m[WARN]\n\e[1;91m[WARN] \e[0;93mThe UDFs for Apache Hive and Apache Flink SQL require JDK 11 so under JDK with $(javac --version) they will not be built !!\n\e[1;91m[WARN]\e[0m"</argument>
                  </arguments>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>

    <profile>
      <id>buildRuby</id>
      <activation>
        <property>
          <name>!DisableRuby</name>
        </property>
      </activation>
      <modules>
        <module>logstash</module>
      </modules>
    </profile>
  </profiles>


  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-enforcer-plugin</artifactId>
        <version>${maven-enforcer-plugin.version}</version>
        <executions>
          <execution>
            <id>dependency-convergence</id>
            <!-- Disable the dependency-convergence for the UDFs                -->
            <!-- The transient dependencies cause almost all to fail over this. -->
            <phase>none</phase>
            <goals>
              <goal>enforce</goal>
            </goals>
            <configuration>
              <rules>
                <dependencyConvergence/>
              </rules>
              <skip>true</skip>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

</project>
