<!--

     Copyright 2005-2014 Red Hat, Inc.

     Red Hat licenses this file to you 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/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <parent>
    <groupId>io.fabric8.jube.images.fabric8</groupId>
    <artifactId>apps</artifactId>
    <version>2.0.19</version>
  </parent>

  <artifactId>fabric8-mq-consumer</artifactId>
  <packaging>jar</packaging>

  <name>Fabric8 MQ : Consumer</name>
  <description>Fabric8 MQ Example Consumer</description>

    <properties>
        <version.maven-surefire-plugin>2.15</version.maven-surefire-plugin>
        <destinationName>TEST.FOO</destinationName>
        <docker.env.MAIN>io.fabric8.mq.consumer.ConsumerMain</docker.env.MAIN>

        <fabric8.kubernetes.name>fabric8MQConsumer</fabric8.kubernetes.name>
        <fabric8.env.AMQ_SERVICE_ID>FABRIC8MQ</fabric8.env.AMQ_SERVICE_ID>
        <fabric8.env.AMQ_QUEUENAME>${destinationName}</fabric8.env.AMQ_QUEUENAME>
        <fabric8.label.container>java</fabric8.label.container>
        <fabric8.label.group>fabric8MQConsumer</fabric8.label.group>
        <fabric8.label.queueName>${destinationName}</fabric8.label.queueName>
        <fabric8.iconRef>icons/activemq.svg</fabric8.iconRef>
    </properties>

  <dependencies>
    <dependency>
        <groupId>io.fabric8.mq</groupId>
        <artifactId>camel-amq</artifactId>
    </dependency>

    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-log4j12</artifactId>
    </dependency>

    <dependency>
      <groupId>org.jboss.arquillian.junit</groupId>
      <artifactId>arquillian-junit-container</artifactId>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>io.fabric8</groupId>
      <artifactId>arquillian-fabric8</artifactId>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>io.fabric8</groupId>
      <artifactId>kubernetes-assertions</artifactId>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <plugin>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>${version.maven-surefire-plugin}</version>
        <configuration>
          <forkMode>perTest</forkMode>
        </configuration>
      </plugin>

      <plugin>
        <groupId>io.fabric8</groupId>
        <artifactId>fabric8-maven-plugin</artifactId>
        <version>${fabric8.version}</version>
        <executions>
          <execution>
            <id>json</id>
            <goals>
              <goal>json</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <groupId>org.jolokia</groupId>
        <artifactId>docker-maven-plugin</artifactId>
        <version>${docker.maven.plugin.version}</version>
        <configuration>
          <images>
            <image>
              <name>${docker.image}</name>
              <build>
                <from>${docker.from}</from>
                <assemblyDescriptorRef>${docker.assemblyDescriptorRef}</assemblyDescriptorRef>
                <env>
                  <MAIN>${docker.env.MAIN}</MAIN>
                  <AMQ_SERVICE_ID>FABRIC8MQ</AMQ_SERVICE_ID>
                  <AMQ_QUEUENAME>TEST.FOO</AMQ_QUEUENAME>
                  <AMQ_PREFETCH>1000</AMQ_PREFETCH>
                </env>
                <ports>
                  <port>8778</port>
                </ports>
              </build>
            </image>
          </images>
        </configuration>
      </plugin>

      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>exec-maven-plugin</artifactId>
        <version>1.2.1</version>
        <configuration>
          <mainClass>io.fabric8.mq.consumer.ConsumerMain</mainClass>
          <includePluginDependencies>false</includePluginDependencies>
        </configuration>
      </plugin>
    </plugins>
  </build>

  <profiles>
    <profile>
      <id>jube</id>
      <activation>
        <activeByDefault>true</activeByDefault>
      </activation>
      <build>
        <plugins>
          <plugin>
            <groupId>io.fabric8.jube</groupId>
            <artifactId>jube-maven-plugin</artifactId>
            <version>${jube.version}</version>
            <executions>
              <execution>
                <goals>
                  <goal>build</goal>
                </goals>
                <phase>package</phase>
              </execution>
            </executions>

            <!-- TODO it'd be nice for the jube plugin to automatically download this dependency -->
            <dependencies>
              <dependency>
                <groupId>io.fabric8.jube.images.fabric8</groupId>
                <artifactId>java</artifactId>
                <version>${jube.version}</version>
                <classifier>image</classifier>
                <type>zip</type>
              </dependency>
            </dependencies>
          </plugin>
        </plugins>
      </build>
    </profile>

    <profile>
      <id>docker-build</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.jolokia</groupId>
            <artifactId>docker-maven-plugin</artifactId>
            <version>${docker.maven.plugin.version}</version>
            <executions>
              <execution>
                <goals>
                  <goal>build</goal>
                </goals>
                <phase>package</phase>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>

    <profile>
      <id>docker-push</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.jolokia</groupId>
            <artifactId>docker-maven-plugin</artifactId>
            <version>${docker.maven.plugin.version}</version>
            <executions>
              <execution>
                <goals>
                  <goal>build</goal>
                  <goal>push</goal>
                </goals>
                <phase>package</phase>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>

</project>
