<?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">
    <parent>
        <artifactId>dashj-parent</artifactId>
        <groupId>org.dashj</groupId>
        <version>0.17.5</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>

    <artifactId>dashj-bls</artifactId>

    <build>
        <plugins>
            <!-- Ensure compilation is done under Java 6 for backwards compatibility -->
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>

            <!-- generate the bls-signature library -->
            <plugin>
                <groupId>com.googlecode.cmake-maven-project</groupId>
                <artifactId>cmake-maven-plugin</artifactId>
                <version>3.7.2-b1</version>
                <executions>
                    <execution>
                        <id>cmake-generate</id>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                        <configuration>
                            <sourcePath>
                                <!-- The directory containing CMakeLists -->
                                ${project.basedir}
                            </sourcePath>
                            <targetPath>
                                <!-- The directory write the project files to -->
                                ${project.build.directory}/cmake
                            </targetPath>
                            <generator>
                                <!-- One of the generators defined at https://cmake.org/cmake/help/v3.7/manual/cmake-generators.7.html -->
                                ${cmake.generator}
                            </generator>
                            <classifier>
                                <!-- The classifier of the current platform. One of [windows-x86_32, windows-x86_64, linux-x86_32, linux-x86_64, linux-arm_32, mac-x86_64]. -->
                                <!--linux-x86_64-->
                                ${cmake.classifier}
                            </classifier>
                            <environmentVariables>
                                <CMAKE_CLASSIFIER>${cmake.classifier}</CMAKE_CLASSIFIER>
                            </environmentVariables>
                            <downloadBinaries>${download.cmake}</downloadBinaries>
                        </configuration>
                    </execution>
                    <execution>
                        <id>cmake-compile</id>
                        <goals>
                            <goal>compile</goal>
                        </goals>
                        <configuration>
                            <config>
                                <!-- Optional: the build configuration (e.g. "Release|x64") -->
                            </config>
                            <target>
                                <!-- Optional: the build "target" -->
                            </target>
                            <projectDirectory>
                                <!-- "targetPath" from the "generate" goal -->
                                ${project.build.directory}/cmake
                            </projectDirectory>
                            <classifier>
                                <!-- The classifier of the current platform. One of [windows-x86_32, windows-x86_64, linux-x86_32, linux-x86_64, linux-arm_32, mac-x86_64]. -->
                                ${cmake.classifier}
                            </classifier>
                            <environmentVariables>
                                <key>value</key>
                            </environmentVariables>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <!-- Generate source and javadoc jars: Maven Central requires this -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-source-plugin</artifactId>
                <executions>
                    <execution>
                        <id>attach-sources</id>
                        <phase>verify</phase>
                        <goals>
                            <goal>jar-no-fork</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <executions>
                    <execution>
                        <id>attach-javadocs</id>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <detectLinks/>
                    <links>
                        <link>http://docs.guava-libraries.googlecode.com/git-history/release/javadoc/</link>
                    </links>
                    <detectJavaApiLink/>
                    <quiet>true</quiet>
                </configuration>
            </plugin>

            <!-- Verify the dependency chain: see https://github.com/gary-rowe/BitcoinjEnforcerRules for
               more information on this.
            -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-enforcer-plugin</artifactId>
                <executions>
                    <execution>
                        <id>enforce</id>
                        <phase>verify</phase>
                        <goals>
                            <goal>enforce</goal>
                        </goals>
                        <configuration>
                            <rules>
                                <DependencyConvergence/>
                                <digestRule implementation="uk.co.froot.maven.enforcer.DigestRule">

                                    <!-- Create a snapshot to build the list of URNs below -->
                                    <buildSnapshot>true</buildSnapshot>

                                    <!-- List of required hashes -->
                                    <!-- Format is URN of groupId:artifactId:version:type:classifier:scope:hash -->
                                    <!-- classifier is "null" if not present -->
                                    <urns>
                                        <urn>junit:junit:4.12:jar:null:test:2973d150c0dc1fefe998f834810d68f278ea58ec</urn>
                                        <urn>com.google.guava:guava:27.1-android:jar:null:compile:a80ef47421d6607e749f8b7282dd7dee61adfea7</urn>
                                        <!-- A check for the rules themselves -->
                                        <urn>uk.co.froot.maven.enforcer:digest-enforcer-rules:0.0.1:jar:null:runtime:16a9e04f3fe4bb143c42782d07d5faf65b32106f</urn>
                                    </urns>
                                </digestRule>
                            </rules>
                        </configuration>
                    </execution>
                </executions>

                <!-- Ensure we download the enforcer rules -->
                <dependencies>
                    <dependency>
                        <groupId>uk.co.froot.maven.enforcer</groupId>
                        <artifactId>digest-enforcer-rules</artifactId>
                        <version>0.0.1</version>
                    </dependency>
                </dependencies>

            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <executions>
                    <!-- Create the bundled JAR, it's easier for some people -->
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                        <configuration>
                            <minimizeJar>false</minimizeJar>
                            <filters>
                                <filter>
                                    <!-- exclude signatures, the bundling process breaks them for some reason -->
                                    <artifact>*:*</artifact>
                                    <excludes>
                                        <exclude>META-INF/*.SF</exclude>
                                        <exclude>META-INF/*.DSA</exclude>
                                        <exclude>META-INF/*.RSA</exclude>
                                    </excludes>
                                </filter>
                            </filters>
                            <shadedArtifactAttached>true</shadedArtifactAttached>
                            <shadedClassifierName>bundled</shadedClassifierName>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <!-- Code coverage plugin, generates coverage report to target/site/jacoco/
                To skip coverage generation add -Djacoco.skip=true
             -->
            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <version>0.7.5.201505241946</version>
                <configuration>
                    <excludes>
                        <!--exclude>**/Protos*.class</exclude--> <!-- Exclude generated protobuf classes -->
                    </excludes>
                </configuration>
                <executions>
                    <execution>
                        <id>pre-unit-test</id>
                        <goals>
                            <goal>prepare-agent</goal>
                        </goals>
                        <configuration>
                            <destFile>${project.build.directory}/coverage-reports/jacoco.exec</destFile>
                            <propertyName>surefireArgLine</propertyName>
                        </configuration>
                    </execution>
                    <execution>
                        <id>post-unit-test</id>
                        <phase>test</phase>
                        <goals>
                            <goal>report</goal>
                        </goals>
                        <configuration>
                            <dataFile>${project.build.directory}/coverage-reports/jacoco.exec</dataFile>
                            <outputDirectory>${project.reporting.outputDirectory}/jacoco</outputDirectory>
                        </configuration>
                    </execution>
                    <execution>
                        <id>default-report</id>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>report</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <!-- Unit tests plugin, to skip runing test add -Dmaven.test.skip -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <!-- First argument increases the maximum heap size, second argument disables a nasty HotSpot optimization
                         (see http://jawspeak.com/2010/05/26/hotspot-caused-exceptions-to-lose-their-stack-traces-in-production-and-the-fix/)
                         and last argument is required for code coverage to work. -->
                    <argLine>-Xmx1024m -XX:-OmitStackTraceInFastThrow ${surefireArgLine} -Djava.library.path=${project.build.directory}/cmake</argLine>
                    <runOrder>alphabetical</runOrder>
                    <systemProperties>
                        <property>
                            <name>java.util.logging.config.file</name>
                            <value>src/test/resources/logging.properties</value>
                        </property>
                    </systemProperties>
                </configuration>
            </plugin>

            <!-- Coveralls is a online code coverage tool, you can track code coverage here: https://coveralls.io/r/dashevo/dashj -->
            <plugin>
                <groupId>org.eluder.coveralls</groupId>
                <artifactId>coveralls-maven-plugin</artifactId>
                <version>3.1.0</version>
            </plugin>
        </plugins>
    </build>

    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
            <version>27.1-android</version>
        </dependency>
    </dependencies>

    <properties>
        <classifier>${platform}</classifier>
        <download.cmake>true</download.cmake>
        <cmake.version>3.7.2-b1</cmake.version>
    </properties>

    <profiles>
        <profile>
            <id>list-profiles</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <artifactId>maven-antrun-plugin</artifactId>
                        <executions>
                            <execution>
                                <phase>validate</phase>
                                <goals>
                                    <goal>run</goal>
                                </goals>
                                <configuration>
                                    <tasks>
                                        <echo>Please pick one of the following profiles:</echo>
                                        <echo>* windows-x86_32-debug</echo>
                                        <echo>* windows-x86_32-release</echo>
                                        <echo>* windows-x86_32_64-debug</echo>
                                        <echo>* windows-x86_32_64-release</echo>
                                        <echo>* linux-x86_32-debug</echo>
                                        <echo>* linux-x86_32-release</echo>
                                        <echo>* linux-x86_64-debug</echo>
                                        <echo>* linux-x86_64-release</echo>
                                        <echo>* mac-x86_64-debug</echo>
                                        <echo>* mac-x86_64-release</echo>
                                        <echo/>
                                        <echo>For instance: mvn -Pwindows-x86_32-debug install</echo>
                                        <fail/>
                                    </tasks>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>windows-x86_32-debug</id>
            <properties>
                <platform>windows-x86_32</platform>
                <build.type>debug</build.type>
                <cmake.classifier>windows-x86_32</cmake.classifier>
                <cmake.generator>Visual Studio 14 2015</cmake.generator>
                <cmake.config>${build.type}</cmake.config>
                <!--
                CMake interprets the lack of a generator architecture ("-A<platform>") as x86. There doesn't
                seem to be any other way to specify it.
                -->
            </properties>
        </profile>
        <profile>
            <id>windows-x86_32-release</id>
            <activation>
                <property>
                    <name>osDetection</name>
                    <value>!false</value>
                </property>
                <os>
                    <family>windows</family>
                    <arch>x86</arch>
                </os>
            </activation>
            <properties>
                <platform>windows-x86_32</platform>
                <build.type>release</build.type>
                <cmake.classifier>windows-x86_32</cmake.classifier>
                <cmake.generator>Visual Studio 14 2015</cmake.generator>
                <cmake.config>${build.type}</cmake.config>
                <!--
                CMake interprets the lack of a generator architecture ("-A<platform>") as x86. There doesn't
                seem to be any other way to specify it.
                -->
            </properties>
        </profile>
        <profile>
            <id>windows-x86_64-debug</id>
            <properties>
                <platform>windows-x86_64</platform>
                <build.type>debug</build.type>
                <cmake.classifier>windows-x86_64</cmake.classifier>
                <cmake.generator>MinGW Makefiles</cmake.generator>
                <cmake.options>-Ax64</cmake.options>
                <cmake.config>${build.type}</cmake.config>
            </properties>
        </profile>
        <profile>
            <id>windows-x86_64-release</id>
            <activation>
                <property>
                    <name>osDetection</name>
                    <value>!false</value>
                </property>
                <os>
                    <family>windows</family>
                    <arch>amd64</arch>
                </os>
            </activation>
            <properties>
                <platform>windows-x86_64</platform>
                <build.type>release</build.type>
                <cmake.classifier>windows-x86_64</cmake.classifier>
                <cmake.generator>MinGW Makefiles</cmake.generator>
                <cmake.options>-Ax64</cmake.options>
                <cmake.config>${build.type}</cmake.config>
            </properties>
        </profile>
        <profile>
            <id>linux-x86_32-debug</id>
            <properties>
                <platform>linux-x86_32</platform>
                <build.type>debug</build.type>
                <cmake.classifier>linux-x86_32</cmake.classifier>
                <cmake.generator>Unix Makefiles</cmake.generator>
                <download.cmake>false</download.cmake>
            </properties>
        </profile>
        <profile>
            <id>linux-x86_32-release</id>
            <activation>
                <property>
                    <name>osDetection</name>
                    <value>!false</value>
                </property>
                <os>
                    <family>linux</family>
                    <arch>i386</arch>
                </os>
            </activation>
            <properties>
                <platform>linux-x86_32</platform>
                <build.type>release</build.type>
                <cmake.classifier>linux-x86_32</cmake.classifier>
                <cmake.generator>Unix Makefiles</cmake.generator>
                <download.cmake>false</download.cmake>
            </properties>
        </profile>
        <profile>
            <id>linux-x86_64-debug</id>
            <properties>
                <platform>linux-x86_64</platform>
                <build.type>debug</build.type>
            </properties>
        </profile>
        <profile>
            <id>linux-x86_64-release</id>
            <activation>
                <property>
                    <name>osDetection</name>
                    <value>!false</value>
                </property>
                <os>
                    <family>linux</family>
                    <arch>amd64</arch>
                </os>
            </activation>
            <properties>
                <platform>linux-x86_64</platform>
                <build.type>release</build.type>
                <cmake.classifier>linux-x86_64</cmake.classifier>
                <cmake.generator>Unix Makefiles</cmake.generator>
            </properties>
        </profile>
        <profile>
            <id>mac-x86_64-debug</id>
            <properties>
                <platform>mac-x86_64</platform>
                <build.type>debug</build.type>
                <cmake.classifier>mac-x86_64</cmake.classifier>
                <cmake.generator>Unix Makefiles</cmake.generator>
            </properties>
        </profile>
        <profile>
            <id>mac-x86_64-release</id>
            <activation>
                <property>
                    <name>osDetection</name>
                    <value>!false</value>
                </property>
                <os>
                    <family>mac</family>
                    <arch>x86_64</arch>
                </os>
            </activation>
            <properties>
                <platform>mac-x86_64</platform>
                <build.type>release</build.type>
                <cmake.classifier>mac-x86_64</cmake.classifier>
                <cmake.generator>Unix Makefiles</cmake.generator>
            </properties>
        </profile>
        <profile>
            <id>portable</id>
            <!--
            Sonatype requires a main jar, even for platform-specific artifacts, so we supply it with an
            empty file.
            -->
            <build>
                <plugins>
                    <plugin>
                        <groupId>com.googlecode.cmake-maven-project</groupId>
                        <artifactId>cmake-maven-plugin</artifactId>
                        <version>${cmake.version}</version>
                        <executions>
                            <execution>
                                <id>cmake-generate</id>
                                <phase>none</phase>
                            </execution>
                            <execution>
                                <id>cmake-compile</id>
                                <phase>none</phase>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
            <properties>
                <platform>portable</platform>
                <build.type>release</build.type>
                <classifier/>
            </properties>
        </profile>
            <profile>
                <id>no-build-bls</id>
                <build>
                    <plugins>
                        <plugin>
                            <groupId>com.googlecode.cmake-maven-project</groupId>
                            <artifactId>cmake-maven-plugin</artifactId>
                            <version>3.7.2-b1</version>
                            <executions>
                                <execution>
                                    <id>cmake-generate</id> <!-- here there must be the same identifier as defined in <build><plugins> section -->
                                    <phase>none</phase> <!-- this disables plugin -->
                                </execution>
                                <execution>
                                    <id>cmake-compile</id> <!-- here there must be the same identifier as defined in <build><plugins> section -->
                                    <phase>none</phase> <!-- this disables plugin -->
                                </execution>
                            </executions>
                        </plugin>
                    </plugins>
                </build>
            </profile>
    </profiles>

</project>