<?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.jwheatsheaf</artifactId>
    <groupId>com.io7m.jwheatsheaf</groupId>
    <version>4.0.0-beta0001</version>
  </parent>

  <artifactId>com.io7m.jwheatsheaf.documentation</artifactId>

  <name>com.io7m.jwheatsheaf.documentation</name>
  <description>JavaFX File Chooser (Documentation)</description>
  <url>https://www.io7m.com/software/jwheatsheaf</url>

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

  <dependencies>
    <dependency>
      <groupId>${project.groupId}</groupId>
      <artifactId>com.io7m.jwheatsheaf.api</artifactId>
      <version>${project.version}</version>
    </dependency>
    <dependency>
      <groupId>${project.groupId}</groupId>
      <artifactId>com.io7m.jwheatsheaf.ui</artifactId>
      <version>${project.version}</version>
    </dependency>
    <dependency>
      <groupId>${project.groupId}</groupId>
      <artifactId>com.io7m.jwheatsheaf.oxygen</artifactId>
      <version>${project.version}</version>
    </dependency>

    <dependency>
      <groupId>com.io7m.primogenitor</groupId>
      <artifactId>com.io7m.primogenitor.support</artifactId>
    </dependency>

    <dependency>
      <groupId>com.io7m.immutables.style</groupId>
      <artifactId>com.io7m.immutables.style</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.immutables</groupId>
      <artifactId>value</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.osgi</groupId>
      <artifactId>org.osgi.annotation.bundle</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.osgi</groupId>
      <artifactId>org.osgi.annotation.versioning</artifactId>
      <scope>provided</scope>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <!-- Copy documentation resources into build directory -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-resources-plugin</artifactId>
        <executions>
          <execution>
            <id>copy-documentation-resources</id>
            <goals>
              <goal>copy-resources</goal>
            </goals>
            <phase>generate-resources</phase>
            <configuration>
              <outputDirectory>${project.build.directory}/documentation/</outputDirectory>
              <resources>
                <resource>
                  <directory>src/main/resources/com/io7m/jwheatsheaf/documentation/</directory>
                  <filtering>true</filtering>
                </resource>
              </resources>
            </configuration>
          </execution>
        </executions>
      </plugin>

      <!-- Unpack sources of dependencies -->
      <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>
              <excludes>module-info.java</excludes>
              <includeGroupIds>${project.groupId}</includeGroupIds>
              <classifier>sources</classifier>
              <failOnMissingClassifierArtifact>false</failOnMissingClassifierArtifact>
              <outputDirectory>${project.build.directory}/javadoc-sources</outputDirectory>
            </configuration>
          </execution>
          <execution>
            <id>make-classpath</id>
            <phase>package</phase>
            <goals>
              <goal>build-classpath</goal>
            </goals>
            <configuration>
              <outputFile>${project.build.directory}/javadoc-classpath</outputFile>
            </configuration>
          </execution>
        </executions>
      </plugin>

      <!-- Javadoc handling -->
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>exec-maven-plugin</artifactId>
        <executions>
          <execution>
            <goals>
              <goal>java</goal>
            </goals>
            <phase>package</phase>
            <configuration>
              <mainClass>com.io7m.primogenitor.support.TrivialJavadoc</mainClass>
              <arguments>
                <argument>${project.build.directory}/javadoc-sources</argument>
                <argument>${project.build.directory}/javadoc-classpath</argument>
                <argument>${project.build.directory}/documentation/apidocs</argument>
                <argument>${project.build.directory}/javadoc-log.txt</argument>
                <argument>${project.build.directory}/javadoc-options</argument>
              </arguments>
            </configuration>
          </execution>
        </executions>
      </plugin>

      <!-- Produce documentation archive -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-assembly-plugin</artifactId>
        <configuration>
          <descriptors>
            <descriptor>src/main/assembly/documentation.xml</descriptor>
          </descriptors>
        </configuration>
        <executions>
          <execution>
            <id>make-assembly</id>
            <phase>package</phase>
            <goals>
              <goal>single</goal>
            </goals>
            <configuration>
              <appendAssemblyId>false</appendAssemblyId>
            </configuration>
          </execution>
        </executions>
      </plugin>

      <!-- Unpack the documentation archive to the parent's generated site minisite directory. -->
      <!-- This is arguably abusive, but there appears to be no other way to achieve it. -->
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>truezip-maven-plugin</artifactId>
        <inherited>false</inherited>
        <executions>
          <execution>
            <id>copy-site-documentation</id>
            <goals>
              <goal>copy</goal>
            </goals>
            <phase>site</phase>
            <configuration>
              <verbose>true</verbose>
              <fileset>
                <directory>
                  ${project.build.directory}/${project.name}-${project.version}.zip/${project.name}-${project.version}/
                </directory>
                <outputDirectory>${project.parent.build.directory}/minisite/documentation/</outputDirectory>
              </fileset>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

</project>