<?xml version="1.0" encoding="UTF-8"?>
<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.hydraql</groupId>
        <artifactId>hydraql</artifactId>
        <version>1.0.1</version>
    </parent>

    <artifactId>hydraql-shell_${hydraql.hbase.adapter.version}</artifactId>
    <packaging>jar</packaging>

    <properties>
        <shading.prefix>hydraql.shaded</shading.prefix>
    </properties>

    <dependencies>
        <dependency>
            <groupId>com.hydraql</groupId>
            <artifactId>hydraql-adapter-common</artifactId>
            <version>${project.version}</version>
            <exclusions>
                <exclusion>
                    <groupId>org.apache.hbase</groupId>
                    <artifactId>hbase-client</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>org.apache.hbase</groupId>
            <artifactId>hbase-server</artifactId>
            <exclusions>
                <exclusion>
                    <artifactId>slf4j-log4j12</artifactId>
                    <groupId>org.slf4j</groupId>
                </exclusion>
            </exclusions>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.jruby</groupId>
            <artifactId>jruby-complete</artifactId>
            <version>${jruby.verison}</version>
        </dependency>

        <dependency>
            <groupId>org.jruby.jcodings</groupId>
            <artifactId>jcodings</artifactId>
            <version>${jcodings.version}</version>
        </dependency>

        <dependency>
            <groupId>org.jruby.joni</groupId>
            <artifactId>joni</artifactId>
            <version>${joni.version}</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
            </plugin>

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

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <executions>
                    <execution>
                        <id>attach-javadocs</id>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <version>2.7</version>
                <executions>
                    <execution>
                        <id>copy-pom</id>
                        <phase>generate-resources</phase>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${project.build.directory}/${hydraql.hbase.adapter.version}</outputDirectory>
                            <resources>
                                <resource>
                                    <directory>${basedir}</directory>
                                    <includes>
                                        <include>pom.xml</include>
                                    </includes>
                                    <filtering>true</filtering>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>com.google.code.maven-replacer-plugin</groupId>
                <artifactId>replacer</artifactId>
                <version>1.5.3</version>
                <executions>
                    <execution>
                        <id>replace-artifactId</id>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>replace</goal>
                        </goals>
                        <configuration>
                            <ignoreMissingFile>false</ignoreMissingFile>
                            <file>${project.build.directory}/${hydraql.hbase.adapter.version}/pom.xml</file>
                            <replacements>
                                <replacement>
                                    <token>${project.artifactId}</token>
                                    <!-- Replace to -->
                                    <value>${project.artifactId}</value>
                                </replacement>
                            </replacements>
                            <outputDir>${project.build.directory}/${hydraql.hbase.adapter.version}/replacer</outputDir>
                            <outputFile>pom.xml</outputFile>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>templating-maven-plugin</artifactId>
                <version>3.0.0</version>
                <executions>
                    <execution>
                        <id>filter-src</id>
                        <goals>
                            <goal>filter-sources</goal>
                        </goals>
                        <configuration>
                            <sourceDirectory>${basedir}/src/main/java-templates</sourceDirectory>
                            <outputDirectory>${project.build.directory}/generated-sources/java-templates</outputDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-install-plugin</artifactId>
                <version>2.5.2</version>
                <executions>
                    <execution>
                        <id>default-install</id>
                        <configuration>
                            <skip>true</skip>
                        </configuration>
                    </execution>
                    <execution>
                        <id>install-scala-version</id>
                        <phase>install</phase>
                        <goals>
                            <goal>install-file</goal>
                        </goals>
                        <configuration>
                            <groupId>${project.groupId}</groupId>
                            <artifactId>${project.artifactId}</artifactId>
                            <version>${project.version}</version>
                            <packaging>${project.packaging}</packaging>
                            <file>
                                ${project.build.directory}/${project.artifactId}-${project.version}.jar
                            </file>
                            <pomFile>${project.build.directory}/${hydraql.hbase.adapter.version}/replacer/pom.xml</pomFile>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>3.2.3</version>
                <executions>
                    <execution>
                        <id>uber-jar</id>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                        <configuration>
                            <createSourcesJar>true</createSourcesJar>
                            <shadeSourcesContent>true</shadeSourcesContent>
                            <createDependencyReducedPom>true</createDependencyReducedPom>
                            <finalName>${artifactId}-${project.version}</finalName>
                            <shadedArtifactAttached>true</shadedArtifactAttached>
                            <filters>
                                <!-- Exclude source code included in non-source jar -->
                                <filter>
                                    <artifact>org.apache.zookeeper:zookeeper-jute</artifact>
                                    <excludes>
                                        <exclude>**/*.java</exclude>
                                    </excludes>
                                </filter>
                                <filter>
                                    <artifact>*:*</artifact>
                                    <excludes>
                                        <exclude>LICENSE</exclude>
                                        <exclude>META-INF/LICENSE</exclude>
                                        <exclude>META-INF/*.SF</exclude>
                                        <exclude>META-INF/*.DSA</exclude>
                                        <exclude>META-INF/*.RSA</exclude>
                                    </excludes>
                                </filter>
                            </filters>
                            <relocations>
                                <relocation>
                                    <pattern>com.google</pattern>
                                    <shadedPattern>${shading.prefix}.common.google</shadedPattern>
                                </relocation>
                            </relocations>
                            <transformers>
                                <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" />
                                <transformer implementation="org.apache.maven.plugins.shade.resource.ApacheLicenseResourceTransformer" />
                                <transformer implementation="org.apache.maven.plugins.shade.resource.DontIncludeResourceTransformer">
                                    <resources>
                                        <resource>NOTICE.txt</resource>
                                        <resource>NOTICE</resource>
                                        <resource>LICENSE</resource>
                                        <resource>Log4j-charsets.properties</resource>
                                        <resource>Log4j-config.xsd</resource>
                                        <resource>Log4j-events.dtd</resource>
                                        <resource>Log4j-events.xsd</resource>
                                        <resource>Log4j-levels.xsd</resource>
                                    </resources>
                                </transformer>
                            </transformers>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

</project>