<?xml version="1.0" encoding="UTF-8"?>

<!--
 * See the NOTICE file distributed with this work for additional
 * information regarding copyright ownership.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see http://www.gnu.org/licenses/
-->

<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/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <parent>
    <groupId>org.phenotips</groupId>
    <artifactId>phenotips-distribution</artifactId>
    <version>1.2.2</version>
  </parent>

  <artifactId>phenotips-dmg</artifactId>
  <packaging>pom</packaging>
  <name>PhenoTips - DMG Distribution</name>
  <description>Distribution containing the PhenoTips application packaged as a disk image with a Mac OS application bundle.</description>

  <properties>
    <!-- Required properties -->
    <srcDir>src/main/app-resources</srcDir>
    <bundleName>PhenoTips</bundleName>
    <bundleExecutable>start.sh</bundleExecutable>
    <standaloneDir>phenotips-standalone-${project.version}</standaloneDir>
    <dmgDir>${bundleName} DMG</dmgDir>
    <bundleDir>${dmgDir}/${bundleName}.app</bundleDir>
    <makeDmgScript>makeDMG.sh</makeDmgScript>
    <codesignCertCommonName>Developer ID Application: Michael Brudno (Q62G548LC6)</codesignCertCommonName>
    <!-- Optional properties -->
    <iconFile>application-icon.icns</iconFile>
    <!-- the image in volumeBackgroundFile has to show a right-pointing arrow in the center -->
    <!-- image size: min width = (iconSize * 4), min height = (iconSize * 2) -->
    <volumeBackgroundFile>volume-background.png</volumeBackgroundFile>
    <!-- if iconSize is missing, its default value is 100 -->
    <iconSize>100</iconSize>
    <includeApplicationsSymlink>true</includeApplicationsSymlink>
    <internetEnable>true</internetEnable>
  </properties>

  <dependencies>
    <dependency>
      <groupId>${project.groupId}</groupId>
      <artifactId>phenotips-standalone</artifactId>
      <version>${project.version}</version>
      <type>zip</type>
      <optional>true</optional>
    </dependency>
  </dependencies>

  <profiles>
    <profile>
      <id>mac</id>
      <activation>
        <activeByDefault>false</activeByDefault>
        <os>
          <family>mac</family>
          <name>mac os x</name>
        </os>
      </activation>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-assembly-plugin</artifactId>
            <executions>
              <execution>
                <id>make-assembly</id>
                <phase>package</phase>
                <goals>
                  <goal>single</goal>
                </goals>
                <configuration>
                  <descriptors>
                    <descriptor>src/assembly/application.xml</descriptor>
                  </descriptors>
                  <appendAssemblyId>false</appendAssemblyId>
                  <attach>false</attach>
                </configuration>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>exec-maven-plugin</artifactId>
            <executions>
              <execution>
                <id>make-dmg</id>
                <phase>package</phase>
                <goals>
                  <goal>exec</goal>
                </goals>
                <configuration>
                  <executable>${project.build.directory}/${project.build.finalName}/${makeDmgScript}</executable>
                </configuration>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>build-helper-maven-plugin</artifactId>
            <executions>
              <execution>
                <id>attach-dmg</id>
                <phase>package</phase>
                <goals>
                  <goal>attach-artifact</goal>
                </goals>
                <configuration>
                  <artifacts>
                    <artifact>
                      <file>${project.build.directory}/${project.build.finalName}.dmg</file>
                      <type>dmg</type>
                    </artifact>
                  </artifacts>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>
</project>
