<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>

    <groupId>com.kichik.pecoff4j</groupId>
    <artifactId>pecoff4j</artifactId>
    <version>0.4.1</version>

    <name>${project.groupId}:${project.artifactId}</name>
    <description>Library for parsing portable (PE) executables, the format used by Windows.</description>
    <url>https://github.com/kichik/pecoff4j</url>

    <developers>
        <developer>
            <id>kichik</id>
            <name>Amir Szekely</name>
            <url>https://github.com/kichik</url>
        </developer>
    </developers>

    <licenses>
        <license>
            <name>Common Public 1.0</name>
            <url>https://github.com/kichik/pecoff4j/blob/master/cpl-v10.html</url>
        </license>
    </licenses>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <scm>
        <connection>scm:git:git://github.com/kichik/pecoff4j.git</connection>
        <developerConnection>scm:git:ssh://github.com:kichik/pecoff4j.git</developerConnection>
        <url>https://github.com/kichik/pecoff4j</url>
    </scm>

    <distributionManagement>
        <snapshotRepository>
            <id>ossrh</id>
            <url>https://oss.sonatype.org/content/repositories/snapshots</url>
        </snapshotRepository>
        <repository>
            <id>ossrh</id>
            <url>https://oss.sonatype.org/service/local/staging/deploy/maven2</url>
        </repository>
    </distributionManagement>


    <profiles>
        <profile>
            <!-- simple profile for Java 8, ony for testing backwards compatibility -->
            <activation>
                <jdk>1.8</jdk>
            </activation>
            <id>jdk8</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-compiler-plugin</artifactId>
                        <version>3.8.1</version>
                        <configuration>
                            <source>1.8</source>
                            <target>1.8</target>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <!-- main profile -->
        <profile>
            <activation>
                <jdk>[1.9,)</jdk>
            </activation>
            <id>jdk9</id>
            <properties>
                <maven.compiler.release>8</maven.compiler.release>
            </properties>
            <build>
                <plugins>
                    <!-- Mark Java 9 sources as a source directory, but disable to prevent adding to java-7-compile task -->
                    <!-- This signals to IDEs that the java9 directory should be added as a source directory -->
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>build-helper-maven-plugin</artifactId>
                        <version>3.2.0</version>
                        <executions>
                            <execution>
                                <id>add-source</id>
                                <phase>none</phase>
                                <goals>
                                    <goal>add-source</goal>
                                </goals>
                                <configuration>
                                    <sources>
                                        <source>${project.basedir}/src/main/java9</source>
                                    </sources>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <!-- Compile multi-release JAR -->
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-compiler-plugin</artifactId>
                        <version>3.8.1</version>
                        <executions>
                            <!-- disable default compilation phase, as it is used to signal the correct Java version to IDES-->
                            <!-- specifying `< java 9` will not allow IDEs to properly interpret module-info.java  -->
                            <execution>
                                <id>default-compile</id>
                                <phase>none</phase>
                                <goals>
                                    <goal>compile</goal>
                                </goals>
                                <configuration>
                                    <!-- indicate at least Java 9 language level -->
                                    <release>9</release>
                                </configuration>
                            </execution>
                            <!-- compile sources for Java 8 -->
                            <execution>
                                <id>java-8-compile</id>
                                <goals>
                                    <goal>compile</goal>
                                </goals>
                                <configuration>
                                    <release>${maven.compiler.release}</release>
                                </configuration>
                            </execution>
                            <!-- compile module-info for Java 9, stored under META-INF/versions/9/module-info.class -->
                            <execution>
                                <id>java-9-compile</id>
                                <phase>compile</phase>
                                <goals>
                                    <goal>compile</goal>
                                </goals>
                                <configuration>
                                    <release>9</release>
                                    <compileSourceRoots>
                                        <compileSourceRoot>${project.basedir}/src/main/java9</compileSourceRoot>
                                    </compileSourceRoots>
                                    <multiReleaseOutput>true</multiReleaseOutput>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <!-- Mark artifact as a multi-release JAR -->
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-jar-plugin</artifactId>
                        <version>3.2.0</version>
                        <configuration>
                            <archive>
                                <manifestEntries>
                                    <Multi-Release>true</Multi-Release>
                                </manifestEntries>
                            </archive>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-gpg-plugin</artifactId>
                        <version>1.6</version>
                        <configuration>
                            <gpgArguments>
                                <arg>--pinentry-mode</arg>
                                <arg>loopback</arg>
                            </gpgArguments>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>org.sonatype.plugins</groupId>
                        <artifactId>nexus-staging-maven-plugin</artifactId>
                        <version>1.6.7</version>
                        <extensions>true</extensions>
                        <configuration>
                            <serverId>ossrh</serverId>
                            <nexusUrl>https://oss.sonatype.org/</nexusUrl>
                            <autoReleaseAfterClose>true</autoReleaseAfterClose>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

    <build>
        <plugins>
            <plugin>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.22.2</version>
            </plugin>
        </plugins>
    </build>

    <dependencies>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-api</artifactId>
            <version>5.7.2</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-engine</artifactId>
            <version>5.7.2</version>
            <scope>test</scope>
        </dependency>
    </dependencies>
</project>
