<?xml version="1.0" encoding="UTF-8"?>
<!--
  ~ Copyright 2016 chronicle.software
  ~
  ~ Licensed under the Apache License, Version 2.0 (the "License");
  ~ you may not use this file except in compliance with the License.
  ~ You may obtain a copy of the License at
  ~
  ~     http://www.apache.org/licenses/LICENSE-2.0
  ~
  ~ Unless required by applicable law or agreed to in writing, software
  ~ distributed under the License is distributed on an "AS IS" BASIS,
  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  ~ See the License for the specific language governing permissions and
  ~ limitations under the License.
  -->
<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>net.openhft</groupId>
        <artifactId>java-parent-pom</artifactId>
        <version>1.24.0</version>
        <relativePath></relativePath>
    </parent>
    <artifactId>chronicle-core</artifactId>
    <version>2.25ea0</version>
    <packaging>bundle</packaging>
    <name>OpenHFT/Chronicle Core</name>
    <description>Chronicle-Core</description>

    <scm>
        <connection>scm:git:git@github.com:OpenHFT/Chronicle-Core.git</connection>
        <developerConnection>scm:git:git@github.com:OpenHFT/Chronicle-Core.git</developerConnection>
        <tag>chronicle-core-2.25ea0</tag>
        <url>scm:git:git@github.com:OpenHFT/Chronicle-Core.git</url>
    </scm>
    <properties>
        <zero.cost.assertions>disabled</zero.cost.assertions>
        <sonar.organization>openhft</sonar.organization>
        <sonar.host.url>https://sonarcloud.io</sonar.host.url>
        <mockito.version>4.9.0</mockito.version>
    </properties>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>net.openhft</groupId>
                <artifactId>third-party-bom</artifactId>
                <version>3.24.0</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>

            <dependency>
                <groupId>net.openhft</groupId>
                <artifactId>chronicle-bom</artifactId>
                <version>2.25ea0</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <dependencies>

        <dependency>
            <groupId>net.openhft</groupId>
            <artifactId>assertions-${zero.cost.assertions}</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>net.openhft</groupId>
            <artifactId>affinity</artifactId>
            <optional>true</optional>
        </dependency>

        <dependency>
            <groupId>net.openhft</groupId>
            <artifactId>posix</artifactId>
        </dependency>

        <dependency>
            <groupId>net.openhft</groupId>
            <artifactId>chronicle-analytics</artifactId>
        </dependency>

        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
        </dependency>

        <dependency>
            <groupId>org.jetbrains</groupId>
            <artifactId>annotations</artifactId>
        </dependency>

        <!-- test dependencies -->

        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-api</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-params</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>net.openhft</groupId>
            <artifactId>chronicle-test-framework</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-simple</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>com.squareup.okhttp3</groupId>
            <artifactId>mockwebserver</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-core</artifactId>
            <version>${mockito.version}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-junit-jupiter</artifactId>
            <version>${mockito.version}</version>
            <scope>test</scope>
        </dependency>

    </dependencies>

    <repositories>
        <repository>
            <releases>
                <enabled>false</enabled>
                <updatePolicy>never</updatePolicy>
            </releases>
            <snapshots>
                <enabled>true</enabled>
                <updatePolicy>always</updatePolicy>
            </snapshots>
            <id>Snapshot Repository</id>
            <name>Snapshot Repository</name>
            <url>https://oss.sonatype.org/content/repositories/snapshots</url>
        </repository>
        <repository>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
            <id>chronicle-enterprise-snapshots</id>
            <name>Snapshot Repository</name>
            <url>https://nexus.chronicle.software/content/repositories/snapshots</url>
        </repository>
        <repository>
            <releases>
                <enabled>true</enabled>
            </releases>
            <id>chronicle-enterprise-release</id>
            <url>https://nexus.chronicle.software/content/repositories/releases</url>
        </repository>
    </repositories>

    <build>
        <plugins>
            <plugin>
                <groupId>com.github.ekryd.sortpom</groupId>
                <artifactId>sortpom-maven-plugin</artifactId>
                <version>3.0.1</version>
                <configuration>
                    <nrOfIndentSpace>4</nrOfIndentSpace>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>sort</goal>
                        </goals>
                        <phase>verify</phase>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>net.openhft</groupId>
                <artifactId>binary-compatibility-enforcer-plugin</artifactId>
                <executions>
                    <execution>
                        <goals>
                            <goal>enforcer</goal>
                        </goals>
                        <phase>verify</phase>
                        <configuration>
                            <referenceVersion>2.24ea0</referenceVersion>
                            <artifactsURI>https://teamcity.chronicle.software/repository/download</artifactsURI>
                            <binaryCompatibilityPercentageRequired>90.5</binaryCompatibilityPercentageRequired>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-scm-publish-plugin</artifactId>
                <configuration>
                    <checkoutDirectory>${project.build.directory}/scmpublish/javadoc</checkoutDirectory>
                    <checkinComment>Publishing javadoc for ${project.artifactId}:${project.version}</checkinComment>
                    <content>${project.reporting.outputDirectory}</content>
                    <skipDeletedFiles>true</skipDeletedFiles>
                    <pubScmUrl>scm:git:git@github.com:OpenHFT/Chronicle-Core</pubScmUrl>
                    <scmBranch>gh-pages</scmBranch>
                </configuration>
            </plugin>

            <!-- used to allow getClass().getPackage().getImplementationVersion() -->

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <compilerArgument>-Xlint:deprecation</compilerArgument>
                </configuration>
                <!-- build a multi-release jar -->
                <executions>
                    <execution>
                        <id>java8</id>
                        <goals>
                            <goal>compile</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>java11</id>
                        <goals>
                            <goal>compile</goal>
                        </goals>
                        <configuration>
                            <compileSourceRoots>${project.basedir}/src/main/java11</compileSourceRoots>
                            <outputDirectory>${project.build.outputDirectory}/META-INF/versions/11</outputDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <configuration>
                    <archive>
                        <manifestEntries>
                            <Multi-Release>true</Multi-Release>
                            <Automatic-Module-Name>chronicle.core</Automatic-Module-Name>
                        </manifestEntries>
                    </archive>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>test-jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <!--
                generate maven dependencies versions file that can be used later
                to install the right bundle in test phase.

                The file is:

                    target/classes/META-INF/maven/dependencies.properties
            -->
            <plugin>
                <groupId>org.apache.servicemix.tooling</groupId>
                <artifactId>depends-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>generate-depends-file</id>
                        <goals>
                            <goal>generate-depends-file</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <!-- This will give each test class its own JVM so you can safely set
                         e.g. system properties per test class but not method -->
                    <forkCount>4</forkCount>
                    <reuseForks>true</reuseForks>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.felix</groupId>
                <artifactId>maven-bundle-plugin</artifactId>
                <extensions>true</extensions>
                <configuration>
                    <instructions>
                        <Bundle-SymbolicName>${project.groupId}.${project.artifactId}</Bundle-SymbolicName>
                        <Bundle-Name>OpenHFT :: ${project.artifactId}</Bundle-Name>
                        <Bundle-Version>${project.version}</Bundle-Version>
                        <Export-Package>net.openhft.chronicle.core.*;-noimport:=true</Export-Package>
                        <Import-Package>software.chronicle.enterprise.core;resolution:=optional,
                            *</Import-Package>
                    </instructions>
                </configuration>
                <executions>
                    <!--
                      This execution makes sure that the manifest is available
                      when the tests are executed
                    -->
                    <execution>
                        <goals>
                            <goal>manifest</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <!--        Enable once https://github.com/osundblad/intellij-annotations-instrumenter-maven-plugin/issues/53  has been fixed
                        <plugin>
                            <groupId>se.eris</groupId>
                            <artifactId>notnull-instrumenter-maven-plugin</artifactId>
                            <executions>
                                <execution>
                                    <goals>
                                        <goal>instrument</goal>
                                        <goal>tests-instrument</goal>
                                    </goals>
                                </execution>
                            </executions>
                            <dependencies>
                                <dependency>
                                    <groupId>org.jetbrains</groupId>
                                    <artifactId>annotations</artifactId>
                                    <version>19.0.0</version>
                                </dependency>
                            </dependencies>
                        </plugin>-->

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-install-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <configuration>
                    <source>8</source>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>assertions</id>
            <properties>
                <zero.cost.assertions>enabled</zero.cost.assertions>
            </properties>
        </profile>
        <profile>
            <id>java11</id>
            <activation>
                <jdk>[11,</jdk>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-compiler-plugin</artifactId>
                        <configuration>
                            <source>11</source>
                            <target>11</target>
                            <compilerArgs>
                                <arg>--add-exports=java.base/jdk.internal.ref=ALL-UNNAMED</arg>
                                <arg>--add-exports=java.base/sun.nio.ch=ALL-UNNAMED</arg>
                            </compilerArgs>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>sonar</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.sonarsource.scanner.maven</groupId>
                        <artifactId>sonar-maven-plugin</artifactId>
                    </plugin>
                    <plugin>
                        <groupId>org.jacoco</groupId>
                        <artifactId>jacoco-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <goals>
                                    <goal>prepare-agent</goal>
                                </goals>
                            </execution>
                            <execution>
                                <id>report</id>
                                <goals>
                                    <goal>report</goal>
                                </goals>
                                <phase>prepare-package</phase>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>run-benchmarks</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-invoker-plugin</artifactId>
                        <configuration>
                            <pom>benchmarks/pom.xml</pom>
                            <goals>clean,test</goals>
                            <profiles>
                                <profile>run-benchmarks</profile>
                            </profiles>
                            <properties>
                                <core.version>${project.version}</core.version>
                                <skip.binary>true</skip.binary>
                            </properties>
                            <streamLogs>true</streamLogs>
                        </configuration>
                        <executions>
                            <execution>
                                <goals>
                                    <goal>run</goal>
                                </goals>
                                <phase>test</phase>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>

    </profiles>

</project>
