<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/maven-v4_0_0.xsd">

  <modelVersion>4.0.0</modelVersion>

  <!-- We use SonaType for publishing artefacts. Parent POM makes things easier here. -->
  <parent>
    <groupId>org.sonatype.oss</groupId>
    <artifactId>oss-parent</artifactId>
    <version>5</version>
  </parent>

  <!-- Project info. -->
  <groupId>com.carrotsearch</groupId>
  <artifactId>hppc</artifactId>
  <version>0.3.4</version>
  <packaging>jar</packaging>

  <name>High Performance Primitive Collections</name>
  <description>Fundamental data structures (maps, sets, lists, stacks, queues) generated for
  combinations of object and primitive types to conserve JVM memory and speed
  up execution.</description>
  <url>http://labs.carrotsearch.com/hppc.html</url>


  <!-- Extended project info. -->
  <licenses>
    <license>
      <name>The Apache Software License, Version 2.0</name>
      <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
      <distribution>repo</distribution>
    </license>
  </licenses>

  <organization>
    <name>Carrot Search s.c.</name>
    <url>http://www.carrotsearch.com</url>
  </organization>

  <issueManagement>
    <system>Jira</system>
    <url>http://issues.carrot2.org/browse/HPPC</url>
  </issueManagement>

  <mailingLists>
    <mailingList>
      <name>Announcements and bug reports mailing list</name>
      <subscribe>java-high-performance-primitive-collections+subscribe@googlegroups.com</subscribe>
      <unsubscribe>java-high-performance-primitive-collections+unsubscribe@googlegroups.com</unsubscribe>
      <post>java-high-performance-primitive-collections@googlegroups.com</post>
    </mailingList>
  </mailingLists>

  <scm>
    <url>https://carrot2.svn.sourceforge.net/svnroot/carrot2/labs/hppc/trunk</url>
    <connection>scm:svn:https://carrot2.svn.sourceforge.net/svnroot/carrot2/labs/hppc/trunk</connection>
    <developerConnection>scm:svn:https://carrot2.svn.sourceforge.net/svnroot/carrot2/labs/hppc/trunk</developerConnection>
  </scm>

  <developers>
    <developer>
      <id>dawid.weiss</id>
      <name>Dawid Weiss</name>
      <email>dawid.weiss@carrotsearch.com</email>
    </developer>

    <developer>
      <id>stanislaw.osinski</id>
      <name>Stanisław Osiński</name>
      <email>stanislaw.osinski@carrotsearch.com</email>
    </developer>
  </developers>

  <!-- Global properties. -->
  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.source>1.6</maven.compiler.source>
    <maven.compiler.target>1.6</maven.compiler.target>
  </properties>


  <!-- Dependencies. -->
  <dependencies>
    <!-- Required for tests only. -->
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.7</version>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>com.carrotsearch</groupId>
      <artifactId>junit-benchmarks</artifactId>
      <version>0.2.1</version>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>com.h2database</groupId>
      <artifactId>h2</artifactId>
      <version>1.2.147</version>
      <scope>test</scope>
    </dependency>
  </dependencies>


  <!-- Build tuning. -->
  <build>
    <defaultGoal>install</defaultGoal>

    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-antrun-plugin</artifactId>
          <version>1.6</version>
          <inherited>false</inherited>

          <dependencies>
            <dependency>
              <groupId>org.apache.ant</groupId>
              <artifactId>ant-nodeps</artifactId>
              <version>1.8.0</version>
            </dependency>
            <dependency>
              <groupId>org.apache.ant</groupId>
              <artifactId>ant-trax</artifactId>
              <version>1.8.0</version>
            </dependency>
            <dependency>
              <groupId>org.apache.ant</groupId>
              <artifactId>ant-junit</artifactId>
              <version>1.8.0</version>
            </dependency>
          </dependencies>
        </plugin>

        <plugin>
          <groupId>org.codehaus.mojo</groupId>
          <artifactId>build-helper-maven-plugin</artifactId>
          <version>1.5</version>
        </plugin>

        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-eclipse-plugin</artifactId>
          <version>2.8</version>
        </plugin>

        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-surefire-plugin</artifactId>
          <version>2.7.1</version>
        </plugin>

        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-assembly-plugin</artifactId>
          <version>2.2</version>
        </plugin>
      </plugins>
    </pluginManagement>

    <plugins>
      <!-- Eclipse project generation. -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-eclipse-plugin</artifactId>
        <configuration>
          <buildOutputDirectory>${project.build.directory}/eclipse</buildOutputDirectory>
        </configuration>
      </plugin>

      <!-- Generate sources for primitives from template. -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-antrun-plugin</artifactId>

        <executions>
          <execution>
            <id>generate.sources</id>
            <phase>generate-sources</phase>
            <configuration>
              <target>
                <ant antfile="${basedir}/build.xml">
                  <target name="generate.sources" />
                  <target name="generate.test.sources" />
                </ant>
              </target>
            </configuration>
            <goals>
              <goal>run</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

      <!-- Add generated source locations. -->
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>build-helper-maven-plugin</artifactId>

        <executions>
          <execution>
            <id>add-source</id>
            <phase>generate-sources</phase>
            <goals>
              <goal>add-source</goal>
            </goals>
            <configuration>
              <sources>
                <source>${project.build.directory}/generated-sources/main/java</source>
              </sources>
            </configuration>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>build-helper-maven-plugin</artifactId>

        <executions>
          <execution>
            <id>add-test-source</id>
            <phase>generate-sources</phase>
            <goals>
              <goal>add-test-source</goal>
            </goals>
            <configuration>
              <sources>
                <source>${project.build.directory}/generated-sources/test/java</source>
              </sources>
            </configuration>
          </execution>
        </executions>
      </plugin>

      <!-- Include benchmarks in the test set. -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <configuration>
          <includes>
            <include>**/*Test.*</include>
            <include>**/*Benchmark.*</include>
          </includes>
          <argLine>-ea -Xmx1024m</argLine>
          <systemPropertyVariables>
            <jub.rounds.warmup>0</jub.rounds.warmup>
            <jub.rounds.benchmark>1</jub.rounds.benchmark>
            <jub.ignore.callgc>true</jub.ignore.callgc>
            <jub.ignore.annotations>true</jub.ignore.annotations>
          </systemPropertyVariables>
        </configuration>
      </plugin>

      <!-- Verify certain aspects in the generated code. -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-antrun-plugin</artifactId>
        <executions>
          <execution>
            <id>verify-generated-code</id>
            <phase>test</phase>
            <configuration>
              <target>
                <!-- Make sure the generated sources don't use Intrinsics.equals. -->
                <condition property="uses.intrinsics">
                  <resourcecount when="greater" count="0">
                    <fileset dir="${project.build.directory}/generated-sources"
                      id="fs.used.intrinsics">
                      <exclude name="**/Object*OpenHashMap*" />
                      <contains casesensitive="true" text="Intrinsics.equals" />
                    </fileset>
                  </resourcecount>
                </condition>

                <pathconvert property="intrinsic.offenders" pathsep=" ">
                  <fileset refid="fs.used.intrinsics" />
                </pathconvert>
                <fail if="uses.intrinsics">"Intrinsics" referred to from generated sources:
                  ${intrinsic.offenders}</fail>
              </target>
            </configuration>
            <goals>
              <goal>run</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

  <!-- Reports -->
  <reporting>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-pmd-plugin</artifactId>
        <version>2.5</version>
        <configuration>
          <targetJdk>${maven.compiler.target}</targetJdk>
          <aggregate>true</aggregate>
          <excludes>
            <exclude>**/BitUtil.java</exclude>
            <exclude>**/BitSet.java</exclude>
          </excludes>
        </configuration>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-report-plugin</artifactId>
        <version>2.7.1</version>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jxr-plugin</artifactId>
        <version>2.2</version>
      </plugin>

      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>findbugs-maven-plugin</artifactId>
        <version>2.3.1</version>
        <configuration>
          <excludeFilterFile>${basedir}/src/main/findbugs/excludes.xml</excludeFilterFile>
          <findbugsXmlOutput>true</findbugsXmlOutput>
        </configuration>
      </plugin>
    </plugins>
  </reporting>

  <profiles>
    <!-- Execute clover code coverage reports via ANT. -->
    <profile>
      <id>clover</id>

      <build>
        <defaultGoal>test-compile</defaultGoal>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-antrun-plugin</artifactId>
            <executions>
              <execution>
                <id>clover</id>
                <phase>test-compile<!-- test-compile, validate --></phase>
                <configuration>
                  <target>
                    <!-- This must be declared here because clover attempts to redefine 
                      it. -->
                    <property name="build.compiler"
                      value="org.eclipse.jdt.core.JDTCompilerAdapter" />
                    <ant antfile="${basedir}/src/ant/clover.xml"
                      inheritRefs="true" inheritAll="true">
                      <property name="version" value="${version}" />
                      <target name="test" />
                    </ant>
                  </target>
                </configuration>
                <goals>
                  <goal>run</goal>
                </goals>
              </execution>
            </executions>
            <dependencies>
              <dependency>
                <groupId>com.cenqua.clover</groupId>
                <artifactId>clover</artifactId>
                <version>3.0.2</version>
              </dependency>

              <!-- Use JDT for compilation. -->
              <dependency>
                <groupId>org.eclipse.jdt.core.compiler</groupId>
                <artifactId>ecj</artifactId>
                <version>3.5.1</version>
              </dependency>

              <!-- Or add system dependency on tools.jar -->
              <!-- <dependency> <groupId>sun.jdk</groupId> <artifactId>tools</artifactId> 
                <version>1.6.0</version> <scope>system</scope> <systemPath>${java.home}/../lib/tools.jar</systemPath> 
                </dependency> -->
            </dependencies>
          </plugin>
        </plugins>
      </build>
    </profile>

    <!-- Execute benchmarks and produce benchmark reports via ANT. -->
    <profile>
      <id>benchmark</id>

      <build>
        <defaultGoal>verify</defaultGoal>

        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-antrun-plugin</artifactId>
            <executions>
              <execution>
                <id>compile</id>
                <phase>verify</phase>
                <configuration>
                  <target>
                    <property name="benchmarks.report.dir"
                      location="${project.build.directory}/benchmarks" />
                    <mkdir dir="${benchmarks.report.dir}" />

                    <junit fork="true" forkmode="once" printsummary="on"
                      errorproperty="benchmarks.error" failureproperty="benchmarks.error">
                      <jvmarg value="-Xmx1024m" />
                      <jvmarg value="-server" />
                      <jvmarg value="-da" />

                      <jvmarg value="-Djub.consumers=h2,console" />
                      <jvmarg value="-Djub.db.file=.benchmark.db" />
                      <jvmarg value="-Djub.charts.dir=${benchmarks.report.dir}" />
                      <jvmarg value="-Dcustom.key=${build.number}" />

                      <formatter type="xml" />

                      <classpath refid="maven.test.classpath" />

                      <batchtest todir="${benchmarks.report.dir}">
                        <fileset dir="${project.build.directory}/test-classes">
                          <include name="**/*Benchmark.class" />
                          <exclude name="**/Abstract*" />
                        </fileset>
                      </batchtest>
                    </junit>

                    <fail
                      message="Benchmarks failed. See ${benchmarks.report.dir} for report."
                      if="benchmarks.error" />

                    <sql userid="sa" driver="org.h2.Driver" password=""
                      url="jdbc:h2:.benchmark.db;IFEXISTS=TRUE" classpathref="maven.test.classpath"
                      print="true" showheaders="false" showtrailers="false"
                      output="${benchmarks.report.dir}/results.txt"
                      src="${basedir}/src/main/benchmarks/benchmark-report.sql" />

                    <concat>
                      <path>
                        <pathelement location="${benchmarks.report.dir}/results.txt" />
                      </path>
                    </concat>
                  </target>
                </configuration>
                <goals>
                  <goal>run</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>

    <!-- Labs' site rsync assembly. -->
    <profile>
      <id>site-labs</id>

      <build>
        <defaultGoal>assembly:single</defaultGoal>

        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-assembly-plugin</artifactId>
            <configuration>
              <descriptors>
                <descriptor>src/main/assembly/site-labs.xml</descriptor>
              </descriptors>
              <attach>false</attach>
              <appendAssemblyId>false</appendAssemblyId>
              <finalName>site-labs</finalName>
            </configuration>
            <executions>
              <execution>
                <id>make-assembly</id>
                <phase>package</phase>
                <goals>
                  <goal>single</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>

    <!-- Release mode (javadocs, sources, zip/tgz bundles). -->
    <profile>
      <id>release</id>

      <build>
        <defaultGoal>install</defaultGoal>

        <plugins>
          <!-- Attach and modify JavaDocs. -->
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-javadoc-plugin</artifactId>
            <version>2.6.1</version>
            <configuration>
              <encoding>${project.build.sourceEncoding}</encoding>
              <stylesheetfile>${basedir}/src/main/javadoc/stylesheet.css</stylesheetfile>
              <docfilessubdirs>true</docfilessubdirs>
              <windowtitle>HPPC v${version} API Documentation (JavaDoc)</windowtitle>
              <doctitle>HPPC v${version} API Documentation</doctitle>
              <header><![CDATA[<div id='header'><a class='logo' target='_top' href='http://labs.carrotsearch.com'></a>High Performance Primitive Collections (HPPC) v${version} <br>API Documentation</div>]]></header>
              <overview>${basedir}/src/main/java/com/carrotsearch/hppc/package.html</overview>
              <failonerror>true</failonerror>
              <use>false</use>
              <groups>
                <group>
                  <title>HPPC</title>
                  <packages>com.carrotsearch.hppc*</packages>
                </group>
              </groups>
            </configuration>
            <executions>
              <execution>
                <id>attach-javadocs</id>
                <goals>
                  <goal>jar</goal>
                </goals>
              </execution>
            </executions>
          </plugin>

          <!-- Attach sources -->
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-source-plugin</artifactId>
            <version>2.1.2</version>
            <executions>
              <execution>
                <id>attach-sources</id>
                <goals>
                  <goal>jar</goal>
                </goals>
              </execution>
            </executions>
          </plugin>

          <!-- Configure assembly of ZIP and TAR.GZ bundles (stand-alone distributions). -->
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-assembly-plugin</artifactId>
            <configuration>
              <descriptors>
                <descriptor>src/main/assembly/bin.xml</descriptor>
              </descriptors>
              <tarLongFileMode>gnu</tarLongFileMode>
              <attach>false</attach>
              <appendAssemblyId>false</appendAssemblyId>
            </configuration>
            <executions>
              <execution>
                <id>make-assembly</id>
                <phase>package</phase>
                <goals>
                  <goal>single</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>

    <!-- Manual release mode. Prepare bundle ZIPs, sign everything once completed 
      and prepare sonatype's release bundle. -->
    <profile>
      <id>sonatype</id>
      <build>
        <defaultGoal>verify</defaultGoal>

        <plugins>
          <!-- GPG sign artefacts. -->
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-gpg-plugin</artifactId>
            <version>1.1</version>
            <configuration>
              <excludes>
                <exclude>**/*.gz</exclude>
                <exclude>**/*.zip</exclude>
              </excludes>
            </configuration>
            <executions>
              <execution>
                <goals>
                  <goal>sign</goal>
                </goals>
              </execution>
            </executions>
          </plugin>

          <!-- Create a release bundle for SonaType. -->
          <plugin>
          <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-assembly-plugin</artifactId>
            <configuration>
              <descriptors>
                <descriptor>src/main/assembly/release.xml</descriptor>
              </descriptors>
              <tarLongFileMode>gnu</tarLongFileMode>
              <finalName>release-bundle</finalName>
              <attach>false</attach>
              <appendAssemblyId>false</appendAssemblyId>
            </configuration>
            <executions>
              <execution>
                <id>make-assembly</id>
                <phase>verify</phase>
                <goals>
                  <goal>single</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>
</project>
