<?xml version="1.0" encoding="UTF-8"?>
<!--
    Copyright 2015-2016 The OpenZipkin Authors
    Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
    in compliance with the License. You may obtain a copy of the License at
    http://www.apache.org/licenses/LICENSE-2.0
    Unless required by applicable law or agreed to in writing, software distributed under the License
    is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
    or implied. See the License for the specific language governing permissions and limitations under
    the License.
-->
<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>

	<name>Benchmarks</name>
	<description>Benchmarks (JMH)</description>
	<groupId>org.springframework.cloud</groupId>
	<version>1.3.3.BUILD-SNAPSHOT</version>
	<artifactId>benchmarks</artifactId>

	<properties>
		<main.basedir>${project.basedir}/..</main.basedir>
		<jmh.version>1.16</jmh.version>
		<maven-shade-plugin.version>2.4.3</maven-shade-plugin.version>
		<maven-install-plugin.version>2.5.2</maven-install-plugin.version>
		<sonar.skip>true</sonar.skip>
		<maven.compiler.target>1.8</maven.compiler.target>
		<maven.compiler.source>1.8</maven.compiler.source>
	</properties>

	<dependencyManagement>
		<dependencies>
			<dependency>
				<groupId>org.springframework.cloud</groupId>
				<artifactId>spring-cloud-sleuth-dependencies</artifactId>
				<version>${project.version}</version>
				<type>pom</type>
				<scope>import</scope>
			</dependency>
			<dependency>
				<!-- Import dependency management from Spring Boot -->
				<groupId>org.springframework.boot</groupId>
				<artifactId>spring-boot-dependencies</artifactId>
				<version>1.5.4.RELEASE</version>
				<type>pom</type>
				<scope>import</scope>
			</dependency>
		</dependencies>
	</dependencyManagement>

	<dependencies>
		<dependency>
			<groupId>${project.groupId}</groupId>
			<artifactId>spring-cloud-sleuth-core</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-web</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-configuration-processor</artifactId>
		</dependency>

		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-test</artifactId>
			<scope>compile</scope>
		</dependency>
		<dependency>
			<groupId>org.aspectj</groupId>
			<artifactId>aspectjrt</artifactId>
		</dependency>
		<dependency>
			<groupId>org.aspectj</groupId>
			<artifactId>aspectjweaver</artifactId>
		</dependency>
		<dependency>
			<groupId>org.assertj</groupId>
			<artifactId>assertj-core</artifactId>
			<version>3.5.2</version>
			<scope>compile</scope>
		</dependency>
		<dependency>
			<groupId>org.hamcrest</groupId>
			<artifactId>hamcrest-core</artifactId>
			<version>1.3</version>
			<scope>compile</scope>
		</dependency>

		<dependency>
			<groupId>org.openjdk.jmh</groupId>
			<artifactId>jmh-core</artifactId>
			<version>${jmh.version}</version>
		</dependency>

		<dependency>
			<groupId>org.openjdk.jmh</groupId>
			<artifactId>jmh-generator-annprocess</artifactId>
			<version>${jmh.version}</version>
			<scope>provided</scope>
		</dependency>
	</dependencies>

	<build>
		<plugins>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-compiler-plugin</artifactId>
				<version>3.1</version>
				<configuration>
					<source>${maven.compiler.source}</source>
					<target>${maven.compiler.target}</target>
				</configuration>
			</plugin>
			<plugin>
				<!--skip deploy (this is just a test module) -->
				<artifactId>maven-deploy-plugin</artifactId>
				<configuration>
					<skip>true</skip>
				</configuration>
			</plugin>
			<plugin>
				<artifactId>maven-install-plugin</artifactId>
				<version>${maven-install-plugin.version}</version>
				<configuration>
					<skip>true</skip>
				</configuration>
			</plugin>
		</plugins>
	</build>

	<repositories>
		<repository>
			<id>spring-snapshots</id>
			<name>Spring Snapshots</name>
			<url>https://repo.spring.io/libs-snapshot-local</url>
			<snapshots>
				<enabled>true</enabled>
			</snapshots>
			<releases>
				<enabled>false</enabled>
			</releases>
		</repository>
		<repository>
			<id>spring-milestones</id>
			<name>Spring Milestones</name>
			<url>https://repo.spring.io/libs-milestone-local</url>
			<snapshots>
				<enabled>false</enabled>
			</snapshots>
		</repository>
		<repository>
			<id>spring-releases</id>
			<name>Spring Releases</name>
			<url>https://repo.spring.io/release</url>
			<snapshots>
				<enabled>false</enabled>
			</snapshots>
		</repository>
	</repositories>

	<profiles>
		<profile>
			<id>jmh</id>
			<activation>
				<activeByDefault>false</activeByDefault>
			</activation>
			<build>
				<plugins>
					<plugin>
						<artifactId>maven-shade-plugin</artifactId>
						<version>${maven-shade-plugin.version}</version>
						<dependencies>
							<dependency>
								<groupId>org.springframework.boot</groupId>
								<artifactId>spring-boot-maven-plugin</artifactId>
								<version>1.3.3.RELEASE</version>
							</dependency>
						</dependencies>
						<configuration>
							<keepDependenciesWithProvidedScope>true
							</keepDependenciesWithProvidedScope>
							<createDependencyReducedPom>true</createDependencyReducedPom>
							<filters>
								<filter>
									<artifact>*:*</artifact>
									<excludes>
										<exclude>META-INF/*.SF</exclude>
										<exclude>META-INF/*.DSA</exclude>
										<exclude>META-INF/*.RSA</exclude>
									</excludes>
								</filter>
							</filters>
						</configuration>
						<executions>
							<execution>
								<phase>package</phase>
								<goals>
									<goal>shade</goal>
								</goals>
								<configuration>
									<finalName>benchmarks</finalName>
									<transformers>
										<transformer
												implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
											<resource>META-INF/spring.handlers</resource>
										</transformer>
										<transformer
												implementation="org.springframework.boot.maven.PropertiesMergingResourceTransformer">
											<resource>META-INF/spring.factories</resource>
										</transformer>
										<transformer
												implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
											<resource>META-INF/spring.schemas</resource>
										</transformer>
										<transformer
												implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
										<transformer
												implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
											<mainClass>org.openjdk.jmh.Main</mainClass>
										</transformer>
									</transformers>
									<createDependencyReducedPom>false</createDependencyReducedPom>
								</configuration>
							</execution>
						</executions>
					</plugin>
				</plugins>
			</build>
		</profile>
		<profile>
			<id>jmeter</id>
			<activation>
				<activeByDefault>false</activeByDefault>
			</activation>
			<build>
				<plugins>
					<plugin>
						<groupId>org.springframework.boot</groupId>
						<artifactId>spring-boot-maven-plugin</artifactId>
						<version>1.5.4.RELEASE</version>
						<executions>
							<execution>
								<goals>
									<goal>repackage</goal>
								</goals>
							</execution>
							<execution>
								<id>start-non-sleuth-app</id>
								<phase>pre-integration-test</phase>
								<goals>
									<goal>start</goal>
								</goals>
								<configuration>
									<jvmArguments>"-Dserver.port=9875" "-Dspring.sleuth.enabled=false"</jvmArguments>
									<jmxPort>8875</jmxPort>
									<fork>true</fork>
								</configuration>
							</execution>
							<execution>
								<id>stop-non-sleuth-app</id>
								<phase>post-integration-test</phase>
								<goals>
									<goal>stop</goal>
								</goals>
								<configuration>
									<jmxPort>8875</jmxPort>
									<fork>true</fork>
								</configuration>
							</execution>
							<execution>
								<id>start-sleuth-app</id>
								<phase>pre-integration-test</phase>
								<goals>
									<goal>start</goal>
								</goals>
								<configuration>
									<jvmArguments>"-Dserver.port=9876"</jvmArguments>
									<jmxPort>8876</jmxPort>
									<fork>true</fork>
								</configuration>
							</execution>
							<execution>
								<id>stop-sleuth-app</id>
								<phase>post-integration-test</phase>
								<goals>
									<goal>stop</goal>
								</goals>
								<configuration>
									<jmxPort>8876</jmxPort>
									<fork>true</fork>
								</configuration>
							</execution>
						</executions>
					</plugin>
					<plugin>
						<groupId>org.apache.maven.plugins</groupId>
						<artifactId>maven-failsafe-plugin</artifactId>
						<version>2.19.1</version>
						<executions>
							<execution>
								<goals>
									<goal>integration-test</goal>
									<goal>verify</goal>
								</goals>
							</execution>
						</executions>
					</plugin>
					<plugin>
						<groupId>com.lazerycode.jmeter</groupId>
						<artifactId>jmeter-maven-plugin</artifactId>
						<version>1.10.1</version>
						<configuration>
							<testResultsTimestamp>false</testResultsTimestamp>
							<suppressJMeterOutput>false</suppressJMeterOutput>
							<ignoreResultFailures>true</ignoreResultFailures>
							<propertiesJMeter>
								<jmeter.save.saveservice.thread_counts>true</jmeter.save.saveservice.thread_counts>
								<sampleresult.useNanoTime>true</sampleresult.useNanoTime>
							</propertiesJMeter>
							<jmeterPlugins>
								<plugin>
									<groupId>kg.apc</groupId>
									<artifactId>jmeter-plugins</artifactId>
								</plugin>
							</jmeterPlugins>
						</configuration>
						<executions>
							<execution>
								<id>execute-jmeter-tests</id>
								<goals>
									<goal>jmeter</goal>
								</goals>
								<phase>integration-test</phase>
							</execution>
						</executions>
						<dependencies>
							<dependency>
								<groupId>kg.apc</groupId>
								<artifactId>jmeter-plugins</artifactId>
								<version>1.0.0</version>
								<exclusions>
									<!--
										Unfortunately some transitive dependencies cannot be found on mvncentral
										and we have to explicitly exclude them.
										For a complete list, see https://github.com/mlex/jmeter-maven-example/
									-->
									<exclusion>
										<groupId>kg.apc</groupId>
										<artifactId>perfmon</artifactId>
									</exclusion>
									<exclusion>
										<groupId>org.apache.hadoop</groupId>
										<artifactId>hadoop-core</artifactId>
									</exclusion>
									<exclusion>
										<groupId>org.apache.hbase</groupId>
										<artifactId>hbase</artifactId>
									</exclusion>

									<!--
										These dependencies would override direct JMeter dependencies,
										which results in version conflicts (e.g. NoSuchMethodError on jmeter startup
									-->
									<exclusion>
										<groupId>org.apache.jmeter</groupId>
										<artifactId>jorphan</artifactId>
									</exclusion>
									<exclusion>
										<groupId>org.apache.bsf</groupId>
										<artifactId>bsf-api</artifactId>
									</exclusion>
									<exclusion>
										<groupId>org.bouncycastle</groupId>
										<artifactId>bcmail-jdk15</artifactId>
									</exclusion>
									<exclusion>
										<groupId>org.bouncycastle</groupId>
										<artifactId>bcprov-jdk15</artifactId>
									</exclusion>
									<exclusion>
										<groupId>javax.activation</groupId>
										<artifactId>activation</artifactId>
									</exclusion>
									<exclusion>
										<groupId>commons-logging</groupId>
										<artifactId>commons-logging</artifactId>
									</exclusion>
								</exclusions>
							</dependency>
						</dependencies>
					</plugin>
					<plugin>
						<groupId>com.lazerycode.jmeter</groupId>
						<artifactId>jmeter-analysis-maven-plugin</artifactId>
						<version>1.0.6</version>
						<configuration>
							<targetDirectory>${project.build.directory}/jmeter/results/analysis/</targetDirectory>
						</configuration>
						<executions>
							<execution>
								<id>create-html-report-for-asynchttp</id>
								<phase>verify</phase>
								<goals>
									<goal>analyze</goal>
								</goals>
								<configuration>
									<source>${project.build.directory}/jmeter/results/AsyncHttpBenchmarks.jtl</source>
								</configuration>
							</execution>
							<execution>
								<id>create-html-report-for-async-method</id>
								<phase>verify</phase>
								<goals>
									<goal>analyze</goal>
								</goals>
								<configuration>
									<source>${project.build.directory}/jmeter/results/AsyncMethodBenchmarks.jtl</source>
								</configuration>
							</execution>
							<execution>
								<id>create-html-report-for-sync-http</id>
								<phase>verify</phase>
								<goals>
									<goal>analyze</goal>
								</goals>
								<configuration>
									<source>${project.build.directory}/jmeter/results/SyncHttpBenchmarks.jtl</source>
								</configuration>
							</execution>
							<execution>
								<id>create-html-report-for-nice-index-html</id>
								<phase>verify</phase>
								<goals>
									<goal>analyze</goal>
								</goals>
								<configuration>
									<source>${project.build.directory}/jmeter/results/*.jtl</source>
								</configuration>
							</execution>
						</executions>
					</plugin>
					<plugin>
						<groupId>de.codecentric</groupId>
						<artifactId>jmeter-graph-maven-plugin</artifactId>
						<version>0.1.0</version>
						<executions>
							<execution>
								<id>create-graph-threads-for-asynchttp</id>
								<goals>
									<goal>create-graph</goal>
								</goals>
								<phase>verify</phase>
								<configuration>
									<inputFile>${project.build.directory}/jmeter/results/AsyncHttpBenchmarks.jtl</inputFile>
									<graphs>
										<graph>
											<pluginType>ResponseTimesOverTime</pluginType>
											<width>800</width>
											<height>600</height>
											<outputFile>${project.build.directory}/jmeter/results/AsyncHttpBenchmarks-ResponseTimesOverTime.png</outputFile>
										</graph>
										<graph>
											<pluginType>ResponseTimesPercentiles</pluginType>
											<width>800</width>
											<height>600</height>
											<outputFile>${project.build.directory}/jmeter/results/AsyncHttpBenchmarks-ResponseTimesPercentiles.png</outputFile>
										</graph>
										<graph>
											<pluginType>LatenciesOverTime</pluginType>
											<width>800</width>
											<height>600</height>
											<outputFile>${project.build.directory}/jmeter/results/AsyncHttpBenchmarks-LatenciesOverTime.png</outputFile>
										</graph>
									</graphs>
								</configuration>
							</execution>
							<execution>
								<id>create-graph-threads-for-async-method</id>
								<goals>
									<goal>create-graph</goal>
								</goals>
								<phase>verify</phase>
								<configuration>
									<inputFile>${project.build.directory}/jmeter/results/AsyncMethodBenchmarks.jtl</inputFile>
									<graphs>
										<graph>
											<pluginType>ResponseTimesOverTime</pluginType>
											<width>800</width>
											<height>600</height>
											<outputFile>${project.build.directory}/jmeter/results/AsyncMethodBenchmarks-ResponseTimesOverTime.png</outputFile>
										</graph>
										<graph>
											<pluginType>ResponseTimesPercentiles</pluginType>
											<width>800</width>
											<height>600</height>
											<outputFile>${project.build.directory}/jmeter/results/AsyncMethodBenchmarks-ResponseTimesPercentiles.png</outputFile>
										</graph>
										<graph>
											<pluginType>LatenciesOverTime</pluginType>
											<width>800</width>
											<height>600</height>
											<outputFile>${project.build.directory}/jmeter/results/AsyncMethodBenchmarks-LatenciesOverTime.png</outputFile>
										</graph>
									</graphs>
								</configuration>
							</execution>
							<execution>
								<id>create-graph-threads-for-sync-http</id>
								<goals>
									<goal>create-graph</goal>
								</goals>
								<phase>verify</phase>
								<configuration>
									<inputFile>${project.build.directory}/jmeter/results/SyncHttpBenchmarks.jtl</inputFile>
									<graphs>
										<graph>
											<pluginType>ResponseTimesOverTime</pluginType>
											<width>800</width>
											<height>600</height>
											<outputFile>${project.build.directory}/jmeter/results/SyncHttpBenchmarks-ResponseTimesOverTime.png</outputFile>
										</graph>
										<graph>
											<pluginType>ResponseTimesPercentiles</pluginType>
											<width>800</width>
											<height>600</height>
											<outputFile>${project.build.directory}/jmeter/results/SyncHttpBenchmarks-ResponseTimesPercentiles.png</outputFile>
										</graph>
										<graph>
											<pluginType>LatenciesOverTime</pluginType>
											<width>800</width>
											<height>600</height>
											<outputFile>${project.build.directory}/jmeter/results/SyncHttpBenchmarks-LatenciesOverTime.png</outputFile>
										</graph>
									</graphs>
								</configuration>
							</execution>
						</executions>
					</plugin>
				</plugins>
			</build>
		</profile>
	</profiles>
</project>
