<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.github.vsonnier</groupId>
		<artifactId>hppcrt-parent</artifactId>
		<version>0.7.1</version>
		<relativePath>../pom.xml</relativePath>
	</parent>

	<!-- Project info. -->
	<groupId>com.github.vsonnier</groupId>
	<artifactId>hppcrt</artifactId>
	<version>0.7.1</version>
	<packaging>jar</packaging>

	<name>HPPC-RT Collections</name>
	<description>High Performance Primitive Collections Realtime
 (fork of HPPC from Carrotsearch)
  Fundamental data structures (maps, sets, lists, queues, heaps, sorts) generated for
  combinations of object and primitive types to conserve JVM memory and speed
  up execution. The Realtime fork intends to extend the existing collections, by tweaking to remove any dynamic allocations at runtime,
  and to obtain low variance execution times whatever the input nature. 
	</description>
	
	<!-- Dependencies. -->
	<dependencies>
		<dependency>
			<groupId>junit</groupId>
			<artifactId>junit</artifactId>
			<version>${version.junit}</version>
			<scope>test</scope>
		</dependency>

		<dependency>
			<groupId>com.carrotsearch.randomizedtesting</groupId>
			<artifactId>randomizedtesting-runner</artifactId>
			<version>${version.randomizedtesting}</version>
			<scope>test</scope>
		</dependency>
	</dependencies>

	<properties>
		<version.retrotranslator>1.2.9</version.retrotranslator>
		<version.backport-util-concurrent>3.1</version.backport-util-concurrent>
	</properties>
	
	<!-- Build tuning. -->
	<build>
		<defaultGoal>install</defaultGoal>
		<plugins>
			<!-- Generate sources for primitives from template. -->
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-antrun-plugin</artifactId>
				<version>${version.maven-antrun-plugin}</version>
				<executions>
					<execution>
						<id>generate.sources</id>
						<phase>generate-sources</phase>
						<configuration>
							<fork>true</fork>
							<meminitial>256m</meminitial>
							<maxmem>512m</maxmem>
							<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.hppcrt.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.github.vsonnier</groupId>
						<artifactId>hppcrt-template-processor</artifactId>
						<version>${project.version}</version>
					</dependency>

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

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

					<dependency>
						<groupId>backport-util-concurrent</groupId>
						<artifactId>backport-util-concurrent</artifactId>
						<version>${version.backport-util-concurrent}</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-source-plugin</artifactId>
				<executions>
					<execution>
						<id>attach-sources</id>
						<goals>
							<goal>jar</goal>
						</goals>
					</execution>
				</executions>
			</plugin>
			
			<!-- Project in general is Java 7 level while the final lib is still 1.6 -->
			<plugin>
				<groupId>org.codehaus.mojo</groupId>
				<artifactId>animal-sniffer-maven-plugin</artifactId>
				<executions>
					<execution>
						<id>check-java-api</id>
						<phase>test</phase>
						<goals>
							<goal>check</goal>
						</goals>
						<configuration>
							<signature>
								<groupId>org.codehaus.mojo.signature
								</groupId>
								<artifactId>java16</artifactId>
								<version>1.0</version>
							</signature>
						</configuration>
					</execution>
				</executions>
			</plugin>
			
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-compiler-plugin</artifactId>
				<version>${version.maven-compiler-plugin}</version>
				<configuration>
					<source>${lib.hppcrt.source}</source>
					<target>${lib.hppcrt.source}</target>
					<testSource>${lib.hppcrt.source}</testSource>
					<testTarget>${lib.hppcrt.source}</testTarget>
					<compilerArgs>
						<arg>-Xlint</arg>
					</compilerArgs>
				</configuration>
			</plugin>

			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-javadoc-plugin</artifactId>
				<executions>
					<execution>
						<id>attach-javadocs</id>
						<configuration>
							<encoding>${project.build.sourceEncoding}</encoding>
							<windowtitle>HPPC-RT v${project.version} API Documentation</windowtitle>
							<doctitle>HPPC-RT v${project.version} API Documentation</doctitle>
							<header><![CDATA[<div id='header'><a class='logo' target='_top' href='https://github.com/vsonnier/hppcrt'></a>High Performance Primitive Collections Realtime(HPPC-RT) v${project.version} <br>API Documentation</div>]]></header>
							<failOnError>false</failOnError>
							<docfilessubdirs>true</docfilessubdirs>
							<use>false</use>
							<noindex>true</noindex>
							<notree>true</notree>
							<groups>
								<group>
									<title>HPPC-RT</title>
									<packages>com.carrotsearch.hppcrt*</packages>
								</group>
							</groups>
						</configuration>
						<goals>
							<goal>jar</goal>
						</goals>
					</execution>
				</executions>
			</plugin>

			<!-- Run tests with Randomizedtesting, instead of Surefire, but create a similar output -->
			<plugin>
				<groupId>com.carrotsearch.randomizedtesting</groupId>
				<artifactId>junit4-maven-plugin</artifactId>
				<executions>
					<execution>
						<id>junit4-tests</id>
						<goals>
							<goal>junit4</goal>
						</goals>
						<configuration>
							<includes>
								<include>**/*Test.*</include>
							</includes>
							<excludes>
								<exclude>**/*$*</exclude>
								<exclude>**/Abstract*</exclude>
							</excludes>

							<parallelism>auto</parallelism>
							<maxMemory>512m</maxMemory>

							<!-- Attach a simple listener. -->
							<listeners>
								<report-text showThrowable="false" 
											 showStackTraces="false" 
											 showOutput="onError"
											 showStatusOk="false"
											 showStatusError="false"
											 showStatusFailure="false"
											 showStatusIgnored="false"
											 showSuiteSummary="true" />

								<report-json file="${project.build.directory}/surefire-reports/test-results.html" />
								<report-ant-xml dir="${project.build.directory}/surefire-reports/" mavenExtensions="true" />
							</listeners>

							<assertions>
								<enable package="com.carrotsearch"/>
							</assertions>
						</configuration>
					</execution>
				</executions>
			</plugin>

		</plugins>
	</build>
	<profiles>
		<profile>
			<id>quick</id>
			<properties>
				<skipTests>true</skipTests> 
			</properties>
		</profile>
        <profile>
			<id>quicknodoc</id>
			<properties>
				<skipTests>true</skipTests>
                <maven.javadoc.skip>true</maven.javadoc.skip>
			</properties>
		</profile>
	</profiles>
</project>
