<?xml version="1.0" encoding="UTF-8"?>
<!--
  #%L
  Wildfly Camel :: Example :: Camel REST
  %%
  Copyright (C) 2013 - 2014 RedHat
  %%
  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/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>org.wildfly.camel</groupId>
        <artifactId>wildfly-camel-example</artifactId>
        <version>2.3.0</version>
    </parent>

    <name>Wildfly Camel :: Example :: Camel REST</name>

    <artifactId>example-camel-rest</artifactId>
	<packaging>war</packaging>
	
    <!-- Properties -->
    <properties>
        <docker.image.name>wildflyext/${project.artifactId}</docker.image.name>
    </properties>

    <!-- Dependencies -->    
	<dependencies>
	
		<!-- Provided -->
        <dependency>
            <groupId>javax.enterprise</groupId>
            <artifactId>cdi-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-cdi</artifactId>
	        <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.hibernate.javax.persistence</groupId>
            <artifactId>hibernate-jpa-2.1-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.jboss.spec.javax.ejb</groupId>
            <artifactId>jboss-ejb-api_3.2_spec</artifactId>
		  <scope>provided</scope>
        </dependency>
	    <dependency>
	        <groupId>org.jboss.spec.javax.servlet</groupId>
	        <artifactId>jboss-servlet-api_3.1_spec</artifactId>
	        <scope>provided</scope>
	    </dependency>
        <dependency>
            <groupId>org.jboss.spec.javax.ws.rs</groupId>
            <artifactId>jboss-jaxrs-api_1.1_spec</artifactId>
            <scope>provided</scope>
        </dependency>
	    
        <!-- Test -->
        <dependency>
            <groupId>org.jboss.arquillian.junit</groupId>
            <artifactId>arquillian-junit-container</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.wildfly</groupId>
            <artifactId>wildfly-arquillian-container-remote</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <scope>test</scope>
        </dependency>
	</dependencies>

	<!-- Build -->
    <build>
        <plugins>
            <plugin>
                <groupId>org.wildfly.plugins</groupId>
                <artifactId>wildfly-maven-plugin</artifactId>
                <configuration>
                    <jbossHome>${jboss.home}</jbossHome>
                    <serverConfig>${server.config}</serverConfig>
                </configuration>
                <executions>
                    <execution>
                        <id>wildfly-deploy</id>
                        <phase>integration-test</phase>
                        <goals>
                            <goal>deploy</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>wildfly-undeploy</id>
                        <phase>post-integration-test</phase>
                        <goals>
                            <goal>undeploy</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

	<!-- Profiles -->
	<profiles>
		<profile>
			<id>docker</id>
            <activation>
                <property>
                    <name>env.DOCKER_HOST</name>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-antrun-plugin</artifactId>
                        <executions>
                            <execution>
                                <phase>install</phase>
                                <goals>
                                    <goal>run</goal>
                                </goals>
                                <configuration>
                                    <target>
                                        <exec executable="docker" failonerror="false">
                                            <arg value="rmi" />
                                            <arg value="--force=true" />
                                            <arg value="${docker.image.name}" />
                                        </exec>
                                    </target>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.jolokia</groupId>
                        <artifactId>docker-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>build-docker-image</id>
                                <phase>install</phase>
                                <goals>
                                    <goal>build</goal>
                                </goals>
                                <configuration>
                                    <images>
                                        <image>
                                            <name>${docker.image.name}</name>
                                            <build>
                                                <from>wildflyext/wildfly-camel</from>
                                                <assembly>
                                                    <basedir>/opt/jboss/wildfly/standalone/deployments</basedir>
                                                    <descriptorRef>artifact</descriptorRef>
                                                </assembly>
                                            </build>
                                        </image>
                                    </images>
                                </configuration>
                            </execution>
                        </executions>
                     </plugin>
                </plugins>
            </build>
		</profile>
        <profile>
            <id>ts.all</id>
            <activation>
                <property>
                    <name>ts.all</name>
                </property>
            </activation>
            <properties>
                <jboss.home>${basedir}/../target/wildfly-${version.wildfly}</jboss.home>
            </properties>
        </profile>
	</profiles>
</project>
