<?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>de.sormuras.junit</groupId>
        <artifactId>junit-platform-isolator-root</artifactId>
        <version>1.0.0-M10</version>
    </parent>

    <artifactId>junit-platform-isolator</artifactId>

    <properties>
        <jar.file.name>${project.artifactId}-${project.version}.jar</jar.file.name>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.junit.platform</groupId>
            <artifactId>junit-platform-launcher</artifactId>
            <version>${junit.platform.version}</version>
            <scope>provided</scope> <!-- Don't leak into 3rd-party projects! -->
        </dependency>

        <dependency>
            <groupId>de.sormuras.junit</groupId>
            <artifactId>junit-platform-isolator-java-11</artifactId> <!-- 11 first !! -->
            <version>${project.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>de.sormuras.junit</groupId>
            <artifactId>junit-platform-isolator-base-8</artifactId>
            <version>${project.version}</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>com.coveo</groupId>
                <artifactId>fmt-maven-plugin</artifactId>
            </plugin>
            <plugin>
                <artifactId>maven-clean-plugin</artifactId>
                <executions>
                    <execution>
                        <id>rm -r target/classes/**/*.class</id>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>clean</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <excludeDefaultDirectories>true</excludeDefaultDirectories>
                    <filesets>
                        <fileset>
                            <!-- Leave empty directories in place for maven-jar-plugin -->
                            <directory>target/classes</directory>
                            <includes>
                                <include>**/*.class</include>
                            </includes>
                        </fileset>
                    </filesets>
                    <verbose>true</verbose>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>1.6.0</version>
                <executions>
                    <execution>
                        <id>jar --update --release 11</id>
                        <phase>package</phase>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                        <configuration>
                            <executable>jar</executable>
                            <arguments>
                                <argument>--verbose</argument>
                                <argument>--update</argument>
                                <argument>--file</argument>
                                <argument>target/${jar.file.name}</argument>
                                <argument>-C</argument>
                                <argument>../${project.artifactId}-base-8/target/classes</argument>
                                <argument>.</argument>
                                <argument>--release</argument>
                                <argument>11</argument>
                                <argument>-C</argument>
                                <argument>../${project.artifactId}-java-11/target/classes</argument>
                                <argument>.</argument>
                            </arguments>
                        </configuration>
                    </execution>

                    <execution>
                        <id>jar --describe-module --release 11</id>
                        <phase>verify</phase>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                        <configuration>
                            <executable>jar</executable>
                            <arguments>
                                <argument>--describe-module</argument>
                                <argument>--file</argument>
                                <argument>target/${jar.file.name}</argument>
                                <argument>--release</argument>
                                <argument>11</argument>
                            </arguments>
                        </configuration>
                    </execution>

                    <execution>
                        <id>jar --update sources.jar</id>
                        <phase>package</phase>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                        <configuration>
                            <executable>jar</executable>
                            <arguments>
                                <argument>--verbose</argument>
                                <argument>--update</argument>
                                <argument>--file</argument>
                                <argument>target/${project.artifactId}-${project.version}-sources.jar</argument>
                                <argument>-C</argument>
                                <argument>../${project.artifactId}-base-8/src/main/java</argument>
                                <argument>.</argument>
                                <argument>--release</argument>
                                <argument>11</argument>
                                <argument>-C</argument>
                                <argument>../${project.artifactId}-java-11/src/main/java</argument>
                                <argument>.</argument>
                            </arguments>
                        </configuration>
                    </execution>

                    <execution>
                        <id>jar --create javadoc.jar</id>
                        <phase>package</phase>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                        <configuration>
                            <executable>jar</executable>
                            <arguments>
                                <argument>--create</argument>
                                <argument>--file</argument>
                                <argument>target/${project.artifactId}-${project.version}-javadoc.jar</argument>
                                <argument>-C</argument>
                                <argument>../${project.artifactId}-base-8/target/apidocs</argument>
                                <argument>.</argument>
                            </arguments>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

</project>
