<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>us.hebi.matlab</groupId>
    <artifactId>mat-file-io</artifactId>
    <version>0.1.2</version>
    <packaging>jar</packaging>

    <name>Mat-File IO</name>
    <description>
        Java library for reading and writing MAT Files that are compatible with MATLAB's MAT-File Format
    </description>
    <url>https://github.com/HebiRobotics/MatlabTools</url>

    <organization>
        <name>HEBI Robotics</name>
        <url>http://www.hebirobotics.com</url>
    </organization>
    <inceptionYear>2018</inceptionYear>

    <!-- Maven Central configuration copied from https://github.com/davidcarboni/releaser -->
    <!-- Required: license information: -->
    <licenses>
        <license>
            <name>The Apache Software License, Version 2.0</name>
            <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
            <distribution>repo</distribution>
            <comments>A business-friendly OSS license</comments>
        </license>
    </licenses>

    <!-- Required: source control information: -->
    <scm>
        <url>https://github.com/HebiRobotics/MatlabTools</url>
        <connection>scm:git:git://github.com/HebiRobotics/MatlabTools.git</connection>
        <developerConnection>scm:git:git@github.com:HebiRobotics/MatlabTools.git</developerConnection>
        <tag>mat-file-io-0.1.2</tag>
    </scm>

    <!-- Maven Central Distribution -->
    <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>

    <!-- Required: developer information: -->
    <developers>
        <developer>
            <id>ennerf</id>
            <name>Florian Enner</name>
            <email>florian@hebirobotics.com</email>
            <url>https://github.com/ennerf</url>
            <organization>HEBI Robotics</organization>
            <organizationUrl>https://github.com/HebiRobotics</organizationUrl>
        </developer>
    </developers>

    <properties>

        <!-- Set Syntax level to Java9 so that IDEs don't complain about the module-info.java
         and so we can use try-with-resources and Lambdas in test Syntax -->
        <maven.compiler.source>9</maven.compiler.source>
        <maven.compiler.target>9</maven.compiler.target>

        <!-- Set the actual target to minimum Java version compatible with Matlab >2009a -->
        <matlab.target>1.6</matlab.target>

        <!-- Other Settings -->
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <gpg.keyname /> <!-- set via settings.xml to sign release artifacts-->

        <!-- License Headers (http://www.mojohaus.org/license-maven-plugin/update-file-header-mojo.html) -->
        <license.licenseName>apache_v2</license.licenseName>
        <license.addJavaLicenseAfterPackage>false</license.addJavaLicenseAfterPackage>
        <license.trimHeaderLine>true</license.trimHeaderLine>

        <!-- For now, disable 'missing' warnings about undocumented @param and @throws -->
        <doclint>html,syntax,accessibility,reference</doclint>

    </properties>

    <!-- Dependency management (keep in alphabetical order) -->
    <dependencies>

        <dependency> <!-- for experimental conversion -->
            <groupId>org.ejml</groupId>
            <artifactId>ejml-all</artifactId>
            <version>0.35</version>
            <scope>test</scope>
        </dependency>

        <dependency> <!-- Unit Tests -->
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
            <scope>test</scope>
        </dependency>

    </dependencies>

    <!-- Build Process -->
    <build>

        <!-- Include the README, NOTICE and LICENSE files: -->
        <resources>
            <resource>
                <directory>${project.basedir}</directory>
                <includes>
                    <include>README*</include>
                    <include>NOTICE*</include>
                    <include>LICENSE*</include>
                </includes>
            </resource>
        </resources>

        <plugins>

            <!-- Java 9 and later: compile in 2 stages so we can get a module-info w/ target sources -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.0</version>
                <executions>

                    <!-- https://maven.apache.org/plugins/maven-compiler-plugin/examples/module-info.html -->

                    <!-- 1) default-compile: Compile everything w/ Java 9 to make sure the module-info is correct -->
                    <!-- (called implicitly) -->

                    <!-- 2) default-testCompile: Compile tests w/ Java 9 so we can use advanced syntax -->
                    <!-- (called implicitly) -->

                    <!-- 3) Re-compile everything for target VM except the module-info.java -->
                    <execution>
                        <id>target-compile</id>
                        <goals>
                            <goal>compile</goal>
                        </goals>
                        <configuration>
                            <!-- Note:
                            Do not set "<release>6</release>" as that disables jdk.unsupported! It will also
                            ignore the module-info.java file as well as disable the manual 'add-module' compiler
                            argument, which makes it impossible to use sun.misc.Unsafe. After a lot of tinkering,
                            the only way I got it to work was to have an existing module-info from the previous
                            compilation step, and to revert to just using the 'target' & 'source' options. -->
                            <source>${matlab.target}</source>
                            <target>${matlab.target}</target>
                            <excludes>
                                <exclude>module-info.java</exclude>
                            </excludes>
                            <jdkToolchain>
                                <version>[1.6,9)</version>
                            </jdkToolchain>
                        </configuration>
                    </execution>
                </executions>
                <configuration>
                    <jdkToolchain>
                        <version>[9,)</version>
                    </jdkToolchain>
                </configuration>
            </plugin>

            <!-- Add licenses to files -->
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>license-maven-plugin</artifactId>
                <version>1.16</version>
                <executions>
                    <execution>
                        <id>first</id>
                        <goals>
                            <goal>update-file-header</goal>
                        </goals>
                        <phase>process-sources</phase>
                    </execution>
                </executions>
            </plugin>

            <!-- Optional: ensure the manifest contains artifact version information: -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>2.4</version>
                <configuration>
                    <archive>
                        <manifest>
                            <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
                            <addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
                        </manifest>
                    </archive>
                </configuration>
            </plugin>

            <!-- Required: Source Jar -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-source-plugin</artifactId>
                <version>3.0.1</version>
                <executions>
                    <execution>
                        <id>attach-sources</id>
                        <phase>verify</phase>
                        <goals>
                            <goal>jar-no-fork</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <!-- Required: Javadoc Jar -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <version>3.0.1</version>
                <executions>
                    <execution>
                        <id>attach-javadoc</id>
                        <phase>verify</phase>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <!-- Release -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-release-plugin</artifactId>
                <version>2.5.3</version>
                <configuration>
                    <localCheckout>true</localCheckout>
                    <pushChanges>false</pushChanges>
                    <mavenExecutorId>forked-path</mavenExecutorId>
                </configuration>
            </plugin>

            <!-- Deployment -->
            <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>

    <profiles>
        <!-- Java 8 and below: ignore module-info -->
        <profile>
            <id>noJava9</id>
            <activation>
                <!-- https://maven.apache.org/enforcer/enforcer-rules/versionRanges.html -->
                <!--<jdk>(,9)</jdk>--> <!-- makes IntelliJ 2018.2 always default to 1.6 sources, so do manually -->
            </activation>
            <build>
                <pluginManagement>
                    <plugins>
                        <plugin>
                            <groupId>org.apache.maven.plugins</groupId>
                            <artifactId>maven-compiler-plugin</artifactId>
                            <version>3.8.0</version>
                            <configuration>
                                <excludes>
                                    <exclude>module-info.java</exclude>
                                </excludes>
                                <source>${matlab.target}</source>
                                <target>${matlab.target}</target>
                                <testSource>8</testSource>
                                <testTarget>8</testTarget>
                            </configuration>
                        </plugin>
                    </plugins>
                </pluginManagement>
            </build>
        </profile>

        <!-- GPG Signature on release -->
        <profile>
            <id>release-sign-artifacts</id>
            <activation>
                <property>
                    <name>performRelease</name>
                    <value>true</value>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-gpg-plugin</artifactId>
                        <version>1.6</version>
                        <executions>
                            <execution>
                                <id>sign-artifacts</id>
                                <phase>verify</phase>
                                <goals>
                                    <goal>sign</goal>
                                </goals>
                                <configuration>
                                    <keyname>${gpg.keyname}</keyname>
                                    <passphraseServerId>${gpg.keyname}</passphraseServerId>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>

    </profiles>

</project>
