<?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>
  <parent>
    <groupId>ca.vanzyl.concord.ck8s</groupId>
    <artifactId>ck8s</artifactId>
    <version>3.0.0</version>
  </parent>

  <artifactId>ck8s-server</artifactId>
  <packaging>concord-plugin</packaging>
  <name>CK8s :: Server</name>

  <properties>
    <db.image>docker.io/library/postgres:10.4-alpine</db.image>
    <db.changeLogPath>ca/vanzyl/concord/k8s/db/liquibase.xml</db.changeLogPath>
    <db.host>localhost</db.host>
    <db.username>postgres</db.username>
    <db.password>q1</db.password>
    <takari.annotationProcessing>proc</takari.annotationProcessing>
  </properties>

  <dependencies>
    <dependency>
      <groupId>com.amazonaws</groupId>
      <artifactId>aws-java-sdk-core</artifactId>
    </dependency>
    <dependency>
      <groupId>com.amazonaws</groupId>
      <artifactId>aws-java-sdk-ec2</artifactId>
    </dependency>
    <dependency>
      <groupId>com.amazonaws</groupId>
      <artifactId>aws-java-sdk-sts</artifactId>
    </dependency>

    <dependency>
      <groupId>io.fabric8</groupId>
      <artifactId>kubernetes-client</artifactId>
    </dependency>
    <dependency>
      <groupId>io.fabric8</groupId>
      <artifactId>kubernetes-model</artifactId>
    </dependency>
    <dependency>
      <groupId>ca.vanzyl.concord.ck8s</groupId>
      <artifactId>ck8s-base-image</artifactId>
    </dependency>
    <dependency>
      <groupId>ca.vanzyl.concord.ck8s</groupId>
      <artifactId>ck8s-common</artifactId>
    </dependency>
    <dependency>
      <groupId>ca.vanzyl.concord.ck8s</groupId>
      <artifactId>ck8s-model</artifactId>
    </dependency>
    <dependency>
      <groupId>com.walmartlabs.concord.server</groupId>
      <artifactId>concord-server-sdk</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>com.walmartlabs.concord</groupId>
      <artifactId>concord-sdk</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>com.walmartlabs.concord</groupId>
      <artifactId>concord-common</artifactId>
      <scope>provided</scope>
    </dependency>
    <!--
        concord-server-impl gives us access to all Concord Server internals,
        but it's not considered a stable API.

        concord-server-sdk contains stable API classes/interfaces but exposes
        less features
    -->
    <dependency>
      <groupId>com.walmartlabs.concord.server</groupId>
      <artifactId>concord-server-impl</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>com.walmartlabs.concord.server</groupId>
      <artifactId>concord-server-db</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.apache.shiro</groupId>
      <artifactId>shiro-core</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.jboss.spec.javax.ws.rs</groupId>
      <artifactId>jboss-jaxrs-api_2.0_spec</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>javax.inject</groupId>
      <artifactId>javax.inject</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.eclipse.sisu</groupId>
      <artifactId>org.eclipse.sisu.inject</artifactId>
      <version>0.3.4</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.jboss.resteasy</groupId>
      <artifactId>resteasy-multipart-provider</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>io.takari.siesta</groupId>
      <artifactId>siesta-api</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-api</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.eclipse.jetty.websocket</groupId>
      <artifactId>websocket-api</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>javax.servlet</groupId>
      <artifactId>javax.servlet-api</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.eclipse.jetty.websocket</groupId>
      <artifactId>websocket-servlet</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.apache.commons</groupId>
      <artifactId>commons-compress</artifactId>
    </dependency>
    <dependency>
      <groupId>com.google.guava</groupId>
      <artifactId>guava</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>javax.validation</groupId>
      <artifactId>validation-api</artifactId>
      <scope>provided</scope>
    </dependency>

    <!-- Immutables -->
    <dependency>
      <groupId>org.immutables</groupId>
      <artifactId>value</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>com.google.errorprone</groupId>
      <artifactId>error_prone_annotations</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>com.google.code.findbugs</groupId>
      <artifactId>jsr305</artifactId>
      <scope>provided</scope>
    </dependency>

    <!-- db stuff -->
    <dependency>
      <groupId>org.jooq</groupId>
      <artifactId>jooq</artifactId>
    </dependency>
    <dependency>
      <groupId>org.postgresql</groupId>
      <artifactId>postgresql</artifactId>
    </dependency>

    <!-- testing -->
    <dependency>
      <groupId>ca.vanzyl.concord.ck8s</groupId>
      <artifactId>ck8s-client</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.assertj</groupId>
      <artifactId>assertj-core</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>ca.ibodrov.concord</groupId>
      <artifactId>testcontainers-concord-junit4</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>ca.ibodrov.concord</groupId>
      <artifactId>testcontainers-concord-core</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.testcontainers</groupId>
      <artifactId>testcontainers</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>com.github.spullara.mustache.java</groupId>
      <artifactId>compiler</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>com.walmartlabs.concord</groupId>
      <artifactId>concord-client</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>com.squareup.okhttp</groupId>
      <artifactId>okhttp</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.mockito</groupId>
      <artifactId>mockito-core</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.eclipse.jetty</groupId>
      <artifactId>jetty-util</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>com.google.inject</groupId>
      <artifactId>guice</artifactId>
      <scope>test</scope>
    </dependency>

    <!-- local mode support -->
    <dependency>
      <groupId>com.walmartlabs.concord.server</groupId>
      <artifactId>concord-server</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>com.walmartlabs.concord</groupId>
      <artifactId>concord-agent</artifactId>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <plugin>
        <groupId>ca.vanzyl.concord</groupId>
        <artifactId>concord-maven-plugin</artifactId>
        <extensions>true</extensions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
        <executions>
          <execution>
            <id>copy-runner-jar</id>
            <phase>process-test-resources</phase>
            <goals>
              <goal>copy</goal>
            </goals>
            <configuration>
              <overWriteIfNewer>true</overWriteIfNewer>
              <artifactItems>
                <artifactItem>
                  <groupId>com.walmartlabs.concord.runtime.v2</groupId>
                  <artifactId>concord-runner-v2</artifactId>
                  <version>${concord.version}</version>
                  <classifier>jar-with-dependencies</classifier>
                  <destFileName>runner-v2.jar</destFileName>
                </artifactItem>
              </artifactItems>
              <outputDirectory>${project.build.directory}</outputDirectory>
            </configuration>
          </execution>
          <execution>
            <id>copy-ui-files</id>
            <phase>process-test-resources</phase>
            <goals>
              <goal>unpack</goal>
            </goals>
            <configuration>
              <artifactItems>
                <artifactItem>
                  <groupId>com.walmartlabs.concord</groupId>
                  <artifactId>concord-console2</artifactId>
                  <version>${concord.version}</version>
                  <classifier>dist</classifier>
                  <type>tar.gz</type>
                  <outputDirectory>${project.build.directory}/console</outputDirectory>
                </artifactItem>
              </artifactItems>
            </configuration>
          </execution>
          <execution>
            <id>copy-docker-stuff</id>
            <phase>package</phase>
            <goals>
              <goal>copy</goal>
            </goals>
            <configuration>
              <overWriteIfNewer>true</overWriteIfNewer>
              <artifactItems>
                <artifactItem>
                  <groupId>com.walmartlabs.concord.server</groupId>
                  <artifactId>concord-server</artifactId>
                  <version>${concord.version}</version>
                  <classifier>dist</classifier>
                  <type>tar.gz</type>
                  <destFileName>server.tar.gz</destFileName>
                </artifactItem>
                <artifactItem>
                  <groupId>com.walmartlabs.concord</groupId>
                  <artifactId>concord-console2</artifactId>
                  <version>${concord.version}</version>
                  <classifier>dist</classifier>
                  <type>tar.gz</type>
                  <destFileName>console.tar.gz</destFileName>
                </artifactItem>
              </artifactItems>
              <outputDirectory>${project.build.directory}</outputDirectory>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>exec-maven-plugin</artifactId>
        <executions>
          <execution>
            <id>docker-context-create</id>
          </execution>
          <execution>
            <id>docker-build</id>
          </execution>
        </executions>
      </plugin>
      <!-- pg + liquibase + jooq -->
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>build-helper-maven-plugin</artifactId>
        <executions>
          <execution>
            <id>reserve-ports</id>
            <phase>generate-sources</phase>
            <goals>
              <goal>reserve-network-port</goal>
            </goals>
            <configuration>
              <portNames>
                <portName>db.port</portName>
              </portNames>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>io.fabric8</groupId>
        <artifactId>docker-maven-plugin</artifactId>
        <extensions>true</extensions>
        <executions>
          <execution>
            <id>start</id>
            <phase>generate-sources</phase>
            <goals>
              <goal>start</goal>
            </goals>
          </execution>
          <execution>
            <id>stop</id>
            <phase>prepare-package</phase>
            <goals>
              <goal>stop</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <images>
            <image>
              <name>${db.image}</name>
              <alias>db</alias>
              <run>
                <ports>
                  <port>${db.port}:5432</port>
                </ports>
                <env>
                  <POSTGRES_PASSWORD>${db.password}</POSTGRES_PASSWORD>
                </env>
                <wait>
                  <log>(?s).*ready for start up.*ready to accept connections.*</log>
                  <time>60000</time>
                </wait>
              </run>
            </image>
          </images>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.liquibase</groupId>
        <artifactId>liquibase-maven-plugin</artifactId>
        <executions>
          <execution>
            <phase>generate-sources</phase>
            <goals>
              <goal>update</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <changeLogFile>src/main/resources/${db.changeLogPath}</changeLogFile>
          <driver>org.postgresql.Driver</driver>
          <url>jdbc:postgresql://${db.host}:${db.port}/postgres</url>
          <username>${db.username}</username>
          <password>${db.password}</password>
          <promptOnNonLocalDatabase>false</promptOnNonLocalDatabase>
          <contexts>codegen</contexts>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.jooq</groupId>
        <artifactId>jooq-codegen-maven</artifactId>
        <executions>
          <execution>
            <phase>generate-sources</phase>
            <goals>
              <goal>generate</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <logging>WARN</logging>
          <jdbc>
            <driver>org.postgresql.Driver</driver>
            <url>jdbc:postgresql://${db.host}:${db.port}/postgres</url>
            <user>${db.username}</user>
            <password>${db.password}</password>
          </jdbc>
          <generator>
            <database>
              <name>org.jooq.meta.postgres.PostgresDatabase</name>
              <inputSchema>public</inputSchema>
              <includes>.*</includes>
              <excludes>DATABASECHANGELOG.*</excludes>
            </database>
            <target>
              <packageName>ca.vanzyl.concord.k8s.jooq</packageName>
              <directory>target/generated-sources/jooq</directory>
            </target>
            <generate>
              <deprecationOnUnknownTypes>false</deprecationOnUnknownTypes>
              <generatedAnnotation>false</generatedAnnotation>
            </generate>
          </generator>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>
