<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>

  <parent>
    <groupId>com.carrotsearch</groupId>
    <artifactId>hppc-parent</artifactId>
    <version>0.4.2</version>
    <relativePath>../pom.xml</relativePath>
  </parent>

  <!-- Project info. -->
  <groupId>com.carrotsearch</groupId>
  <artifactId>hppc</artifactId>
  <version>0.4.2</version>
  <packaging>jar</packaging>

  <name>HPPC Collections</name>
  <description>High Performance Primitive Collections. 
  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>

  <!-- Dependencies. -->
  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>com.google.guava</groupId>
      <artifactId>guava</artifactId>
      <optional>true</optional>
    </dependency>
  </dependencies>


  <properties>
    <retrotranslator.version>1.2.9</retrotranslator.version>
    <backport-util-concurrent.version>3.1</backport-util-concurrent.version>
  </properties>

  <!-- Build tuning. -->
  <build>
    <defaultGoal>install</defaultGoal>

    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-eclipse-plugin</artifactId>
          <configuration>
            <buildcommands>
              <buildCommand>
                <name>org.ui.externaltools.ExternalToolBuilder</name>
                <triggers>auto,full,</triggers>
                <arguments>
                  <LaunchConfigHandle>&lt;project&gt;/.externalToolBuilders/HPPC-generate-sources.launch</LaunchConfigHandle>
                </arguments>
              </buildCommand>
              <buildCommand>
                <name>org.eclipse.jdt.core.javabuilder</name>
              </buildCommand>
            </buildcommands>
          </configuration>
        </plugin>
      </plugins>
    </pluginManagement>

    <plugins>
      <!-- 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>
                <property name="classpath" refid="maven.plugin.classpath" />
                <echo file="${project.basedir}/.builder.classpath">${classpath}</echo>
                <ant antfile="${basedir}/build.xml" />
              </target>
            </configuration>
            <goals>
              <goal>run</goal>
            </goals>
          </execution>
          
          <execution>
            <id>antrun-retrotranslate-jdk15</id>
            <phase>package</phase>
            <configuration>
              <target>
                <taskdef name="retrotranslator"
                  classname="net.sf.retrotranslator.transformer.RetrotranslatorTask"
                  classpathref="maven.plugin.classpath" />

                <retrotranslator verbose="true" verify="false"
                  failonwarning="true" target="1.5" embed="com.carrotsearch.hppc.backport"
                  destjar="${project.build.directory}/${project.build.finalName}-jdk15.jar">

                  <jarfileset dir="${project.build.directory}"
                    includes="${project.build.finalName}.jar" />

                  <classpath>
                    <pathelement location="${basedir}/src/main/retrotranslator" />
                  </classpath>
                  <classpath refid="maven.plugin.classpath" />
                  <classpath refid="maven.compile.classpath" />
                  <classpath>
                    <fileset dir="${java.home}/lib" includes="rt.jar" />
                  </classpath>
                </retrotranslator>

                <attachartifact
                  file="${project.build.directory}/${project.build.finalName}-jdk15.jar"
                  classifier="jdk15" type="jar" />
              </target>
            </configuration>
            <goals>
              <goal>run</goal>
            </goals>
          </execution>
        </executions>

        <dependencies>
          <dependency>
            <groupId>com.carrotsearch</groupId>
            <artifactId>hppc-templateprocessor</artifactId>
            <version>${project.version}</version>
          </dependency>
          
          <dependency>
            <groupId>net.sf.retrotranslator</groupId>
            <artifactId>retrotranslator-transformer</artifactId>
            <version>${retrotranslator.version}</version>
          </dependency>

          <dependency>
            <groupId>net.sf.retrotranslator</groupId>
            <artifactId>retrotranslator-runtime</artifactId>
            <version>${retrotranslator.version}</version>
          </dependency>

          <dependency>
            <groupId>backport-util-concurrent</groupId>
            <artifactId>backport-util-concurrent</artifactId>
            <version>${backport-util-concurrent.version}</version>
          </dependency>
        </dependencies>
      </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.basedir}/src/main/templates</source>
                <source>${project.build.directory}/generated-sources/main/java</source>
              </sources>
            </configuration>
          </execution>

          <execution>
            <id>add-test-source</id>
            <phase>generate-sources</phase>
            <goals>
              <goal>add-test-source</goal>
            </goals>
            <configuration>
              <sources>
                <source>${project.basedir}/src/test/templates</source>
                <source>${project.build.directory}/generated-sources/test/java</source>
              </sources>
            </configuration>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <configuration>
          <includes>
            <include>**/*Test.*</include>
          </includes>
          <argLine>-ea -Xmx1024m</argLine>
        </configuration>
      </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>
      </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>
        <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>integration-test</defaultGoal>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-antrun-plugin</artifactId>
            <executions>
              <execution>
                <id>clover</id>
                <phase>integration-test</phase>
                <configuration>
                  <target>
                    <ant antfile="${basedir}/src/ant/clover.xml"
                      inheritRefs="true" inheritAll="true">
                      <property name="version" value="${project.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>
            </dependencies>
          </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>
            <executions>
              <execution>
                <id>make-labs-assembly</id>
                <phase>install</phase>
                <goals>
                  <goal>single</goal>
                </goals>
                <configuration>
                  <descriptors>
                    <descriptor>src/main/assembly/site-labs.xml</descriptor>
                  </descriptors>
                  <attach>false</attach>
                  <appendAssemblyId>false</appendAssemblyId>
                  <finalName>site-labs</finalName>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>

    <!-- Release mode (javadocs, sources, zip/tgz bundles, signing). -->
    <profile>
      <id>release</id>

      <build>
        <defaultGoal>package</defaultGoal>

        <plugins>
          <!-- Attach and modify JavaDocs. -->
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-javadoc-plugin</artifactId>
            <executions>
              <execution>
                <id>attach-javadocs</id>
                <configuration>
                  <encoding>${project.build.sourceEncoding}</encoding>
                  <stylesheetfile>${basedir}/src/main/javadoc/stylesheet.css</stylesheetfile>
                  <docfilessubdirs>true</docfilessubdirs>
                  <windowtitle>HPPC v${project.version} API Documentation
                    (JavaDoc)</windowtitle>
                  <doctitle>HPPC v${project.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${project.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>
                <goals>
                  <goal>jar</goal>
                </goals>
              </execution>
            </executions>
          </plugin>

          <!-- Attach sources -->
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-source-plugin</artifactId>
            <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>
            <executions>
              <execution>
                <id>make-release-assembly</id>
                <phase>package</phase>
                <goals>
                  <goal>single</goal>
                </goals>
                <configuration>
                  <descriptors>
                    <descriptor>src/main/assembly/bin.xml</descriptor>
                  </descriptors>
                  <tarLongFileMode>gnu</tarLongFileMode>
                  <attach>false</attach>
                  <appendAssemblyId>false</appendAssemblyId>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>
</project>
