<!--
  #%L
  %%
  Copyright (C) 2011 - 2016 BMW Car IT GmbH
  %%
  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.
  #L%
  -->
<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>
	<artifactId>performance</artifactId>
	<name>${project.groupId}:${project.artifactId}</name>

	<parent>
		<groupId>io.joynr</groupId>
		<artifactId>tests</artifactId>
		<version>0.16.0</version>
	</parent>

	<dependencies>
		<dependency>
			<groupId>io.joynr.java.core</groupId>
			<artifactId>clustercontroller-websocket-runtime</artifactId>
			<version>${project.version}</version>
		</dependency>
		<dependency>
			<groupId>io.joynr.java.core</groupId>
			<artifactId>clustercontroller-inprocess-runtime</artifactId>
			<version>${project.version}</version>
		</dependency>
		<dependency>
			<groupId>io.joynr.java.core</groupId>
			<artifactId>libjoynr-websocket-runtime</artifactId>
			<version>${project.version}</version>
		</dependency>
		<dependency>
			<groupId>io.joynr.java.messaging.mqtt</groupId>
			<artifactId>joynr-mqtt-client</artifactId>
			<version>${project.version}</version>
		</dependency>
		<dependency>
			<groupId>io.joynr.java.core</groupId>
			<artifactId>libjoynr</artifactId>
			<version>${project.version}</version>
			<classifier>tests</classifier>
		</dependency>
		<!-- Logging used in the performance Java code -->
		<dependency>
			<groupId>org.slf4j</groupId>
			<artifactId>slf4j-log4j12</artifactId>
		</dependency>

		<!-- Console I/O framework used in the performance Java code -->
		<dependency>
			<groupId>jline</groupId>
			<artifactId>jline</artifactId>
			<version>2.12</version>
		</dependency>

		<!--
			The following dependencies allow to run a jetty server that
			contains the minimum backend
		-->
		<dependency>
			<groupId>io.joynr.java.messaging.bounceproxy</groupId>
			<artifactId>single-bounceproxy</artifactId>
			<version>${project.version}</version>
			<type>war</type>
		</dependency>

		<dependency>
			<groupId>io.joynr.java.backend-services</groupId>
			<artifactId>discovery-directory-servlet</artifactId>
			<version>${project.version}</version>
			<type>war</type>
		</dependency>

		<dependency>
			<groupId>io.joynr.java.backend-services</groupId>
			<artifactId>domain-access-controller-servlet</artifactId>
			<version>${project.version}</version>
			<type>war</type>
		</dependency>
		<dependency>
			<groupId>commons-cli</groupId>
			<artifactId>commons-cli</artifactId>
			<version>1.3</version>
		</dependency>
	</dependencies>

	<build>
		<!--
			If a local subdirectory is used to store Franca files,
			it should be specified here as a resource
		-->
		<resources>
			<resource>
				<directory>src/main/resources</directory>
				<filtering>true</filtering>
			</resource>
			<resource>
				<directory>src/main/model</directory>
			</resource>
		</resources>

		<plugins>
			<plugin>
				<groupId>com.googlecode.maven-java-formatter-plugin</groupId>
				<artifactId>maven-java-formatter-plugin</artifactId>
			</plugin>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-jar-plugin</artifactId>
				<configuration>
					<excludes>
						<exclude>**/package-info*</exclude> <!-- to prevent package-info files from different projects to collide -->
						<exclude>**/CheckForNull*</exclude> <!-- to prevent check-for-null annotations from package-info to be pulled
							into jar-files -->
					</excludes>
				</configuration>
			</plugin>

			<!-- Add the generated Java and Franca files to the processing of sources -->
			<plugin>
				<groupId>org.codehaus.mojo</groupId>
				<artifactId>build-helper-maven-plugin</artifactId>
				<executions>
					<execution>
						<id>add-source</id>
						<phase>process-sources</phase>
						<goals>
							<goal>add-source</goal>
						</goals>
						<configuration>
							<sources>
								<source>src/main/generated-java</source>
								<source>src/main/model</source>
							</sources>
						</configuration>
					</execution>
				</executions>
			</plugin>

			<plugin>
				<groupId>io.joynr.tools.generator</groupId>
				<artifactId>joynr-generator-maven-plugin</artifactId>
				<executions>
					<execution>
						<id>generate-java</id>
						<phase>generate-sources</phase>
						<goals>
							<goal>generate</goal>
						</goals>
						<configuration>
							<model>${basedir}/src/main/model</model>
							<generationLanguage>java</generationLanguage>
							<outputPath>${basedir}/src/main/generated-java</outputPath>
						</configuration>
					</execution>
					<execution>
						<id>generate-cpp</id>
						<phase>generate-sources</phase>
						<goals>
							<goal>generate</goal>
						</goals>
						<configuration>
							<model>${basedir}/src/main/model</model>
							<generationLanguage>cpp</generationLanguage>
							<outputPath>${basedir}/src/main/generated-cpp</outputPath>
						</configuration>
					</execution>
					<execution>
						<id>generate-javascript</id>
						<phase>generate-sources</phase>
						<goals>
							<goal>generate</goal>
						</goals>
						<configuration>
							<model>${basedir}/src/main/model</model>
							<generationLanguage>javascript</generationLanguage>
							<outputPath>${basedir}/src/main/generated-javascript</outputPath>
						</configuration>
					</execution>
				</executions>
				<dependencies>
					<dependency>
						<groupId>io.joynr.tools.generator</groupId>
						<artifactId>java-generator</artifactId>
						<version>${project.version}</version>
					</dependency>
					<dependency>
						<groupId>io.joynr.tools.generator</groupId>
						<artifactId>cpp-generator</artifactId>
						<version>${project.version}</version>
					</dependency>
					<dependency>
						<groupId>io.joynr.tools.generator</groupId>
						<artifactId>js-generator</artifactId>
						<version>${project.version}</version>
					</dependency>
				</dependencies>
			</plugin>

			<plugin>
				<artifactId>maven-clean-plugin</artifactId>
				<configuration>
					<filesets>
						<fileset>
							<directory>src/main/generated-java</directory>
							<includes>
								<include>**</include>
							</includes>
						</fileset>
						<fileset>
							<directory>src/main/generated-cpp</directory>
							<includes>
								<include>**</include>
							</includes>
						</fileset>
						<fileset>
							<directory>src/main/generated-javascript</directory>
							<includes>
								<include>**</include>
							</includes>
						</fileset>
					</filesets>
				</configuration>
			</plugin>

			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-dependency-plugin</artifactId>
				<executions>
					<execution>
						<id>copy-backend-services</id>
						<!--
							NOTE: jetty:run runs in phase test-compile. Hence, backend services
							must be copied at latest in the process-test-resources phase.
						-->
						<phase>process-test-resources</phase>
						<goals>
							<goal>copy</goal>
						</goals>
						<configuration>
							<artifactItems>
								<artifactItem>
									<groupId>io.joynr.java.messaging.bounceproxy</groupId>
									<artifactId>single-bounceproxy</artifactId>
									<version>${project.version}</version>
									<type>war</type>
									<outputDirectory>${project.build.directory}</outputDirectory>
									<destFileName>bounceproxy.war</destFileName>
								</artifactItem>
								<artifactItem>
									<groupId>io.joynr.java.backend-services</groupId>
									<artifactId>domain-access-controller-servlet</artifactId>
									<version>${project.version}</version>
									<type>war</type>
									<outputDirectory>${project.build.directory}</outputDirectory>
									<destFileName>accesscontrol.war</destFileName>
								</artifactItem>
								<artifactItem>
									<groupId>io.joynr.java.backend-services</groupId>
									<artifactId>discovery-directory-servlet</artifactId>
									<version>${project.version}</version>
									<type>war</type>
									<outputDirectory>${project.build.directory}</outputDirectory>
									<destFileName>discovery.war</destFileName>
								</artifactItem>
							</artifactItems>
							<overWriteReleases>false</overWriteReleases>
							<overWriteSnapshots>true</overWriteSnapshots>
						</configuration>
					</execution>
				</executions>
			</plugin>
			<plugin>
				<groupId>org.eclipse.jetty</groupId>
				<artifactId>jetty-maven-plugin</artifactId>
				<dependencies>
					<dependency>
						<groupId>org.slf4j</groupId>
						<artifactId>slf4j-log4j12</artifactId>
						<version>1.6.6</version>
					</dependency>
				</dependencies>
				<configuration>
					<webApp>
						<contextPath>/</contextPath>
					</webApp>
					<stopPort>9966</stopPort>
					<stopKey>joynr</stopKey>
					<contextHandlers>
						<contextHandler implementation="org.eclipse.jetty.webapp.WebAppContext">
							<war>${project.build.directory}/bounceproxy.war</war>
							<contextPath>/bounceproxy</contextPath>
						</contextHandler>
						<contextHandler implementation="org.eclipse.jetty.webapp.WebAppContext">
							<war>${project.build.directory}/discovery.war</war>
							<contextPath>/discovery</contextPath>
						</contextHandler>
						<contextHandler implementation="org.eclipse.jetty.webapp.WebAppContext">
							<war>${project.build.directory}/accesscontrol.war</war>
							<contextPath>/accesscontrol</contextPath>
						</contextHandler>
					</contextHandlers>
					<systemProperties>
						<systemProperty>
							<name>log4j.configuration</name>
							<value>file:${basedir}/src/main/resources/log4j.properties</value>
						</systemProperty>
						<systemProperty>
							<name>joynr.servlet.hostPath</name>
							<value>http://localhost:8080</value>
						</systemProperty>
						<systemProperty>
							<name>org.atmosphere.useNative</name>
							<value>true</value>
						</systemProperty>
					</systemProperties>
				</configuration>
			</plugin>
		</plugins>
	</build>
</project>
