<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>com.google.cloud.spark</groupId>
    <artifactId>spark-bigquery-parent</artifactId>
    <version>0.23.2</version>
    <relativePath>../../spark-bigquery-parent</relativePath>
  </parent>

  <artifactId>spark-bigquery-dsv2-parent</artifactId>
  <name>BigQuery DataSource v2 implementation common settings</name>
  <packaging>pom</packaging>
  <properties>
    <spark.version>2.4.0</spark.version>
  </properties>
  <licenses>
    <license>
      <name>Apache License, Version 2.0</name>
      <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
      <distribution>repo</distribution>
    </license>
  </licenses>
  <dependencies>
    <dependency>
      <groupId>${project.groupId}</groupId>
      <artifactId>spark-bigquery-connector-common</artifactId>
      <version>${project.parent.version}</version>
    </dependency>
    <dependency>
      <groupId>org.apache.spark</groupId>
      <artifactId>spark-mllib_2.12</artifactId>
      <version>${spark.version}</version>
      <scope>provided</scope>
      <exclusions>
        <exclusion>
          <groupId>io.netty</groupId>
          <artifactId>netty</artifactId>
        </exclusion>
        <exclusion>
          <groupId>io.netty</groupId>
          <artifactId>netty-all</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
    <dependency>
      <groupId>org.apache.spark</groupId>
      <artifactId>spark-sql_2.12</artifactId>
      <version>${spark.version}</version>
      <scope>provided</scope>
      <exclusions>
        <exclusion>
          <groupId>io.netty</groupId>
          <artifactId>netty</artifactId>
        </exclusion>
        <exclusion>
          <groupId>io.netty</groupId>
          <artifactId>netty-all</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
    <dependency>
      <groupId>${project.groupId}</groupId>
      <artifactId>spark-bigquery-tests</artifactId>
      <version>${project.parent.version}</version>
      <scope>test</scope>
    </dependency>
  </dependencies>
  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-resources-plugin</artifactId>
        <executions>
          <execution>
            <id>copy-resources</id>
            <!-- here the phase you need -->
            <phase>validate</phase>
            <goals>
              <goal>copy-resources</goal>
            </goals>
            <configuration>
              <outputDirectory>${basedir}/target/classes</outputDirectory>
              <resources>
                <resource>
                  <directory>src/build/resources</directory>
                  <filtering>true</filtering>
                </resource>
              </resources>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-shade-plugin</artifactId>
        <configuration>
          <shadedArtifactAttached>false</shadedArtifactAttached>
          <relocations>
            <relocation>
              <pattern>android</pattern>
              <shadedPattern>
                com.google.cloud.spark.bigquery.repackaged.android
              </shadedPattern>
            </relocation>
            <relocation>
              <pattern>avro.shaded</pattern>
              <shadedPattern>
                com.google.cloud.spark.bigquery.repackaged.avro.shaded
              </shadedPattern>
            </relocation>
            <relocation>
              <pattern>com.fasterxml</pattern>
              <shadedPattern>
                com.google.cloud.spark.bigquery.repackaged.com.fasterxml
              </shadedPattern>
            </relocation>
            <relocation>
              <pattern>com.github</pattern>
              <shadedPattern>
                com.google.cloud.spark.bigquery.repackaged.com.github
              </shadedPattern>
            </relocation>
            <relocation>
              <pattern>com.google</pattern>
              <shadedPattern>
                com.google.cloud.spark.bigquery.repackaged.com.google
              </shadedPattern>
              <excludes>
                <exclude>com.google.cloud.bigquery.connector.common.**</exclude>
                <exclude>com.google.cloud.spark.bigquery.**</exclude>
              </excludes>
            </relocation>
            <relocation>
              <pattern>com.thoughtworks.paranamer</pattern>
              <shadedPattern>
                com.google.cloud.spark.bigquery.repackaged.com.thoughtworks.paranamer
              </shadedPattern>
            </relocation>
            <relocation>
              <pattern>com.typesafe</pattern>
              <shadedPattern>
                com.google.cloud.spark.bigquery.repackaged.com.typesafe
              </shadedPattern>
            </relocation>
            <relocation>
              <pattern>io.grpc</pattern>
              <shadedPattern>
                com.google.cloud.spark.bigquery.repackaged.io.grpc
              </shadedPattern>
            </relocation>
            <relocation>
              <pattern>io.netty</pattern>
              <shadedPattern>
                com.google.cloud.spark.bigquery.repackaged.io.netty
              </shadedPattern>
            </relocation>
            <relocation>
              <pattern>io.opencensus</pattern>
              <shadedPattern>
                com.google.cloud.spark.bigquery.repackaged.io.opencensus
              </shadedPattern>
            </relocation>
            <relocation>
              <pattern>io.perfmark</pattern>
              <shadedPattern>
                com.google.cloud.spark.bigquery.repackaged.io.perfmark
              </shadedPattern>
            </relocation>
            <relocation>
              <pattern>org.apache.arrow</pattern>
              <shadedPattern>
                com.google.cloud.spark.bigquery.repackaged.org.apache.arrow
              </shadedPattern>
            </relocation>
            <relocation>
              <pattern>org.apache.beam</pattern>
              <shadedPattern>
                com.google.cloud.spark.bigquery.repackaged.org.apache.beam
              </shadedPattern>
            </relocation>
            <relocation>
              <pattern>org.apache.commons</pattern>
              <shadedPattern>
                com.google.cloud.spark.bigquery.repackaged.org.apache.commons
              </shadedPattern>
            </relocation>
            <relocation>
              <pattern>org.apache.http</pattern>
              <shadedPattern>
                com.google.cloud.spark.bigquery.repackaged.org.apache.http
              </shadedPattern>
            </relocation>
            <relocation>
              <pattern>org.checkerframework</pattern>
              <shadedPattern>
                com.google.cloud.spark.bigquery.repackaged.org.checkerframework
              </shadedPattern>
            </relocation>
            <relocation>
              <pattern>org.codehaus.mojo</pattern>
              <shadedPattern>
                com.google.cloud.spark.bigquery.repackaged.org.codehaus.mojo
              </shadedPattern>
            </relocation>
            <relocation>
              <pattern>org.conscrypt</pattern>
              <shadedPattern>
                com.google.cloud.spark.bigquery.repackaged.org.conscrypt
              </shadedPattern>
            </relocation>
            <relocation>
              <pattern>org.json</pattern>
              <shadedPattern>
                com.google.cloud.spark.bigquery.repackaged.org.json
              </shadedPattern>
            </relocation>
            <relocation>
              <pattern>org.threeten</pattern>
              <shadedPattern>
                com.google.cloud.spark.bigquery.repackaged.org.threeten
              </shadedPattern>
            </relocation>
            <relocation>
              <pattern>org.tukaani.xz</pattern>
              <shadedPattern>
                com.google.cloud.spark.bigquery.repackaged.org.tukaani.xz
              </shadedPattern>
            </relocation>
            <relocation>
              <pattern>org.xerial.snappy</pattern>
              <shadedPattern>
                com.google.cloud.spark.bigquery.repackaged.org.xerial.snappy
              </shadedPattern>
            </relocation>
            <relocation>
              <pattern>META-INF/native/libnetty</pattern>
              <shadedPattern>
                META-INF/native/libcom_google_cloud_spark_bigquery_repackaged_netty
              </shadedPattern>
            </relocation>
            <relocation>
              <pattern>META-INF/native/netty</pattern>
              <shadedPattern>
                META-INF/native/com_google_cloud_spark_bigquery_repackaged_netty
              </shadedPattern>
            </relocation>
          </relocations>
          <transformers>
            <transformer
                implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
          </transformers>
          <filters>
            <filter>
              <artifact>*:*</artifact>
              <excludes>
                <exclude>module-info.class</exclude>
                <exclude>META-INF/*.MF</exclude>
                <exclude>META-INF/*.SF</exclude>
                <exclude>META-INF/*.DSA</exclude>
                <exclude>META-INF/*.RSA</exclude>
                <exclude>META-INF/maven/**</exclude>
                <exclude>**/*.proto</exclude>
              </excludes>
            </filter>
          </filters>
        </configuration>
        <executions>
          <execution>
            <phase>package</phase>
            <goals>
              <goal>shade</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>
