<?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.4.8</version>
  </parent>

  <artifactId>phenotips-rpm</artifactId>
  <packaging>rpm</packaging>
  <name>PhenoTips - RPM Distribution</name>
  <description>Distribution containing the PhenoTips application deployed under Tomcat, with HSQLDB for storage, as a RedHat (.rpm) package.</description>

  <properties>
    <ptwar.path>${project.build.directory}/ptwar</ptwar.path>
    <data.path>${project.build.directory}/phenotips</data.path>
    <db.path>${data.path}/data</db.path>
    <xwiki.properties.environment.permanentDirectory>/var/lib/phenotips/data</xwiki.properties.environment.permanentDirectory>
  </properties>

  <dependencies>
    <dependency>
      <groupId>${project.groupId}</groupId>
      <artifactId>phenotips-war</artifactId>
      <version>${project.version}</version>
      <type>war</type>
    </dependency>

    <dependency>
      <groupId>${project.groupId}</groupId>
      <artifactId>database-zip</artifactId>
      <version>${project.version}</version>
      <type>zip</type>
    </dependency>

    <dependency>
      <groupId>${project.groupId}</groupId>
      <artifactId>solr-configuration</artifactId>
      <version>${project.version}</version>
      <type>jar</type>
      <optional>true</optional>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <!-- Unpack the war -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
        <executions>
          <execution>
            <id>unzip-phenotips</id>
            <phase>process-resources</phase>
            <goals>
              <goal>unpack</goal>
            </goals>
            <configuration>
              <artifactItems>
                <artifactItem>
                  <groupId>${project.groupId}</groupId>
                  <artifactId>phenotips-war</artifactId>
                  <version>${project.version}</version>
                  <type>war</type>
                </artifactItem>
              </artifactItems>
              <excludes>**\/xwiki.cfg,**/xwiki.properties,**/hibernate.cfg.xml</excludes>
              <outputDirectory>${ptwar.path}</outputDirectory>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <!-- Prepare configuration -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-remote-resources-plugin</artifactId>
        <executions>
          <execution>
            <id>xwiki-configuration-resources</id>
          </execution>
          <execution>
            <id>xwiki-platform-tool-configuration-resources</id>
            <goals>
              <goal>process</goal>
            </goals>
            <configuration>
              <resourceBundles>
                <resourceBundle>org.xwiki.platform:xwiki-platform-tool-configuration-resources:${xwiki.version}</resourceBundle>
              </resourceBundles>
              <properties>
                <xwikiDbConnectionUrl>jdbc:hsqldb:file:${environment.permanentDirectory}/database/xwiki_db;shutdown=true;hsqldb.cache_size=50000;hsqldb.script_format=3;hsqldb.nio_max_size=512;hsqldb.lob_file_scale=16;hsqldb.default_table_type=cached;hsqldb.tx=mvcc</xwikiDbConnectionUrl>
                <xwikiDbConnectionUsername>sa</xwikiDbConnectionUsername>
                <xwikiDbConnectionPassword />
                <xwikiDbConnectionDriverClass>org.hsqldb.jdbcDriver</xwikiDbConnectionDriverClass>
                <xwikiDbDialect>org.hibernate.dialect.HSQLDialect</xwikiDbDialect>
                <xwikiDbHbmXwiki>xwiki.hbm.xml</xwikiDbHbmXwiki>
                <xwikiDbHbmFeeds>feeds.hbm.xml</xwikiDbHbmFeeds>
                <xwikiDbHbmCommonExtraMappings>instance.hbm.xml,mailsender.hbm.xml</xwikiDbHbmCommonExtraMappings>
                <xwikiCfgPlugins>\
  com.xpn.xwiki.monitor.api.MonitorPlugin,\
  com.xpn.xwiki.plugin.skinx.JsSkinExtensionPlugin,\
  com.xpn.xwiki.plugin.skinx.JsSkinFileExtensionPlugin,\
  com.xpn.xwiki.plugin.skinx.JsResourceSkinExtensionPlugin,\
  com.xpn.xwiki.plugin.skinx.CssSkinExtensionPlugin,\
  com.xpn.xwiki.plugin.skinx.CssSkinFileExtensionPlugin,\
  com.xpn.xwiki.plugin.skinx.CssResourceSkinExtensionPlugin,\
  com.xpn.xwiki.plugin.skinx.LinkExtensionPlugin,\
  com.xpn.xwiki.plugin.mail.MailPlugin,\
  com.xpn.xwiki.plugin.packaging.PackagePlugin,\
  com.xpn.xwiki.plugin.svg.SVGPlugin,\
  com.xpn.xwiki.plugin.fileupload.FileUploadPlugin,\
  com.xpn.xwiki.plugin.image.ImagePlugin,\
  com.xpn.xwiki.plugin.zipexplorer.ZipExplorerPlugin,\
  com.xpn.xwiki.plugin.diff.DiffPlugin,\
  com.xpn.xwiki.plugin.rightsmanager.RightsManagerPlugin,\
  com.xpn.xwiki.plugin.jodatime.JodaTimePlugin,\
  com.xpn.xwiki.plugin.mailsender.MailSenderPlugin</xwikiCfgPlugins>
                <xwikiCfgVirtual>0</xwikiCfgVirtual>
                <xwikiCfgVirtualUsepath>0</xwikiCfgVirtualUsepath>
                <xwikiCfgEditCommentMandatory>0</xwikiCfgEditCommentMandatory>
                <xwikiCfgDefaultSkin>phenotips</xwikiCfgDefaultSkin>
                <xwikiCfgDefaultBaseSkin>colibri</xwikiCfgDefaultBaseSkin>
                <xwikiCfgEncoding>UTF-8</xwikiCfgEncoding>
                <xwikiCfgAdditionalProperties>
