<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <modelVersion>4.0.0</modelVersion>

    <groupId>org.rocksdb</groupId>
    <artifactId>rocksdbjni</artifactId>
    <version>10.4.2</version>  <!-- this will be replaced by the Makefile's rocksdbjavageneratepom target -->

    <name>RocksDB JNI</name>
    <description>RocksDB fat jar that contains .so files for linux32 and linux64 (glibc and musl-libc), jnilib files
        for Mac OSX, and a .dll for Windows x64.
    </description>
    <url>https://rocksdb.org</url>
    <inceptionYear>2012</inceptionYear>

    <licenses>
        <license>
            <name>Apache License 2.0</name>
            <url>http://www.apache.org/licenses/LICENSE-2.0.html</url>
            <distribution>repo</distribution>
        </license>
        <license>
            <name>GNU General Public License, version 2</name>
            <url>http://www.gnu.org/licenses/gpl-2.0.html</url>
            <distribution>repo</distribution>
        </license>
    </licenses>

    <scm>
        <connection>scm:git:https://github.com/facebook/rocksdb.git</connection>
        <developerConnection>scm:git:https://github.com/facebook/rocksdb.git</developerConnection>
        <url>scm:git:https://github.com/facebook/rocksdb.git</url>
    </scm>

    <organization>
        <name>Facebook</name>
        <url>https://www.facebook.com</url>
    </organization>

    <developers>
        <developer>
            <name>Facebook</name>
            <email>help@facebook.com</email>
            <timezone>America/New_York</timezone>
            <roles>
                <role>architect</role>
            </roles>
        </developer>
    </developers>

    <mailingLists>
        <mailingList>
            <name>rocksdb - Google Groups</name>
            <subscribe>rocksdb-subscribe@googlegroups.com</subscribe>
            <unsubscribe>rocksdb-unsubscribe@googlegroups.com</unsubscribe>
            <post>rocksdb@googlegroups.com</post>
            <archive>https://groups.google.com/forum/#!forum/rocksdb</archive>
        </mailingList>
    </mailingLists>

    <properties>
        <project.build.source>1.8</project.build.source>
        <project.build.target>1.8</project.build.target>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.13.1</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.hamcrest</groupId>
            <artifactId>hamcrest</artifactId>
            <version>2.2</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>cglib</groupId>
            <artifactId>cglib</artifactId>
            <version>3.3.0</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.assertj</groupId>
            <artifactId>assertj-core</artifactId>
            <version>2.9.0</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-all</artifactId>
            <version>1.10.19</version>
            <scope>test</scope>
        </dependency>
   </dependencies>

    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.14.0</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <version>3.5.3</version>
                </plugin>
                <plugin>
                    <groupId>org.jacoco</groupId>
                    <artifactId>jacoco-maven-plugin</artifactId>
                    <version>0.7.2.201409121644</version>
                </plugin>
                <plugin>
                    <groupId>org.codehaus.gmaven</groupId>
                    <artifactId>groovy-maven-plugin</artifactId>
                    <version>2.1.1</version>
                </plugin>
                <plugin>
                    <groupId>com.github.spotbugs</groupId>
                    <artifactId>spotbugs-maven-plugin</artifactId>
                    <version>4.7.2.1</version>
                    <dependencies>
                        <dependency>
                            <groupId>com.github.spotbugs</groupId>
                            <artifactId>spotbugs</artifactId>
                            <version>4.7.3</version>
                        </dependency>
                    </dependencies>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-pmd-plugin</artifactId>
                    <version>3.20.0</version>     
                </plugin>
            </plugins>
        </pluginManagement>
    </build>

    <profiles>
        <profile>
            <!--
                NOTE(AR) This profile allows local development using Maven (active by default)
                This is needed to prevent building when doing a release (see `release-all` profile)
                which is done through Make.
            -->
            <id>local-dev</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-compiler-plugin</artifactId>
                        <configuration>
                            <source>${project.build.source}</source>
                            <target>${project.build.target}</target>
                            <encoding>${project.build.sourceEncoding}</encoding>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <configuration>
                            <argLine>${argLine} -ea -Xcheck:jni -Djava.library.path=${project.build.directory}</argLine>
                            <useManifestOnlyJar>false</useManifestOnlyJar>  
                            <useSystemClassLoader>false</useSystemClassLoader>
                            <additionalClasspathElements>
                                <additionalClasspathElement>${project.build.directory}/*</additionalClasspathElement>
                            </additionalClasspathElements>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>org.jacoco</groupId>
                        <artifactId>jacoco-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>prepare-agent</id>
                                <goals>
                                    <goal>prepare-agent</goal>
                                </goals>
                            </execution>
                            <execution>
                                <id>report</id>
                                <phase>prepare-package</phase>
                                <goals>
                                    <goal>report</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.codehaus.gmaven</groupId>
                        <artifactId>groovy-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <phase>process-classes</phase>
                                <goals>
                                    <goal>execute</goal>
                                </goals>
                                <configuration>
                                    <defaults>
                                        <name>Xenu</name>
                                    </defaults>
                                    <source>
                                        String fileContents = new File(project.basedir.absolutePath + '/../include/rocksdb/version.h').getText('UTF-8')
                                        matcher = (fileContents =~ /(?s).*ROCKSDB_MAJOR ([0-9]+).*?/)
                                        String major_version = matcher.getAt(0).getAt(1)
                                        matcher = (fileContents =~ /(?s).*ROCKSDB_MINOR ([0-9]+).*?/)
                                        String minor_version = matcher.getAt(0).getAt(1)
                                        matcher = (fileContents =~ /(?s).*ROCKSDB_PATCH ([0-9]+).*?/)
                                        String patch_version = matcher.getAt(0).getAt(1)
                                        String version = String.format('%s.%s.%s', major_version, minor_version, patch_version)
                                        // Set version to be used in pom.properties
                                        project.version = version
                                        // Set version to be set as jar name
                                        project.build.finalName = project.artifactId + "-" + version
                                    </source>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>com.github.spotbugs</groupId>
                        <artifactId>spotbugs-maven-plugin</artifactId>
                        <configuration>
                            <excludeFilterFile>spotbugs-exclude.xml</excludeFilterFile>
                        </configuration>          
                        <dependencies>
                            <!-- overwrite dependency on spotbugs if you want to specify the version of spotbugs -->
                            <dependency>
                                <groupId>com.github.spotbugs</groupId>
                                <artifactId>spotbugs</artifactId>
                                <version>4.7.3</version>
                            </dependency>
                        </dependencies>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-pmd-plugin</artifactId>
                        <executions>
                        <execution>
                            <goals>
                                <goal>check</goal>
                                <goal>cpd-check</goal>
                            </goals>
                        </execution>
                        </executions>
                        <configuration>
                            <rulesets>
                            <!-- A rule set, that comes bundled with PMD -->
                            <ruleset>/pmd-rules.xml</ruleset>
                            <!-- A rule set, that comes bundled with PMD -->
                            <!-- <ruleset>/category/java/errorprone.xml</ruleset> -->
                            </rulesets>
                        </configuration>          
                    </plugin>
                </plugins>
            </build>
        </profile>

        <profile>
            <id>release-all</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-compiler-plugin</artifactId>
                        <configuration>
                            <skipMain>true</skipMain>
                            <skip>true</skip>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <configuration>
                            <skip>true</skip>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>org.jacoco</groupId>
                        <artifactId>jacoco-maven-plugin</artifactId>
                        <configuration>
                            <skip>true</skip>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>org.codehaus.gmaven</groupId>
                        <artifactId>groovy-maven-plugin</artifactId>
                        <configuration>
                            <skip>true</skip>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>com.github.spotbugs</groupId>
                        <artifactId>spotbugs-maven-plugin</artifactId>
                        <version>4.7.2.1</version>
                        <configuration>
                            <skip>true</skip>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-pmd-plugin</artifactId>
                        <configuration>
                            <skip>true</skip>
                        </configuration>
                    </plugin>

                    <plugin>
                        <!--
                            NOTE(AR) As our artifacts are built by Make before we use Maven to deploy,
                            we have to manually attach them here.
                        -->
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>build-helper-maven-plugin</artifactId>
                        <version>3.6.1</version>
                        <executions>
                            <execution>
                                <id>attach-artifacts</id>
                                <phase>verify</phase>
                                <goals>
                                    <goal>attach-artifact</goal>
                                </goals>
                                <configuration>
                                    <artifacts>
					<!--
                                        <artifact>
                                            <file>${project.build.directory}/rocksdbjni-${project.version}.jar</file>
                                            <type>jar</type>
                                        </artifact>
					-->
                                        <artifact>
                                            <file>${project.build.directory}/rocksdbjni-${project.version}-javadoc.jar</file>
                                            <type>jar</type>
                                            <classifier>javadoc</classifier>
                                        </artifact>
                                        <artifact>
                                            <file>${project.build.directory}/rocksdbjni-${project.version}-sources.jar</file>
                                            <type>jar</type>
                                            <classifier>sources</classifier>
                                        </artifact>
                                        <artifact>
                                            <file>${project.build.directory}/rocksdbjni-${project.version}-linux64.jar</file>
                                            <type>jar</type>
                                            <classifier>linux64</classifier>
                                        </artifact>
                                        <artifact>
                                            <file>${project.build.directory}/rocksdbjni-${project.version}-linux32.jar</file>
                                            <type>jar</type>
                                            <classifier>linux32</classifier>
                                        </artifact>
                                        <artifact>
                                            <file>${project.build.directory}/rocksdbjni-${project.version}-linux64-musl.jar</file>
                                            <type>jar</type>
                                            <classifier>linux64-musl</classifier>
                                        </artifact>
                                        <artifact>
                                            <file>${project.build.directory}/rocksdbjni-${project.version}-linux32-musl.jar</file>
                                            <type>jar</type>
                                            <classifier>linux32-musl</classifier>
                                        </artifact>
                                        <artifact>
                                            <file>${project.build.directory}/rocksdbjni-${project.version}-osx.jar</file>
                                            <type>jar</type>
                                            <classifier>osx</classifier>
                                        </artifact>
                                        <artifact>
                                            <file>${project.build.directory}/rocksdbjni-${project.version}-win64.jar</file>
                                            <type>jar</type>
                                            <classifier>win64</classifier>
                                        </artifact>
                                    </artifacts>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-gpg-plugin</artifactId>
                        <version>3.2.8</version>
                        <executions>
                            <execution>
                                <id>sign-artifacts</id>
                                <phase>verify</phase>
                                <goals>
                                    <goal>sign</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.sonatype.central</groupId>
                        <artifactId>central-publishing-maven-plugin</artifactId>
                        <version>0.8.0</version>
                        <extensions>true</extensions>
                        <configuration>
                            <publishingServerId>central</publishingServerId>
                            <deploymentName>${project.artifactId}-${project.version}</deploymentName>
                            <failOnBuildFailure>true</failOnBuildFailure>
                            <waitUntil>validated</waitUntil>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

    <reporting>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jxr-plugin</artifactId>
                <version>3.3.0</version>
            </plugin>
        </plugins>
    </reporting>

</project>
