<?xml version="1.0" encoding="UTF-8"?>
<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>

	<groupId>com.baeldung</groupId>
	<artifactId>resteasy-tutorial</artifactId>
	<version>1.0</version>
	<packaging>war</packaging>

	<properties>
		<resteasy.version>3.0.19.Final</resteasy.version>
		<junit.version>4.12</junit.version>
		<commons-io.version>2.5</commons-io.version>
        <maven-surefire-plugin.version>2.19.1</maven-surefire-plugin.version>
        <cargo-maven2-plugin.version>1.6.1</cargo-maven2-plugin.version>        		
	</properties>

	<build>
		<finalName>RestEasyTutorial</finalName>
		<plugins>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-compiler-plugin</artifactId>
				<configuration>
					<source>1.8</source>
					<target>1.8</target>
				</configuration>
			</plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>${maven-surefire-plugin.version}</version>                
                <configuration>
                    <excludes>
                        <exclude>**/*IntegrationTest.java</exclude>
                        <exclude>**/*LiveTest.java</exclude>
                    </excludes>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.codehaus.cargo</groupId>
                <artifactId>cargo-maven2-plugin</artifactId>
                <version>${cargo-maven2-plugin.version}</version>
                <configuration>
                    <wait>true</wait>
                    <container>
                        <containerId>jetty8x</containerId>
                        <type>embedded</type>
                    </container>
                    <configuration>
                        <properties>
                            <cargo.servlet.port>8082</cargo.servlet.port>
                        </properties>
                    </configuration>
                </configuration>
            </plugin>			
		</plugins>
	</build>

	<dependencies>

		<!-- core library -->

		<dependency>
			<groupId>org.jboss.resteasy</groupId>
			<artifactId>resteasy-servlet-initializer</artifactId>
			<version>${resteasy.version}</version>
		</dependency>


		<dependency>
			<groupId>org.jboss.resteasy</groupId>
			<artifactId>resteasy-client</artifactId>
			<version>${resteasy.version}</version>
		</dependency>

		<!-- Optional library -->

		<dependency>
			<groupId>org.jboss.resteasy</groupId>
			<artifactId>resteasy-jaxb-provider</artifactId>
			<version>${resteasy.version}</version>
		</dependency>

		<dependency>
			<groupId>org.jboss.resteasy</groupId>
			<artifactId>resteasy-jackson-provider</artifactId>
			<version>${resteasy.version}</version>
		</dependency>

		<!-- Junit Library -->

		<dependency>
			<groupId>junit</groupId>
			<artifactId>junit</artifactId>
			<version>${junit.version}</version>
		</dependency>

		<dependency>
			<groupId>commons-io</groupId>
			<artifactId>commons-io</artifactId>
			<version>${commons-io.version}</version>
		</dependency>

	</dependencies>

    <profiles>
        <profile>
            <id>live</id>
            <build>

                <plugins>

                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <executions>
                            <execution>
                                <phase>integration-test</phase>
                                <goals>
                                    <goal>test</goal>
                                </goals>
                                <configuration>
                                    <excludes>
                                        <exclude>**/*IntegrationTest.java</exclude>
                                    </excludes>
                                    <includes>
                                        <include>**/*LiveTest.java</include>
                                    </includes>
                                </configuration>
                            </execution>
                        </executions>
                        <configuration>
                            <systemPropertyVariables>
                                <test.mime>json</test.mime>
                            </systemPropertyVariables>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>org.codehaus.cargo</groupId>
                        <artifactId>cargo-maven2-plugin</artifactId>
                        <version>${cargo-maven2-plugin.version}</version>                        
                        <configuration>
                            <wait>false</wait>
                        </configuration>
                        <executions>
                            <execution>
                                <id>start-server</id>
                                <phase>pre-integration-test</phase>
                                <goals>
                                    <goal>start</goal>
                                </goals>
                            </execution>
                            <execution>
                                <id>stop-server</id>
                                <phase>post-integration-test</phase>
                                <goals>
                                    <goal>stop</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>

            </build>
        </profile>
    </profiles>
    
</project>