<?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>org.sonatype.oss</groupId>
    <artifactId>oss-parent</artifactId>
    <version>7</version>
  </parent>

  <packaging>jar</packaging>
  <groupId>nu.pattern</groupId>
  <artifactId>opencv</artifactId>
  <version>2.4.9-4</version>
  <name>Pattern OpenCV</name>
  <description>OpenCV packaged with native libraries and loader for multiple platforms.</description>
  <url>http://github.com/patternconsulting/opencv</url>

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

  <profiles>
    <profile>
      <id>jdk-8</id>
      <activation>
        <jdk>1.8</jdk>
      </activation>
      <properties>
        <!-- OpenCV's Javadocs fail DocLint tests. See http://stackoverflow.com/a/16743137 for tip. -->
        <javadoc.parameters>-Xdoclint:none</javadoc.parameters>
      </properties>
    </profile>

    <profile>
      <id>release-sign-artifacts</id>
      <activation>
        <property>
          <name>gpg.sign</name>
          <value>true</value>
        </property>
      </activation>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-gpg-plugin</artifactId>
            <version>1.4</version>
            <executions>
              <execution>
                <id>sign-artifacts</id>
                <phase>verify</phase>
                <goals>
                  <goal>sign</goal>
                </goals>
                <configuration>
                  <useAgent>false</useAgent>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>

  <licenses>
    <license>
      <name>BSD License</name>
      <url>http://github.com/Itseez/opencv/raw/master/LICENSE</url>
    </license>
  </licenses>

  <scm>
    <url>http://github.com/patternconsulting/opencv</url>
    <connection>scm:git:http://github.com/patternconsulting/opencv.git</connection>
    <developerConnection>scm:git:http://github.com/patternconsulting/opencv.git</developerConnection>
    <tag>v2.4.9-3</tag>
  </scm>

  <issueManagement>
    <system>GitHub</system>
    <url>http://github.com/patternconsulting/opencv/issues</url>
  </issueManagement>

  <developers>
    <developer>
      <id>michaelahlers</id>
      <name>Michael Ahlers</name>
      <email>michael.ahlers@pattern.nu</email>
      <organization>Pattern</organization>
      <organizationUrl>http://pattern.nu</organizationUrl>
      <roles>
        <role>maintainer</role>
      </roles>
      <!--<properties>
        <picUrl>http://pattern.nu/images/team/michael.ahlers.png</picUrl>
      </properties>-->
    </developer>
  </developers>

  <build>
    <plugins>
      <!-- Extracts the compiled Java classes and sources built by the OpenCV project. Avoids any manual process which may introduce errors. -->
      <plugin>
        <artifactId>maven-antrun-plugin</artifactId>
        <version>1.3</version>
        <executions>
          <execution>
            <phase>generate-sources</phase>
            <configuration>
              <tasks>
                <echo>Extracting Java classes.</echo>
                <unjar src="${project.basedir}/upstream/opencv-249.jar" dest="${project.build.directory}/classes">
                  <patternset>
                    <include name="**/*"/>
                  </patternset>
                </unjar>

                <echo>Extracting Java test classes.</echo>
                <unjar src="${project.basedir}/upstream/opencv-test.jar" dest="${project.build.directory}/test-classes">
                  <patternset>
                    <include name="**/*.class"/>
                  </patternset>
                </unjar>

                <echo>Extracting Java sources.</echo>
                <unjar src="${project.basedir}/upstream/opencv-249.jar" dest="${project.build.directory}/upstream-sources">
                  <patternset>
                    <include name="**/*.java"/>
                  </patternset>
                </unjar>
              </tasks>
            </configuration>
            <goals>
              <goal>run</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

      <!-- The upstream sources should be included in the source JAR, but not the binary JAR. Ensure upstream-sources is added after the compile phase and before package. -->
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>build-helper-maven-plugin</artifactId>
        <version>1.8</version>
        <executions>
          <execution>
            <phase>prepare-package</phase>
            <goals>
              <goal>add-source</goal>
            </goals>
            <configuration>
              <sources>
                <source>${project.build.directory}/upstream-sources</source>
              </sources>
            </configuration>
          </execution>
        </executions>
      </plugin>

      <!-- Package local and upstream sources. -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-source-plugin</artifactId>
        <version>2.2.1</version>
        <executions>
          <execution>
            <goals>
              <goal>jar</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>2.12.4</version>
        <configuration>
          <systemProperties>
            <property>
              <name>java.util.logging.config.file</name>
              <value>${project.build.directory}/test-classes/logging.properties</value>
            </property>
          </systemProperties>
          <properties>
            <!-- Bootstrap the test classes with the extracted library, if applicable. -->
            <property>
              <name>listener</name>
              <value>nu.pattern.OpenCVRunListener</value>
            </property>
          </properties>
          <!-- It's preferred to keep all upstream resources contained in a single location. Since the test classes use the working directory to find their fixtures, it's necessary to specify this location at test time. -->
          <workingDirectory>${project.basedir}/upstream</workingDirectory>
          <excludes>
            <!-- Contains no test cases (it's the base class for others, however), so it must be excluded to avoid failrues. -->
            <exclude>**/OpenCVTestCase.*</exclude>
          </excludes>
        </configuration>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-javadoc-plugin</artifactId>
        <version>2.9.1</version>
        <executions>
          <execution>
            <id>attach-javadocs</id>
            <goals>
              <goal>jar</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <links>
            <link>http://docs.opencv.org/java/</link>
            <link>http://docs.oracle.com/javase/8/docs/api/</link>
          </links>
          <additionalparam>${javadoc.parameters}</additionalparam>
        </configuration>
      </plugin>
    </plugins>
  </build>

  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.11</version>
      <scope>test</scope>
    </dependency>
  </dependencies>

</project>
