<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  ~ Copyright (C) 2019 Google Inc.
  ~
  ~ 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:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
         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.google.cloud.teleport.v2</groupId>
    <artifactId>dynamic-templates</artifactId>
    <version>1.0-SNAPSHOT</version>

    <packaging>pom</packaging>
    <name>dynamic-templates</name>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <autovalue.version>1.7.4</autovalue.version>
        <autovalue.annotations.version>1.7.4</autovalue.annotations.version>
        <autovalue.service.version>1.0-rc6</autovalue.service.version>
        <checkstyle.version>8.7</checkstyle.version>
        <beam.version>2.29.0</beam.version>
        <beam-vendor-guava.version>0.1</beam-vendor-guava.version>
        <hamcrest.version>2.1</hamcrest.version>
        <java.version>1.8</java.version>
        <jib.maven.version>2.6.0</jib.maven.version>
        <junit.version>4.13</junit.version>
        <junit-dep.version>4.10</junit-dep.version>
        <opensensus.version>0.24.0</opensensus.version>
        <surefire.version>2.21.0</surefire.version>
        <maven-checkstyle-plugin.version>3.0.0</maven-checkstyle-plugin.version>
        <maven-compiler-plugin.version>3.6.2</maven-compiler-plugin.version>
        <maven-dependency-plugin.version>3.0.1</maven-dependency-plugin.version>
        <maven-enforcer-plugin.version>3.0.0-M1</maven-enforcer-plugin.version>
        <maven-javadoc-plugin.version>3.0.0-M1</maven-javadoc-plugin.version>
        <maven-jar-plugin.version>3.0.2</maven-jar-plugin.version>
        <maven-shade-plugin.version>3.0.0</maven-shade-plugin.version>
        <maven-source-plugin.version>3.0.1</maven-source-plugin.version>
        <mockito-core.version>3.0.0</mockito-core.version>
        <os-maven-plugin.version>1.5.0.Final</os-maven-plugin.version>
        <slf4j.version>1.7.25</slf4j.version>
        <joda.version>2.10.5</joda.version>
        <findbugs.version>3.0.1</findbugs.version>
        <mvn-target-dir>${basedir}/target</mvn-target-dir>
        <json.version>20200518</json.version>
        <excluded.spanner.tests>com.google.cloud.teleport.v2.spanner.IntegrationTest</excluded.spanner.tests>
    </properties>

    <dependencies>
        <!-- Beam -->
        <dependency>
            <groupId>org.apache.beam</groupId>
            <artifactId>beam-sdks-java-core</artifactId>
            <version>${beam.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.beam</groupId>
            <artifactId>beam-sdks-java-io-google-cloud-platform</artifactId>
            <version>${beam.version}</version>
            <exclusions>
                <exclusion>
                    <groupId>junit</groupId>
                    <artifactId>junit</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
          <groupId>org.apache.beam</groupId>
          <artifactId>beam-sdks-java-io-jdbc</artifactId>
          <version>${beam.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.beam</groupId>
            <artifactId>beam-sdks-java-extensions-google-cloud-platform-core</artifactId>
            <version>${beam.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.beam</groupId>
            <artifactId>beam-runners-google-cloud-dataflow-java</artifactId>
            <version>${beam.version}</version>
        </dependency>
        <dependency>
            <!-- Direct runner included for local development and testing. -->
            <groupId>org.apache.beam</groupId>
            <artifactId>beam-runners-direct-java</artifactId>
            <version>${beam.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.beam</groupId>
            <artifactId>beam-vendor-guava-20_0</artifactId>
            <version>${beam-vendor-guava.version}</version>
        </dependency>

        <!-- Test -->
        <dependency>
            <groupId>org.hamcrest</groupId>
            <artifactId>hamcrest-core</artifactId>
            <version>${hamcrest.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.hamcrest</groupId>
            <artifactId>hamcrest-library</artifactId>
            <version>${hamcrest.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit-dep</artifactId>
            <version>${junit-dep.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-core</artifactId>
            <version>${mockito-core.version}</version>
            <scope>test</scope>
        </dependency>
  

        <!-- Misc -->
        <dependency>
            <groupId>io.opencensus</groupId>
            <artifactId>opencensus-api</artifactId>
            <version>${opensensus.version}</version>
        </dependency>
        <dependency>
            <groupId>com.google.auto.service</groupId>
            <artifactId>auto-service</artifactId>
            <version>${autovalue.service.version}</version>
        </dependency>
        <dependency>
            <groupId>com.google.auto.value</groupId>
            <artifactId>auto-value</artifactId>
            <version>${autovalue.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.google.auto.value</groupId>
            <artifactId>auto-value-annotations</artifactId>
            <version>${autovalue.annotations.version}</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>${slf4j.version}</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-simple</artifactId>
            <version>${slf4j.version}</version>
        </dependency>
        <dependency>
            <groupId>joda-time</groupId>
            <artifactId>joda-time</artifactId>
            <version>${joda.version}</version>
        </dependency>
        <dependency>
            <groupId>com.google.code.findbugs</groupId>
            <artifactId>jsr305</artifactId>
            <version>${findbugs.version}</version>
        </dependency>
        <dependency>
            <groupId>org.json</groupId>
            <artifactId>json</artifactId>
            <version>${json.version}</version>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>${junit.version}</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <directory>${mvn-target-dir}</directory>
        <extensions>
            <extension>
                <groupId>kr.motd.maven</groupId>
                <artifactId>os-maven-plugin</artifactId>
                <version>${os-maven-plugin.version}</version>
            </extension>
        </extensions>

        <pluginManagement>
            <plugins>

                <!--
                    The jib plugin provides the capability to containerize this application based on
                    properties specified in the configuration without having to build a Dockerfile manually.
                     Jib also integrates with the maven lifecycle and helps push the image to the repository
                    specified in the configuration or via the command line.
                        https://github.com/GoogleContainerTools/jib/tree/master/jib-maven-plugin
                    -->
                <plugin>
                    <groupId>com.google.cloud.tools</groupId>
                    <artifactId>jib-maven-plugin</artifactId>
                    <version>${jib.maven.version}</version>
                    <configuration>
                        <from>
                            <!--
                            The Dataflow Template base image to use. This
                             should not need to change unless we want to use the JDK11
                             -->
                            <image>${base-container-image}:${base-container-image.version}</image>
                        </from>
                        <container>
                            <!--
                            The root directory to use to expand the compiled classes and dependencies in. The
                            Jib plugin  will create the following directories under this root:
                              - resources: All the files under src/resources will be copied to this folder as-is.
                              - libs: All dependency jars needed to execute this pipeline will be copied into this
                                      folder.
                              - classes: Compiled pipeline code will be copied into this folder.
                            The libs and classes folders under appRoot should thus be added in the classpath
                            defined in src/resources/command-spec.json.
                            -->
                            <appRoot>${app-root}</appRoot>
                            <!--
                            INHERIT the base containers entrypoint. Do not override or the Dataflow service
                            will be unable to launch this template.
                            -->
                            <entrypoint>INHERIT</entrypoint>
                            <environment>
                                <!--
                                Set an environment variable called DATAFLOW_JAVA_COMMAND_SPEC that points to the
                                java-command-spec.json file inside the container. Note that since the Jib plugin
                                copies the containers of src/resources/* to appRoot/resources, the value of this
                                environment variable can be set here.
                                -->
                                <DATAFLOW_JAVA_COMMAND_SPEC>
                                    ${command-spec}
                                </DATAFLOW_JAVA_COMMAND_SPEC>
                            </environment>
                        </container>
                    </configuration>

                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-shade-plugin</artifactId>
                    <version>3.0.0</version>
                    <executions>
                        <execution>
                            <id>bundle-and-repackage</id>
                            <phase>package</phase>
                            <goals>
                                <goal>shade</goal>
                            </goals>
                            <configuration>
                                <dependencyReducedPomLocation>
                                    ${mvn-target-dir}/dependency-reduced-pom.xml
                                </dependencyReducedPomLocation>
                                <shadeTestJar>true</shadeTestJar>
                                <artifactSet>
                                    <includes>
                                        <include>*:*</include>
                                    </includes>
                                </artifactSet>
                                <filters>
                                    <filter>
                                        <artifact>*:*</artifact>
                                        <excludes>
                                            <exclude>META-INF/*.SF</exclude>
                                            <exclude>META-INF/*.DSA</exclude>
                                            <exclude>META-INF/*.RSA</exclude>
                                        </excludes>
                                    </filter>
                                </filters>
                                <transformers>
                                    <transformer
                                            implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
                                </transformers>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>exec-maven-plugin</artifactId>
                    <version>1.6.0</version>
                    <configuration>
                        <cleanupDaemonThreads>false</cleanupDaemonThreads>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>

        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>${maven-dependency-plugin.version}</version>
                <executions>
                    <execution>
                        <id>analyze-dependencies</id>
                        <goals>
                            <goal>analyze-only</goal>
                        </goals>
                        <configuration>
                            <!-- Ignore runtime-only dependencies in analysis -->
                            <ignoreNonCompile>true</ignoreNonCompile>
                            <failOnWarning>false</failOnWarning>
                            <ignoredUsedUndeclaredDependencies>
                                <ignoredUsedUndeclaredDependency>
                                    com.google.api.grpc:proto-google-cloud-dlp-v2
                                </ignoredUsedUndeclaredDependency>
                                <ignoredUsedUndeclaredDependency>
                                    org.apache.beam:beam-model-pipeline
                                </ignoredUsedUndeclaredDependency>
                            </ignoredUsedUndeclaredDependencies>
                            <ignoredUnusedDeclaredDependencies>
                                <ignoredUnusedDeclaredDependency>
                                    org.slf4j:slf4j-api
                                </ignoredUnusedDeclaredDependency>
                                <ignoredUnusedDeclaredDependency>
                                    org.slf4j:slf4j-simple
                                </ignoredUnusedDeclaredDependency>
                                <ignoredUnusedDeclaredDependency>
                                    org.apache.beam:beam-sdks-java-extensions-google-cloud-platform-core
                                </ignoredUnusedDeclaredDependency>
                                <ignoredUnusedDeclaredDependency>
                                    org.apache.beam:beam-runners-google-cloud-dataflow-java
                                </ignoredUnusedDeclaredDependency>
                                <ignoredUnusedDeclaredDependency>
                                    org.slf4j:slf4j-simple
                                </ignoredUnusedDeclaredDependency>
                                <ignoredUnusedDeclaredDependency>
                                    com.google.code.findbugs:jsr305
                                </ignoredUnusedDeclaredDependency>
                                <ignoredUnusedDeclaredDependency>
                                    org.apache.beam:beam-runners-direct-java
                                </ignoredUnusedDeclaredDependency>
                                <ignoredUnusedDeclaredDependency>
                                    org.threeten:threetenbp
                                </ignoredUnusedDeclaredDependency>
                                <ignoredUnusedDeclaredDependency>
                                    org.apache.beam:beam-sdks-java-core
                                </ignoredUnusedDeclaredDependency>
                                <ignoredUnusedDeclaredDependency>
                                    com.google.auto.value:auto-value-annotations
                                </ignoredUnusedDeclaredDependency>
                                <ignoredUnusedDeclaredDependency>
                                    joda-time:joda-time
                                </ignoredUnusedDeclaredDependency>
                                <ignoredUnusedDeclaredDependency>
                                    org.apache.beam:beam-vendor-guava-20_0
                                </ignoredUnusedDeclaredDependency>
                                <ignoredUnusedDeclaredDependency>
                                    org.apache.beam:beam-sdks-java-io-google-cloud-platform
                                </ignoredUnusedDeclaredDependency>
                            </ignoredUnusedDeclaredDependencies>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>${maven-compiler-plugin.version}</version>
                <configuration>
                    <source>${java.version}</source>
                    <target>${java.version}</target>
                    <!-- <compilerArgument>-parameters</compilerArgument> -->
                    <parameters>true</parameters>
                    <testCompilerArgument>-parameters</testCompilerArgument>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-source-plugin</artifactId>
                <version>${maven-source-plugin.version}</version>
                <executions>
                    <execution>
                        <id>attach-sources</id>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <executions>
                    <execution>
                        <id>bundle-and-repackage</id>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                        <configuration>
                            <shadeTestJar>true</shadeTestJar>
                            <artifactSet>
                                <includes>
                                    <include>*:*</include>
                                </includes>
                            </artifactSet>
                            <filters>
                                <filter>
                                    <artifact>*:*</artifact>
                                    <excludes>
                                        <exclude>META-INF/*.SF</exclude>
                                        <exclude>META-INF/*.DSA</exclude>
                                        <exclude>META-INF/*.RSA</exclude>
                                    </excludes>
                                </filter>
                            </filters>
                            <transformers>
                                <transformer
                                        implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
                            </transformers>
                        </configuration>
                    </execution>
                </executions>
            </plugin>


            <plugin>
                <!-- Set up Javadoc configuration for javadoc run via in the Maven
                     build. Teleport only uses the plugin to create the individual javadoc
                     attached artifacts used for IDEs. The combined javadoc for the
                     website is built in the sdks/java/javadoc directory. Rather than
                     duplicate a raft of configuration between the ant.xml there and
                     here, we leave things simple here. -->
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <version>${maven-javadoc-plugin.version}</version>
                <configuration>
                    <windowtitle>Teleport for Java, version ${project.version} API</windowtitle>
                    <doctitle>Teleport for Java, version ${project.version}</doctitle>
                    <use>false</use>
                    <quiet>true</quiet>
                    <notimestamp>true</notimestamp>
                </configuration>
            </plugin>

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


            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-checkstyle-plugin</artifactId>
                <version>${maven-checkstyle-plugin.version}</version>
                <dependencies>
                    <dependency>
                        <groupId>com.puppycrawl.tools</groupId>
                        <artifactId>checkstyle</artifactId>
                        <version>${checkstyle.version}</version>
                    </dependency>
                </dependencies>
                <configuration>
                    <configLocation>checkstyle/checkstyle.xml</configLocation>
                    <suppressionsLocation>checkstyle/suppressions.xml</suppressionsLocation>
                    <consoleOutput>true</consoleOutput>
                    <failOnViolation>true</failOnViolation>
                    <includeResources>false</includeResources>
                    <includeTestSourceDirectory>true</includeTestSourceDirectory>
                </configuration>
                <executions>
                    <!--
                      Execute checkstyle after compilation but before tests.
                      This ensures that any parsing or type checking errors are from
                      javac, so they look as expected. Beyond that, we want to
                      fail as early as possible.
                    -->
                    <execution>
                        <phase>test-compile</phase>
                        <goals>
                            <goal>check</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-enforcer-plugin</artifactId>
                <version>${maven-enforcer-plugin.version}</version>
                <executions>
                    <execution>
                        <id>enforce</id>
                        <goals>
                            <goal>enforce</goal>
                        </goals>
                        <configuration>
                            <rules>
                                <enforceBytecodeVersion>
                                    <maxJdkVersion>1.9</maxJdkVersion>
                                    <excludes>
                                        <!--
                                          Supplied by the user JDK and compiled with matching
                                          version. Is not shaded, so safe to ignore.
                                        -->
                                        <exclude>jdk.tools:jdk.tools</exclude>
                                    </excludes>
                                </enforceBytecodeVersion>
                                <requireJavaVersion>
                                    <version>[1.7,)</version>
                                </requireJavaVersion>
                                <requireMavenVersion>
                                    <!-- Keep aligned with prerequisite section below. -->
                                    <version>[3.2,)</version>
                                </requireMavenVersion>
                            </rules>
                        </configuration>
                    </execution>
                    <execution>
                        <id>enforce-banned-dependencies</id>
                        <goals>
                            <goal>enforce</goal>
                        </goals>
                        <configuration>
                            <rules>
                                <bannedDependencies>
                                    <excludes>
                                        <exclude>com.google.guava:guava-jdk5</exclude>
                                        <exclude>com.google.protobuf:protobuf-lite</exclude>
                                    </excludes>
                                </bannedDependencies>
                            </rules>
                            <fail>true</fail>
                        </configuration>
                    </execution>
                </executions>
                <dependencies>
                    <dependency>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>extra-enforcer-rules</artifactId>
                        <version>1.0-beta-6</version>
                    </dependency>
                </dependencies>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>${surefire.version}</version>
                <configuration>
                  <!-- Exclude Cloud Spanner integration tests that require a GCP project to run.
                  They can be run run manually using
                  TODO: Add support for emulator to run integration tests.
                  'mvn -Dexcluded.spanner.tests="" -Dtest=<testname> test' -->
                  <systemProperties>
                    <property>
                      <name>nashorn.args</name>
                      <value>--no-deprecation-warning</value>
                    </property>
                  </systemProperties>
                  <excludedGroups>${excluded.spanner.tests}</excludedGroups>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <!-- The following snapshot profile allows us to test teleport with
             unreleased apache sw. E.g. to test with a snapshot version of beam we
             could do
                  mvn test -Psnapshot -Dbeam.version=A.B.C-SNAPSHOT
          -->
        <profile>
            <id>snapshot</id>
            <repositories>
                <repository>
                    <id>apache.snapshots</id>
                    <url>https://repository.apache.org/content/repositories/snapshots</url>
                </repository>
            </repositories>
        </profile>
    </profiles>


    <modules>
        <module>bigquery-to-elasticsearch</module>
        <module>bigquery-to-parquet</module>
        <module>common</module>
        <module>cdc-parent</module>
        <module>csv-to-elasticsearch</module>
        <module>datastream-to-bigquery</module>
        <module>datastream-to-postgres</module>
        <module>datastream-to-spanner</module>
        <module>elasticsearch-common</module>
        <module>file-format-conversion</module>
        <module>hive-to-bigquery</module>
        <module>kafka-to-bigquery</module>
        <module>kafka-to-gcs</module>
        <module>kudu-to-bigquery</module>
        <module>pubsub-binary-to-bigquery</module>
        <module>pubsub-cdc-to-bigquery</module>
        <module>pubsub-to-elasticsearch</module>
        <module>pubsub-to-mongodb</module>
        <module>streaming-data-generator</module>
        <module>kafka-to-pubsub</module>
        <module>kafka-common</module>
    </modules>

</project>
