<?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>
    <artifactId>com.io7m.looseleaf</artifactId>
    <groupId>com.io7m.looseleaf</groupId>
    <version>0.0.1</version>
  </parent>

  <artifactId>com.io7m.looseleaf.oci</artifactId>

  <packaging>pom</packaging>
  <name>com.io7m.looseleaf.oci</name>
  <description>Minimalist transactional HTTP key/value store (OCI image)</description>
  <url>https://www.io7m.com/software/looseleaf/</url>

  <properties>
    <mdep.analyze.skip>true</mdep.analyze.skip>
  </properties>

  <dependencies>
    <dependency>
      <groupId>${project.groupId}</groupId>
      <artifactId>com.io7m.looseleaf.cmdline</artifactId>
      <version>${project.version}</version>
      <classifier>distribution</classifier>
      <type>zip</type>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-resources-plugin</artifactId>
        <executions>
          <execution>
            <id>copy-resource-one</id>
            <phase>generate-sources</phase>
            <goals>
              <goal>copy-resources</goal>
            </goals>
            <configuration>
              <outputDirectory>${project.build.directory}/image</outputDirectory>
              <resources>
                <resource>
                  <directory>src/main/oci</directory>
                  <includes>
                    <include>Dockerfile</include>
                  </includes>
                </resource>
              </resources>
            </configuration>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
        <executions>
          <execution>
            <id>unpack-sources</id>
            <phase>package</phase>
            <goals>
              <goal>unpack-dependencies</goal>
            </goals>
            <configuration>
              <includeGroupIds>${project.groupId}</includeGroupIds>
              <includeArtifactIds>com.io7m.looseleaf.cmdline</includeArtifactIds>
              <classifier>distribution</classifier>
              <type>zip</type>
              <failOnMissingClassifierArtifact>true</failOnMissingClassifierArtifact>
              <outputDirectory>${project.build.directory}/image/</outputDirectory>
            </configuration>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <groupId>io.fabric8</groupId>
        <artifactId>docker-maven-plugin</artifactId>
        <executions>
          <execution>
            <id>build-oci-image</id>
            <phase>package</phase>
            <goals>
              <goal>build</goal>
            </goals>
            <configuration>
              <images>
                <image>
                  <name>io7m/looseleaf</name>
                  <build>
                    <contextDir>${project.build.directory}/image</contextDir>
                    <tags>
                      <tag>${project.version}-${buildNumber}</tag>
                    </tags>
                  </build>
                </image>
              </images>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

</project>
