<?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>org.dellroad</groupId>
        <artifactId>leveldb-project</artifactId>
        <version>0.9</version>
    </parent>

    <artifactId>leveldb</artifactId>
    <name>${project.artifactId}</name>
    <description>Port of LevelDB to Java</description>

    <properties>
        <air.main.basedir>${project.parent.basedir}</air.main.basedir>
    </properties>

    <dependencies>

        <dependency>
            <groupId>org.dellroad</groupId>
            <artifactId>leveldb-api</artifactId>
        </dependency>

        <dependency>
            <groupId>org.xerial.snappy</groupId>
            <artifactId>snappy-java</artifactId>
            <version>1.1.2.6 </version>
            <optional>true</optional>
        </dependency>

        <dependency>
            <groupId>org.iq80.snappy</groupId>
            <artifactId>snappy</artifactId>
            <version>0.4</version>
            <optional>true</optional>
        </dependency>

        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
        </dependency>

        <!-- only needed for ProGuard -->
        <dependency>
            <groupId>com.google.code.findbugs</groupId>
            <artifactId>annotations</artifactId>
            <optional>true</optional>
            <scope>provided</scope>
        </dependency>

        <!-- for testing -->
        <dependency>
            <groupId>joda-time</groupId>
            <artifactId>joda-time</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.testng</groupId>
            <artifactId>testng</artifactId>
            <scope>test</scope>
        </dependency>

        <!-- to verify file format compatibility with the native leveldb impl -->
        <dependency>
            <groupId>org.fusesource.leveldbjni</groupId>
            <artifactId>leveldbjni</artifactId>
            <version>1.1</version>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.iq80.leveldb</groupId>
                    <artifactId>leveldb-api</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>1.4</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <shadedArtifactAttached>true</shadedArtifactAttached>
                    <shadedClassifierName>uber</shadedClassifierName>
                    <relocations>
                        <relocation>
                            <pattern>com.google.common</pattern>
                            <shadedPattern>org.iq80.leveldb.shaded.guava</shadedPattern>
                        </relocation>
                    </relocations>
                </configuration>
            </plugin>
            <plugin>
                <groupId>com.github.wvengen</groupId>
                <artifactId>proguard-maven-plugin</artifactId>
                <version>2.0.5</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>proguard</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <proguardVersion>4.8</proguardVersion>
                    <injar>${project.build.finalName}.jar</injar>
                    <outjar>${project.build.finalName}-slim.jar</outjar>
                    <attach>true</attach>
                    <attachArtifactClassifier>min</attachArtifactClassifier>
                    <libs>
                        <lib>${rt.jar.path}</lib>
                        <lib>${jsse.jar.path}</lib>
                    </libs>
                    <assembly>
                        <inclusions>
                            <inclusion>
                                <groupId>org.dellroad</groupId>
                                <artifactId>leveldb-api</artifactId>
                            </inclusion>
                            <inclusion>
                                <groupId>org.iq80.snappy</groupId>
                                <artifactId>snappy</artifactId>
                            </inclusion>
                            <inclusion>
                                <groupId>com.google.guava</groupId>
                                <artifactId>guava</artifactId>
                            </inclusion>
                        </inclusions>
                    </assembly>

                    <obfuscate>false</obfuscate>
                    <options>
                        <option>-keep class org.iq80.leveldb.*{*;}</option>
                        <option>-keep class org.iq80.leveldb.impl.*{*;}</option>
                        <option>-keep class org.iq80.leveldb.util.*{*;}</option>

                        <option>-keep class com.google.common.collect.ImmutableList{*;}</option>
                        <option>-keep class com.google.common.base.Preconditions{*;}</option>

                        <option>-keep class org.iq80.snappy.*{*;}</option>
                        <!-- <option>-keep class org.xerial.snappy.Snappy{*;}</option> -->
                        <option>-dontnote com.google.common.cache.Striped64</option>
                        <option>-dontnote com.google.common.cache.Striped64$*</option>
                        <option>-dontnote com.google.common.util.concurrent.MoreExecutors</option>
                        <option>-dontwarn com.google.common.collect.MinMaxPriorityQueue</option>
                        <option>-dontwarn org.xerial.snappy.SnappyLoader</option>
                        <option>-dontwarn org.xerial.snappy.SnappyBundleActivator</option>
                        <option>-dontwarn org.iq80.snappy.HadoopSnappyCodec**</option>
                        <option>-dontoptimize</option>
                    </options>
                </configuration>
                <dependencies>
                    <dependency>
                        <groupId>net.sf.proguard</groupId>
                        <artifactId>proguard-base</artifactId>
                        <version>4.8</version>
                        <scope>runtime</scope>
                    </dependency>
                </dependencies>
            </plugin>
        </plugins>

        <resources>
            <resource>
                <directory>${project.basedir}/src/main/resources</directory>
                <filtering>true</filtering>
                <includes>
                    <include>**/*</include>
                </includes>
            </resource>
        </resources>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <configuration>
                        <excludes>
                        </excludes>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>

    <profiles>
        <profile>
            <id>lib/rt.jar</id>
            <activation>
                <file>
                    <exists>${java.home}/lib/rt.jar</exists>
                </file>
            </activation>
            <properties>
                <rt.jar.path>${java.home}/lib/rt.jar</rt.jar.path>
                <jsse.jar.path>${java.home}/lib/jsse.jar</jsse.jar.path>
            </properties>
        </profile>
        <profile>
            <id>Classes/classes.jar</id>
            <activation>
                <file>
                    <exists>${java.home}/../Classes/classes.jar</exists>
                </file>
            </activation>
            <properties>
                <rt.jar.path>${java.home}/../Classes/classes.jar</rt.jar.path>
                <jsse.jar.path>${java.home}/../Classes/jsse.jar</jsse.jar.path>
            </properties>
        </profile>
        <profile>
            <id>jre/lib/rt.jar</id>
            <activation>
                <file>
                    <exists>${java.home}/jre/lib/rt.jar</exists>
                </file>
            </activation>
            <properties>
                <rt.jar.path>${java.home}/jre/lib/rt.jar</rt.jar.path>
                <jsse.jar.path>${java.home}/jre/lib/jsse.jar</jsse.jar.path>
            </properties>
        </profile>
    </profiles>
</project>