xwiki.plugin.watchlist.automaticwatch=none
xwiki.authentication.group.allgroupimplicit=1
xwiki.authentication.rightsclass=org.phenotips.security.authorization.ModularRightServiceImpl
xwiki.section.edit=0
xwiki.backlinks=0
xwiki.showviewaction=0
xwiki.defaultweb=data
xwiki.usedefaultweb=1
xwiki.usedefaultaction=0
xwiki.monitor=0
xwiki.store.attachment.hint=file
xwiki.store.attachment.versioning.hint=file
xwiki.store.attachment.recyclebin.hint=file
                </xwikiCfgAdditionalProperties>
                <xwikiPropertiesEnvironmentPermanentDirectory>/var/lib/phenotips/data/</xwikiPropertiesEnvironmentPermanentDirectory>
                <xwikiPropertiesAdditionalProperties>
model.reference.default.space=data
extension.repositories=maven-central:maven:https://nexus.phenotips.org/nexus/content/groups/public/
extension.repositories=maven-phenotips:maven:https://nexus.phenotips.org/nexus/content/repositories/releases/
extension.repositories=phenotips.org:xwiki:https://phenotips.org/rest/
rendering.transformations=macro
activeinstalls.pingURL=https://stats.phenotips.org
activeinstalls.ipFetchURL=https://phenotips.org/get/Stats/Id
                </xwikiPropertiesAdditionalProperties>
              </properties>
            </configuration>
          </execution>
        </executions>
      </plugin>

      <!-- Produce the RPM -->
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>rpm-maven-plugin</artifactId>
        <version>2.1.5</version>
        <extensions>true</extensions>
        <configuration>
          <name>phenotips</name>
          <summary>The PhenoTips server packaged for Tomcat with an embedded HSQLDB database for data storage</summary>
          <description>PhenoTips is an open source software tool for collecting and analyzing phenotypic information for patients with genetic disorders. The user interface closely mirrors clinician workflows so as to facilitate the recording of observations made during the patient encounter. This easy-to-use front-end, compatible with any device that runs a Web browser, is coupled with with a standardized database back-end where phenotypic information is represented using the Human Phenotype Ontology (HPO).

Collected data include demographics, medical history, family history, physical and laboratory measurements, physical findings, and free-form notes.

In addition to data collection, PhenoTips automatically analyzes a wide range of measurements and plots live the corresponding growth curves. It also supports accurate diagnosis based on the entered data, and can suggest additional clinical investigations that can improve the diagnosis.</description>
          <packager>Computational Biology Lab, University of Toronto (devs@phenotips.org)</packager>
          <license>AGPL 3.0</license>
          <group>Applications/Science</group>
          <icon>src/main/resources/phenotips.gif</icon>
          <defaultDirmode>750</defaultDirmode>
          <defaultFilemode>644</defaultFilemode>
          <defaultUsername>tomcat</defaultUsername>
          <defaultGroupname>tomcat</defaultGroupname>
          <requires>
            <require>java &gt;= 0:1.8.0</require>
            <require>tomcat</require>
            <require>unzip</require>
            <require>bc</require>
          </requires>
          <mappings>
            <!-- Copy the main PhenoTips webapp -->
            <mapping>
              <directory>/var/lib/phenotips/webapp</directory>
              <sources>
                <source>
                  <location>${ptwar.path}</location>
                </source>
              </sources>
            </mapping>
            <!-- Copy the custom PhenoTips/XWiki configuration files into the webapp -->
            <mapping>
              <directory>/var/lib/phenotips/webapp/WEB-INF</directory>
              <configuration>noreplace</configuration>
              <directoryIncluded>false</directoryIncluded>
              <sources>
                <source>
                  <location>${project.build.outputDirectory}/</location>
                  <includes>
                    <include>xwiki.cfg</include>
                    <include>xwiki.properties</include>
                    <include>hibernate.cfg.xml</include>
                  </includes>
                </source>
              </sources>
            </mapping>
            <!-- Copy the data dependencies into the "next" directory for optional unpacking when first installing this package -->
            <mapping>
              <directory>/var/lib/phenotips/next</directory>
              <dependency>
                <includes>
                  <include>${project.groupId}:database-zip</include>
                  <include>${project.groupId}:solr-configuration</include>
                </includes>
              </dependency>
            </mapping>
            <!-- Copy the webapp descriptor -->
            <mapping>
              <directory>/etc/tomcat/Catalina/localhost</directory>
              <directoryIncluded>false</directoryIncluded>
              <sources>
                <source>
                  <location>${project.build.outputDirectory}/context.xml</location>
                  <destination>phenotips.xml</destination>
                </source>
              </sources>
            </mapping>
          </mappings>
          <preinstallScriptlet>
            <scriptFile>src/main/scripts/preinstall</scriptFile>
            <fileEncoding>utf-8</fileEncoding>
          </preinstallScriptlet>
          <postinstallScriptlet>
            <scriptFile>src/main/scripts/postinstall</scriptFile>
            <fileEncoding>utf-8</fileEncoding>
          </postinstallScriptlet>
          <postremoveScriptlet>
            <scriptFile>src/main/scripts/postremove</scriptFile>
            <fileEncoding>utf-8</fileEncoding>
          </postremoveScriptlet>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>
