<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>ca.uhn.hapi.fhir</groupId>
        <artifactId>hapi-deployable-pom</artifactId>
        <version>5.4.0</version>
    </parent>

    <!--
    Note: Version of this project and the version of HAPI FHIR are not locked to
    each other. It is fine to bump the point version of this POM without affecting
    HAPI FHIR
    -->
    <artifactId>org.hl7.fhir.core</artifactId>
    <version>5.6.36-SNAPSHOT</version>
    <packaging>pom</packaging>

    <properties>
        <hapi_fhir_version>5.4.0</hapi_fhir_version>
        <validator_test_case_version>1.1.89</validator_test_case_version>
        <junit_jupiter_version>5.7.1</junit_jupiter_version>
        <junit_platform_launcher_version>1.7.1</junit_platform_launcher_version>
        <maven_surefire_version>3.0.0-M5</maven_surefire_version>
        <maven_clean_version>3.1.0</maven_clean_version>
        <jacoco_version>0.8.7</jacoco_version>
        <info_cqframework_version>1.5.1</info_cqframework_version>
        <lombok_version>1.18.22</lombok_version>
        <byte_buddy_version>1.10.21</byte_buddy_version>
    </properties>

    <name>HL7 Core Artifacts</name>

    <organization>
        <name>Health Level 7</name>
        <url>http://hl7.org</url>
    </organization>

    <modules>
        <module>org.hl7.fhir.utilities</module>
        <module>org.hl7.fhir.dstu2</module>
        <module>org.hl7.fhir.dstu2016may</module>
        <module>org.hl7.fhir.dstu3</module>
        <module>org.hl7.fhir.r4</module>
        <module>org.hl7.fhir.r4b</module>
        <module>org.hl7.fhir.r5</module>
        <module>org.hl7.fhir.convertors</module>
        <module>org.hl7.fhir.validation</module>
        <module>org.hl7.fhir.validation.cli</module>
        <!-- The report project exists only to aggregate the test results from the other projects into a central report. -->
        <module>org.hl7.fhir.report</module>
    </modules>

    <repositories>
        <repository>
            <id>jitpack.io</id>
            <url>https://jitpack.io</url>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </repository>
        <repository>
            <id>github-releases</id>
            <url>https://maven.pkg.github.com/FHIR/fhir-test-cases/</url>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </repository>
    </repositories>

    <dependencies>
        <!-- Use logback for tests -->
        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-classic</artifactId>
            <version>1.2.3</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>ca.uhn.hapi.fhir</groupId>
                <artifactId>hapi-fhir-base</artifactId>
                <version>${hapi_fhir_version}</version>
                <exclusions>
                    <exclusion>
                        <groupId>ca.uhn.hapi.fhir</groupId>
                        <artifactId>hapi-fhir-utilities</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>
            <dependency>
                <groupId>ca.uhn.hapi.fhir</groupId>
                <artifactId>org.hl7.fhir.utilities</artifactId>
                <version>${project.version}</version>
            </dependency>
            <dependency>
                <groupId>ca.uhn.hapi.fhir</groupId>
                <artifactId>hapi-fhir-structures-r4</artifactId>
                <version>${hapi_fhir_version}</version>
            </dependency>
            <dependency>
                <groupId>ca.uhn.hapi.fhir</groupId>
                <artifactId>hapi-fhir-validation-resources-r4</artifactId>
                <version>${hapi_fhir_version}</version>
            </dependency>
            <dependency>
                <groupId>com.atlassian.commonmark</groupId>
                <artifactId>commonmark</artifactId>
                <version>0.12.1</version>
            </dependency>
            <dependency>
                <groupId>com.atlassian.commonmark</groupId>
                <artifactId>commonmark-ext-gfm-tables</artifactId>
                <version>0.12.1</version>
            </dependency>
            <dependency>
                <groupId>com.github.rjeschke</groupId>
                <artifactId>txtmark</artifactId>
                <version>0.13</version>
            </dependency>
            <dependency>
                <groupId>org.junit.platform</groupId>
                <artifactId>junit-platform-launcher</artifactId>
                <version>${junit_platform_launcher_version}</version>
                <scope>test</scope>
            </dependency>
            <dependency>
                <groupId>org.junit.jupiter</groupId>
                <artifactId>junit-jupiter-engine</artifactId>
                <version>${junit_jupiter_version}</version>
                <scope>test</scope>
            </dependency>
            <dependency>
                <groupId>org.junit.vintage</groupId>
                <artifactId>junit-vintage-engine</artifactId>
                <version>${junit_jupiter_version}</version>
                <scope>test</scope>
            </dependency>
            <dependency>
                <groupId>net.bytebuddy</groupId>
                <artifactId>byte-buddy</artifactId>
                <version>${byte_buddy_version}</version>
                <scope>test</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-enforcer-plugin</artifactId>
                <configuration>
                    <skip>true</skip>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.0</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                    <forceJavacCompilerUse>false</forceJavacCompilerUse>
                    <encoding>UTF-8</encoding>
                    <!-- Allows running the compiler in a separate process. If false it uses the built in compiler,
                    while if true it will use an executable. -->
                    <fork>true</fork>
                    <meminitial>512m</meminitial>
                    <maxmem>4000m</maxmem>
                    <debug>true</debug>
                </configuration>
                <executions>
                    <!-- Replacing default-compile as it is treated specially by maven -->
                    <execution>
                        <id>default-compile</id>
                        <phase>none</phase>
                    </execution>
                    <!-- Replacing default-testCompile as it is treated specially by maven -->
                    <execution>
                        <id>default-testCompile</id>
                        <phase>none</phase>
                    </execution>
                    <execution>
                        <id>java-compile</id>
                        <phase>compile</phase>
                        <goals> <goal>compile</goal> </goals>
                    </execution>
                    <execution>
                        <id>java-test-compile</id>
                        <phase>test-compile</phase>
                        <goals> <goal>testCompile</goal> </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.basepom.maven</groupId>
                <artifactId>duplicate-finder-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>default</id>
                        <phase>verify</phase>
                        <goals>
                            <goal>check</goal>
                        </goals>
                        <inherited>true</inherited>
                    </execution>
                </executions>
                <configuration>
                    <printEqualFiles>false</printEqualFiles>
                    <failBuildInCaseOfDifferentContentConflict>true</failBuildInCaseOfDifferentContentConflict>
                    <failBuildInCaseOfEqualContentConflict>true</failBuildInCaseOfEqualContentConflict>
                    <failBuildInCaseOfConflict>true</failBuildInCaseOfConflict>
                    <checkCompileClasspath>true</checkCompileClasspath>
                    <checkRuntimeClasspath>false</checkRuntimeClasspath>
                    <checkTestClasspath>false</checkTestClasspath>
                    <skip>false</skip>
                    <quiet>false</quiet>
                    <preferLocal>true</preferLocal>
                    <useResultFile>true</useResultFile>
                    <resultFileMinClasspathCount>2</resultFileMinClasspathCount>
                    <resultFile>${project.build.directory}/duplicate-finder-result.xml</resultFile>
                    <ignoredDependencies>
                        <dependency>
                            <groupId>javax.el</groupId>
                            <artifactId>javax.el-api</artifactId>
                        </dependency>
                        <dependency>
                            <groupId>javax.mail</groupId>
                            <artifactId>javax.mail-api</artifactId>
                        </dependency>
                        <dependency>
                            <groupId>javax.activation</groupId>
                            <artifactId>javax.activation-api</artifactId>
                        </dependency>
                        <dependency>
                            <groupId>com.helger</groupId>
                            <artifactId>ph-schematron</artifactId>
                        </dependency>
                        <dependency>
                            <groupId>commons-logging</groupId>
                            <artifactId>commons-logging</artifactId>
                        </dependency>
                        <dependency>
                            <groupId>org.jscience</groupId>
                            <artifactId>jscience</artifactId>
                        </dependency>
                        <dependency>
                            <groupId>org.springframework</groupId>
                            <artifactId>spring-jcl</artifactId>
                        </dependency>
                        <dependency>
                            <groupId>org.springframework</groupId>
                            <artifactId>spring-jcl</artifactId>
                        </dependency>
                        <dependency>
                            <groupId>com.google.code.findbugs</groupId>
                            <artifactId>annotations</artifactId>
                        </dependency>
                        <dependency>
                            <groupId>org.apache.derby</groupId>
                            <artifactId>derbyclient</artifactId>
                        </dependency>
                        <dependency>
                            <groupId>org.apache.derby</groupId>
                            <artifactId>derbynet</artifactId>
                        </dependency>
                        <dependency>
                            <groupId>org.apache.derby</groupId>
                            <artifactId>derbyclient</artifactId>
                        </dependency>
                        <dependency>
                            <groupId>org.apache.poi</groupId>
                            <artifactId>ooxml-schemas</artifactId>
                        </dependency>
                    </ignoredDependencies>
                    <ignoredResourcePatterns>
                        <ignoredResourcePattern>changelog.txt</ignoredResourcePattern>
                        <ignoredResource>javac.bat</ignoredResource>
                        <ignoredResource>javac.sh</ignoredResource>
                        <ignoredResource>about.html</ignoredResource>
                        <ignoredResource>changelog.xml</ignoredResource>
                    </ignoredResourcePatterns>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.felix</groupId>
                <artifactId>maven-bundle-plugin</artifactId>
                <extensions>true</extensions>
                <configuration>
                    <instructions>
                        <_nouses>true</_nouses>
                        <_removeheaders>Built-By, Include-Resource, Private-Package, Require-Capability</_removeheaders>
                        <!-- No need to disable normal OSGi class loading
						<Fragment-Host>
							ca.uhn.hapi.fhir.hapi-fhir-base
						</Fragment-Host>
						-->
                    </instructions>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>license-maven-plugin</artifactId>
                <configuration>
                    <skipUpdateLicense>true</skipUpdateLicense>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <version>${jacoco_version}</version>
                <configuration>
                    <excludes>
                        <!-- These files blow away the JVM limit on file size. Until we refactor, we need to ignore or
                             Jacoco complains and won't run the validator tests. -->
                        <exclude>org/hl7/fhir/r5/formats/JsonParser</exclude>
                        <exclude>org/hl7/fhir/r5/formats/XmlParser</exclude>
                        <exclude>org/hl7/fhir/r4b/formats/JsonParser</exclude>
                        <exclude>org/hl7/fhir/r4b/formats/XmlParser</exclude>
                        <exclude>org/hl7/fhir/r4/formats/JsonParser</exclude>
                        <exclude>org/hl7/fhir/r4/formats/XmlParser</exclude>
                        <exclude>org/hl7/fhir/r4/**/*</exclude>
                        <exclude>org/hl7/fhir/dstu3/**/*</exclude>
                        <exclude>org/hl7/fhir/dstu2/**/*</exclude>
                        <exclude>org/hl7/fhir/dstu2016may/**/*</exclude>
                    </excludes>
                </configuration>
                <executions>
                    <execution>
                        <id>jacoco-initialize</id>
                        <goals>
                            <goal>prepare-agent</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>report</id>
                        <phase>package</phase>
                        <goals>
                            <goal>report</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-deploy-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>surefire-java-8</id>
            <activation>
                <jdk>(,1.8]</jdk>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <version>${maven_surefire_version}</version>
                        <configuration>
                            <forkCount>1</forkCount>
                            <reuseForks>true</reuseForks>
                            <parallel>classes</parallel>
                            <trimStackTrace>false</trimStackTrace>
                            <testFailureIgnore>false</testFailureIgnore>
                            <!-- We need to include the ${argLine} here so the Jacoco test arguments are included in the
                             Surefire testing run. This may appear as an error in some IDEs, but it will run regardless.
                            -->
                            <!-- UseConcMarkSweepGC is required for Java 8 builds, or else garbage collection will fail
                            for forked tests -->
                            <argLine>${argLine} -Xmx4096m -XX:+UseConcMarkSweepGC</argLine>
                            <redirectTestOutputToFile>false</redirectTestOutputToFile>
                            <excludes>
                                <exclude>org/hl7/fhir/validation/cli/**</exclude>
                            </excludes>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>surefire-java-9-plus</id>
            <activation>
                <jdk>[9,)</jdk>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <version>${maven_surefire_version}</version>
                        <configuration>
                            <forkCount>1</forkCount>
                            <reuseForks>true</reuseForks>
                            <parallel>classes</parallel>
                            <trimStackTrace>false</trimStackTrace>
                            <testFailureIgnore>false</testFailureIgnore>
                            <!-- We need to include the ${argLine} here so the Jacoco test arguments are included in the
                             Surefire testing run. This may appear as an error in some IDEs, but it will run regardless.
                            -->
                            <argLine>${argLine} -Xmx4096m</argLine>
                            <systemPropertyVariables>
                                <java.locale.providers>COMPAT</java.locale.providers>
                            </systemPropertyVariables>
                            <redirectTestOutputToFile>false</redirectTestOutputToFile>
                            <excludes>
                                <exclude>org/hl7/fhir/validation/cli/**</exclude>
                            </excludes>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>github-repo</id>
            <activation>
                <activeByDefault>false</activeByDefault>
                <property>
                    <name>deployToGitHub</name>
                </property>
            </activation>
            <distributionManagement>
                <snapshotRepository>
                    <id>github</id>
                    <url>https://maven.pkg.github.com/hapifhir/org.hl7.fhir.core</url>
                </snapshotRepository>
                <repository>
                    <id>github</id>
                    <url>https://maven.pkg.github.com/hapifhir/org.hl7.fhir.core</url>
                </repository>
            </distributionManagement>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-gpg-plugin</artifactId>
                        <version>1.6</version>
                        <executions>
                            <execution>
                                <id>sign-artifacts</id>
                                <phase>verify</phase>
                                <goals>
                                    <goal>sign</goal>
                                </goals>
                                <configuration>
					<keyname>${gpg.keyname}</keyname>
					<passphraseServerId>${gpg.keyname}</passphraseServerId>
					<gpgArguments>
					    <arg>--pinentry-mode</arg>
					    <arg>loopback</arg>
					</gpgArguments>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>ossrh-repo</id>
            <activation>
                <activeByDefault>false</activeByDefault>
                <property>
                    <name>deployToSonatype</name>
                </property>
            </activation>
            <distributionManagement>
                <snapshotRepository>
                    <id>ossrh</id>
                    <url>https://oss.sonatype.org/content/repositories/snapshots</url>
                </snapshotRepository>
                <repository>
                    <id>ossrh</id>
                    <url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
                </repository>
            </distributionManagement>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.sonatype.plugins</groupId>
                        <artifactId>nexus-staging-maven-plugin</artifactId>
                        <version>1.6.8</version>
                        <extensions>true</extensions>
                        <configuration>
                            <serverId>ossrh</serverId>
                            <nexusUrl>https://oss.sonatype.org/</nexusUrl>
                            <autoReleaseAfterClose>true</autoReleaseAfterClose>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-gpg-plugin</artifactId>
                        <version>1.6</version>
                        <executions>
                            <execution>
                                <id>sign-artifacts</id>
                                <phase>verify</phase>
                                <goals>
                                    <goal>sign</goal>
                                </goals>
                                <configuration>
					<keyname>${gpg.keyname}</keyname>
					<passphraseServerId>${gpg.keyname}</passphraseServerId>
					<gpgArguments>
					    <arg>--pinentry-mode</arg>
					    <arg>loopback</arg>
					</gpgArguments>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>cleanTxCache</id>
            <activation>
                <activeByDefault>false</activeByDefault>
                <property>
                    <name>fhir.txcache.clean</name>
                    <value>true</value>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <artifactId>maven-clean-plugin</artifactId>
                        <version>${maven_clean_version}</version>
                        <configuration>
                            <filesets>
                                <fileset>
                                    <directory>src/test/resources/txCache</directory>
                                    <includes>
                                        <include>**/*</include>
                                    </includes>
                                    <followSymlinks>false</followSymlinks>
                                </fileset>
                            </filesets>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>