<?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/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>org.pih.openmrs</groupId>
    <artifactId>pwa-apzu-ic3</artifactId>
    <version>2.1.0</version>
    <packaging>pom</packaging>
    <name>openmrs-pwa-apzu-ic3</name>
    <description>APZU IC3 Application</description>
    <url>https://github.com/PIH/openmrs-pwa-apzu-ic3</url>

    <developers>
        <developer>
            <name>Partners In Health</name>
        </developer>
    </developers>

    <licenses>
        <license>
            <name>Mozilla Public License 2.0 with Healthcare Disclaimer</name>
            <url>http://openmrs.org/license</url>
        </license>
    </licenses>

    <scm>
        <connection>scm:git:https://github.com/PIH/openmrs-pwa-apzu-ic3.git</connection>
        <developerConnection>scm:git:https://github.com/PIH/openmrs-pwa-apzu-ic3.git</developerConnection>
        <url>https://github.com/PIH/openmrs-pwa-apzu-ic3</url>
        <tag>2.1.0</tag>
    </scm>

    <properties>
        <reactAppBuildNumber />
    </properties>

    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-release-plugin</artifactId>
                    <version>3.2.0</version>
                    <configuration>
                        <tagNameFormat>@{project.version}</tagNameFormat>
                        <projectVersionPolicyId>SemVerVersionPolicy</projectVersionPolicyId>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-gpg-plugin</artifactId>
                    <version>3.2.7</version>
                </plugin>
            </plugins>
        </pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.sonatype.central</groupId>
                <artifactId>central-publishing-maven-plugin</artifactId>
                <version>0.11.0</version>
                <extensions>true</extensions>
                <configuration>
                    <publishingServerId>sonatype-central</publishingServerId>
                    <autoPublish>true</autoPublish>
                    <waitUntil>published</waitUntil>
                </configuration>
            </plugin>
            <plugin>
                <groupId>com.github.eirslett</groupId>
                <artifactId>frontend-maven-plugin</artifactId>
                <version>1.12.0</version>
                <configuration>
                    <installDirectory>target</installDirectory>
                </configuration>
                <executions>
                    <execution>
                        <id>install node and npm</id>
                        <goals>
                            <goal>install-node-and-npm</goal>
                        </goals>
                        <configuration>
                            <nodeVersion>v14.21.3</nodeVersion>
                        </configuration>
                    </execution>
                    <execution>
                        <id>npm ci</id>
                        <goals>
                            <goal>npm</goal>
                        </goals>
                        <configuration>
                            <arguments>ci</arguments>
                        </configuration>
                    </execution>
                    <execution>
                        <id>npm test</id>
                        <goals>
                            <goal>npm</goal>
                        </goals>
                        <configuration>
                            <arguments>test</arguments>
                            <environmentVariables>
                                <CI>true</CI>
                            </environmentVariables>
                        </configuration>
                    </execution>
                    <execution>
                        <id>npm build</id>
                        <goals>
                            <goal>npm</goal>
                        </goals>
                        <configuration>
                            <arguments>run build</arguments>
                            <environmentVariables>
                                <CI>true</CI>
                                <REACT_APP_SERVER_ADDRESS />
                                <REACT_APP_SERVER_CONTEXT_PATH>/openmrs</REACT_APP_SERVER_CONTEXT_PATH>
                                <REACT_APP_CONTEXT_PATH>/workflow</REACT_APP_CONTEXT_PATH>
                                <REACT_APP_BUILD_NUMBER>${reactAppBuildNumber}</REACT_APP_BUILD_NUMBER>
                            </environmentVariables>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <version>3.3.0</version>
                <configuration>
                    <appendAssemblyId>false</appendAssemblyId>
                    <descriptors>
                        <descriptor>${basedir}/assembly.xml</descriptor>
                        <descriptor>${basedir}/assembly-owa.xml</descriptor>
                    </descriptors>
                </configuration>
                <executions>
                    <execution>
                        <id>make-assembly</id>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>release</id>
            <activation>
                <property>
                    <name>deployRelease</name>
                    <value>true</value>
                </property>
            </activation>
            <build>
                <plugins>
                    <!--
                    To deploy non-snapshot versions to Sonatype, signatures must be generated using gpg.
                    -->
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-gpg-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>sign-artifacts</id>
                                <phase>verify</phase>
                                <goals>
                                    <goal>sign</goal>
                                </goals>
                                <configuration>
                                    <signer>bc</signer>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

    <pluginRepositories>
        <pluginRepository>
            <id>openmrs-repo</id>
            <name>OpenMRS Nexus Repository</name>
            <url>https://openmrs.jfrog.io/artifactory/public</url>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </pluginRepository>
    </pluginRepositories>

    <!-- Not 'central': Maven 3.10+ only sends the 'central' server's credentials to Maven Central -->
    <distributionManagement>
        <snapshotRepository>
            <id>sonatype-central</id>
            <url>https://central.sonatype.com/repository/maven-snapshots/</url>
        </snapshotRepository>
    </distributionManagement>

</project>
