<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>
  <parent>
    <groupId>io.apiman</groupId>
    <artifactId>apiman-manager-api</artifactId>
    <version>1.1.2.Preview2</version>
    <relativePath>../../pom.xml</relativePath>
  </parent>
  <artifactId>apiman-manager-api-war-micro</artifactId>
  <name>apiman-manager-api-war-micro</name>

  <properties>
    <fabric8.version>2.0.30</fabric8.version>
    <fabric8.label.container>java</fabric8.label.container>
    <fabric8.label.component>apimanManagerApi</fabric8.label.component>
    <fabric8.label.group>apiman</fabric8.label.group>
    <jube.version>2.0.30</jube.version>

    <http.port>7070</http.port>

    <docker.from>fabric8/java</docker.from>
    <docker.registryPrefix>${env.DOCKER_REGISTRY}/</docker.registryPrefix>
    <docker.image>${docker.registryPrefix}fabric8/${project.artifactId}:${project.version}</docker.image>
    <docker.assemblyDescriptorRef>artifact-with-dependencies</docker.assemblyDescriptorRef>
    <docker.env.MAIN>io.apiman.manager.api.war.micro.Starter</docker.env.MAIN>
    <docker.port.container.http>${http.port}</docker.port.container.http>
    <docker.port.container.jolokia>8778</docker.port.container.jolokia>

    <fabric8.replicationController.name>apiman-manager-api</fabric8.replicationController.name>
    <fabric8.service.name>apiman-manager-api</fabric8.service.name>
    <fabric8.service.port>7072</fabric8.service.port>
    <fabric8.service.containerPort>${http.port}</fabric8.service.containerPort>
  </properties>

  <dependencies>
    <dependency>
      <groupId>${project.groupId}</groupId>
      <artifactId>apiman-manager-api-war</artifactId>
      <type>jar</type>
      <classifier>classes</classifier>
    </dependency>

    <!-- Jetty -->
    <dependency>
      <groupId>org.eclipse.jetty</groupId>
      <artifactId>jetty-server</artifactId>
    </dependency>
    <dependency>
      <groupId>org.eclipse.jetty</groupId>
      <artifactId>jetty-servlet</artifactId>
    </dependency>
    <dependency>
      <groupId>org.eclipse.jetty</groupId>
      <artifactId>jetty-servlets</artifactId>
    </dependency>
    <dependency>
      <groupId>org.eclipse.jetty</groupId>
      <artifactId>jetty-security</artifactId>
    </dependency>
    <dependency>
      <groupId>org.eclipse.jetty</groupId>
      <artifactId>jetty-jsp</artifactId>
    </dependency>
    <dependency>
      <groupId>org.eclipse.jetty</groupId>
      <artifactId>jetty-jndi</artifactId>
    </dependency>
    <dependency>
      <groupId>org.eclipse.jetty</groupId>
      <artifactId>jetty-util</artifactId>
    </dependency>

    <!-- Weld -->
    <dependency>
      <groupId>org.jboss.weld.se</groupId>
      <artifactId>weld-se-core</artifactId>
      <exclusions>
        <exclusion>
          <artifactId>el-api</artifactId>
          <groupId>javax.el</groupId>
        </exclusion>
      </exclusions>
    </dependency>
    <dependency>
      <groupId>org.jboss.weld.servlet</groupId>
      <artifactId>weld-servlet-core</artifactId>
    </dependency>

    <!-- REST Easy -->
    <dependency>
      <groupId>org.jboss.resteasy</groupId>
      <artifactId>resteasy-jaxrs</artifactId>
    </dependency>
    <dependency>
      <groupId>org.jboss.resteasy</groupId>
      <artifactId>resteasy-cdi</artifactId>
      <exclusions>
        <exclusion>
          <groupId>org.jboss.resteasy</groupId>
          <artifactId>resteasy-jaxrs</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
    <dependency>
      <groupId>org.jboss.resteasy</groupId>
      <artifactId>resteasy-jackson-provider</artifactId>
    </dependency>
    <dependency>
      <groupId>org.jboss.resteasy</groupId>
      <artifactId>resteasy-jaxb-provider</artifactId>
    </dependency>

    <!-- Database/JPA Dependencies -->
    <dependency>
      <groupId>commons-dbcp</groupId>
      <artifactId>commons-dbcp</artifactId>
    </dependency>
    <dependency>
      <groupId>commons-io</groupId>
      <artifactId>commons-io</artifactId>
    </dependency>
    <dependency>
      <groupId>commons-pool</groupId>
      <artifactId>commons-pool</artifactId>
    </dependency>
    <dependency>
      <groupId>com.h2database</groupId>
      <artifactId>h2</artifactId>
    </dependency>
    <dependency>
      <groupId>org.hibernate</groupId>
      <artifactId>hibernate-core</artifactId>
    </dependency>
    <dependency>
      <groupId>org.hibernate</groupId>
      <artifactId>hibernate-entitymanager</artifactId>
    </dependency>
    <dependency>
      <groupId>org.hibernate.javax.persistence</groupId>
      <artifactId>hibernate-jpa-2.1-api</artifactId>
    </dependency>

    <!-- Elastic Search -->
    <dependency>
      <groupId>org.elasticsearch</groupId>
      <artifactId>elasticsearch</artifactId>
    </dependency>

    <!-- Logging -->
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-api</artifactId>
    </dependency>
    <dependency>
      <artifactId>slf4j-log4j12</artifactId>
      <groupId>org.slf4j</groupId>
    </dependency>

    <!-- Spec Libs -->
    <dependency>
      <groupId>javax.enterprise</groupId>
      <artifactId>cdi-api</artifactId>
    </dependency>
    <dependency>
      <groupId>org.jboss.spec.javax.servlet</groupId>
      <artifactId>jboss-servlet-api_3.0_spec</artifactId>
      <scope>provided</scope>
    </dependency>
  </dependencies>

  <build>
    <finalName>${project.artifactId}</finalName>

    <plugins>
      <plugin>
        <groupId>org.jolokia</groupId>
        <artifactId>docker-maven-plugin</artifactId>
        <configuration>
          <images>
            <image>
              <name>${docker.image}</name>
              <build>
                <from>${docker.from}</from>
                <assembly>
                  <descriptorRef>${docker.assemblyDescriptorRef}</descriptorRef>
                </assembly>
                <env>
                  <MAIN>${docker.env.MAIN}</MAIN>
                  <HTTP_PORT>${http.port}</HTTP_PORT>
                </env>
                <ports>
                  <port>8778</port>
                  <port>${http.port}</port>
                </ports>
              </build>
            </image>
          </images>
        </configuration>
      </plugin>

      <plugin>
        <groupId>io.fabric8.jube</groupId>
        <artifactId>jube-maven-plugin</artifactId>
        <version>${jube.version}</version>
      </plugin>

      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>exec-maven-plugin</artifactId>
        <configuration>
          <mainClass>${docker.env.MAIN}</mainClass>
          <includePluginDependencies>false</includePluginDependencies>
        </configuration>
      </plugin>
    </plugins>
  </build>

  <profiles>
    <profile>
      <id>docker-build</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.jolokia</groupId>
            <artifactId>docker-maven-plugin</artifactId>
            <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>
            <executions>
              <execution>
                <goals>
                  <goal>build</goal>
                  <goal>push</goal>
                </goals>
                <phase>package</phase>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
    
    <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>
            <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-public</id>
      <properties>
        <docker.registryPrefix />
      </properties>
    </profile>
  </profiles>

</project>
