<?xml version="1.0" encoding="UTF-8"?>
<!--

     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</groupId>
    <artifactId>components</artifactId>
    <version>2.0.19</version>
  </parent>

  <groupId>io.fabric8</groupId>
  <artifactId>kubernetes-api</artifactId>
  <packaging>bundle</packaging>

  <name>Fabric8 :: Kubernetes Client API</name>

  <properties>
    <clone-kube>true</clone-kube>
    <kube.dir>${basedir}/src/main/kubernetes</kube.dir>
  </properties>

  <dependencies>
    <dependency>
      <groupId>com.fasterxml.jackson.module</groupId>
      <artifactId>jackson-module-jaxb-annotations</artifactId>
      <version>${jackson2.version}</version>
    </dependency>
    <dependency>
      <groupId>javax.validation</groupId>
      <artifactId>validation-api</artifactId>
      <version>${validation-api.version}</version>
<!--
      <optional>true</optional>
-->
    </dependency>
    <dependency>
      <groupId>com.fasterxml.jackson.core</groupId>
      <artifactId>jackson-databind</artifactId>
    </dependency>
    <dependency>
      <groupId>io.fabric8</groupId>
      <artifactId>fabric-utils</artifactId>
    </dependency>

    <dependency>
      <groupId>commons-lang</groupId>
      <artifactId>commons-lang</artifactId>
    </dependency>

    <dependency>
      <groupId>com.fasterxml.jackson.jaxrs</groupId>
      <artifactId>jackson-jaxrs-json-provider</artifactId>
    </dependency>
    <dependency>
      <groupId>org.apache.cxf</groupId>
      <artifactId>cxf-rt-rs-client</artifactId>
    </dependency>

    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-api</artifactId>
    </dependency>
    
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-simple</artifactId>
    </dependency>

    <dependency>
      <groupId>org.yaml</groupId>
      <artifactId>snakeyaml</artifactId>
    </dependency>
    
    <dependency>
      <groupId>org.json</groupId>
      <artifactId>json</artifactId>
    </dependency>
    
      <!-- testing -->
    <dependency>
      <groupId>org.assertj</groupId>
      <artifactId>assertj-core</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-log4j12</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>io.hawt</groupId>
      <artifactId>hawtio-kubernetes</artifactId>
      <version>${hawtio.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>io.hawt</groupId>
      <artifactId>hawtio-aether</artifactId>
      <version>${hawtio.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>io.hawt</groupId>
      <artifactId>hawtio-git</artifactId>
      <version>${hawtio.version}</version>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <plugin>
        <groupId>org.jsonschema2pojo</groupId>
        <artifactId>jsonschema2pojo-maven-plugin</artifactId>
        <version>0.4.5</version>
        <configuration>
          <sourceDirectory>${kube.dir}/api/doc</sourceDirectory>
          <targetPackage>io.fabric8.kubernetes.api.model</targetPackage>
          <includeJsr303Annotations>true</includeJsr303Annotations>
          <outputDirectory>${basedir}/target/generated-sources</outputDirectory>
        </configuration>
        <executions>
          <execution>
            <goals>
              <goal>generate</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <artifactId>maven-antrun-plugin</artifactId>
        <version>1.7</version>
        <executions>
          <execution>
            <phase>generate-sources</phase>
            <configuration>
              <target>
                <echo>removing the duplicate generated calss</echo>
                <delete file="${basedir}/target/generated-sources/io/fabric8/kubernetes/api/model/IntOrString.java" verbose="true" />
              </target>
            </configuration>
            <goals>
              <goal>run</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>exec-maven-plugin</artifactId>
        <version>${exec-maven-plugin.version}</version>
        <executions>
          <execution>
            <goals>
              <goal>java</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
<!--
          <mainClass>io.fabric8.kubernetes.api.ViewAppSummaries</mainClass>
-->
          <mainClass>io.fabric8.kubernetes.api.Example</mainClass>
          <classpathScope>test</classpathScope>
        </configuration>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <configuration>
          <systemPropertyVariables>
            <kube.dir>${kube.dir}</kube.dir>
          </systemPropertyVariables>
        </configuration>
      </plugin>
    </plugins>
  </build>

  <profiles>
    <profile>
      <id>update-kube</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-scm-plugin</artifactId>
            <version>1.9.1</version>
            <configuration>
              <checkoutDirectory>${basedir}/target/kubernetes-checkout</checkoutDirectory>
              <connectionUrl>scm:git:https://github.com/fabric8io/kubernetes.git</connectionUrl>
            </configuration>
            <executions>
              <execution>
                <phase>initialize</phase>
                <goals>
                  <goal>checkout</goal>
                </goals>
              </execution>
            </executions>
          </plugin>

          <plugin>
            <artifactId>maven-antrun-plugin</artifactId>
            <version>1.7</version>
            <executions>
              <execution>
                <phase>initialize</phase>
                <configuration>
                  <target>
                    <echo>copying kubernetes API code into project</echo>
                    <mkdir dir="${kube.dir}/api" />
                    <copy todir="${kube.dir}/api">
                      <fileset dir="target/kubernetes-checkout/api" />
                    </copy>
                    <exec executable="git" failonerror="true" dir="${basedir}">
                      <arg value="add" />
                      <arg value="${kube.dir}/api" />
                    </exec>
                    <echo>Updated the kubernetes API to ${kube.dir}/api</echo>
                  </target>
                </configuration>
                <goals>
                  <goal>run</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>

  </profiles>
</project>
