<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  ~     ___                  _   ____  ____
  ~    / _ \ _   _  ___  ___| |_|  _ \| __ )
  ~   | | | | | | |/ _ \/ __| __| | | |  _ \
  ~   | |_| | |_| |  __/\__ \ |_| |_| | |_) |
  ~    \__\_\\__,_|\___||___/\__|____/|____/
  ~
  ~  Copyright (c) 2014-2019 Appsicle
  ~  Copyright (c) 2019-2020 QuestDB
  ~
  ~  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:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <name>QuestDB core</name>
    <description>QuestDB is high performance SQL time series database</description>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <outputPath>target</outputPath>
        <nodejs.npm.cmd>npm</nodejs.npm.cmd>
        <nodejs.version>v12.16.2</nodejs.version>
        <runtime.assembly>none</runtime.assembly>
        <javac.target>11</javac.target>
        <argLine>-Dfile.encoding=UTF-8</argLine>
    </properties>

    <version>6.0.1</version>
    <groupId>org.questdb</groupId>
    <artifactId>questdb-jdk8</artifactId>
    <packaging>jar</packaging>

    <url>https://questdb.io/</url>
    <licenses>
        <license>
            <name>Apache 2.0</name>
            <url>https://www.apache.org/licenses/LICENSE-2.0.txt</url>
            <distribution>repo</distribution>
        </license>
    </licenses>

    <developers>
        <developer>
            <name>QuestDB Team</name>
            <email>hello@questdb.io</email>
        </developer>
    </developers>

    <scm>
        <url>scm:git:https://github.com/questdb/questdb.git</url>
        <connection>scm:git:https://github.com/questdb/questdb.git</connection>
        <tag>HEAD</tag>
    </scm>

    <distributionManagement>
        <snapshotRepository>
            <id>central</id>
            <url>https://oss.sonatype.org/content/repositories/snapshots</url>
        </snapshotRepository>
        <repository>
            <id>central</id>
            <url>https://oss.sonatype.org/service/local/staging/deploy/maven2</url>
        </repository>
    </distributionManagement>

    <build>
        <directory>${outputPath}</directory>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.1</version>
                <configuration>
                    <compilerArgs>
                        <arg>${compilerArg1}</arg>
                        <arg>${compilerArg2}</arg>
                    </compilerArgs>
                    <fork>true</fork>
                    <source>${javac.compile.source}</source>
                    <target>${javac.compile.target}</target>
                    <testExcludes>
                        <exclude>${excludePattern1}</exclude>
                    </testExcludes>
                    <excludes>
                        <exclude>${excludeTestPattern1}</exclude>
                    </excludes>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>3.0.1</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>test-jar</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <archive>
                        <manifest>
                            <mainClass>io.questdb.ServerMain</mainClass>
                            <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
                        </manifest>
                        <manifestEntries>
                            <Build-Commit-Hash>${buildNumber}</Build-Commit-Hash>
                        </manifestEntries>
                    </archive>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-enforcer-plugin</artifactId>
                <version>3.0.0-M3</version>
                <executions>
                    <execution>
                        <id>enforce-versions</id>
                        <goals>
                            <goal>enforce</goal>
                        </goals>
                        <configuration>
                            <rules>
                                <requireMavenVersion>
                                    <version>3.0.0</version>
                                </requireMavenVersion>
                                <requireJavaVersion>
                                    <version>${java.enforce.version}</version>
                                </requireJavaVersion>
                            </rules>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <!-- remove web console package on "clean" -->
            <plugin>
                <artifactId>maven-clean-plugin</artifactId>
                <version>3.1.0</version>
                <configuration>
                    <filesets>
                        <fileset>
                            <directory>src/main/resources/io/questdb/site/</directory>
                            <includes>
                                <include>public.zip</include>
                            </includes>
                            <followSymlinks>false</followSymlinks>
                        </fileset>
                    </filesets>
                </configuration>
            </plugin>
            <!-- disable stock deploy plugin -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-deploy-plugin</artifactId>
                <version>2.8.2</version>
                <configuration>
                    <skip>true</skip>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>buildnumber-maven-plugin</artifactId>
                <version>1.4</version>
                <executions>
                    <execution>
                        <phase>validate</phase>
                        <goals>
                            <goal>create</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <doCheck>false</doCheck>
                    <doUpdate>false</doUpdate>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.17</version>
                <configuration>
                    <properties>
                        <property>
                            <name>listener</name>
                            <value>io.questdb.TestListener</value>
                        </property>
                    </properties>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>maven-central-release</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-source-plugin</artifactId>
                        <version>3.0.1</version>
                        <executions>
                            <execution>
                                <id>attach-sources</id>
                                <goals>
                                    <goal>jar</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-javadoc-plugin</artifactId>
                        <version>3.2.0</version>
                        <executions>
                            <execution>
                                <id>attach-javadocs</id>
                                <goals>
                                    <goal>jar</goal>
                                </goals>
                            </execution>
                        </executions>
                        <configuration>
                            <additionalJOptions>
                                <additionalJOption>${compilerArg1}</additionalJOption>
                                <additionalJOption>${compilerArg2}</additionalJOption>
                            </additionalJOptions>
                            <sourceFileExcludes>
                                <sourceFileExclude>${excludePattern1}</sourceFileExclude>
                            </sourceFileExcludes>
                        </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>
                            </execution>
                        </executions>
                        <configuration>
                            <executable>gpg</executable>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>org.sonatype.plugins</groupId>
                        <artifactId>nexus-staging-maven-plugin</artifactId>
                        <version>1.6.3</version>
                        <executions>
                            <execution>
                                <id>default-deploy</id>
                                <phase>deploy</phase>
                                <goals>
                                    <goal>deploy</goal>
                                </goals>
                            </execution>
                        </executions>
                        <configuration>
                            <serverId>central</serverId>
                            <nexusUrl>https://oss.sonatype.org</nexusUrl>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>use-built-in-nodejs</id>
            <properties>
                <nodejs.npm.cmd>${project.basedir}/node/npm</nodejs.npm.cmd>
            </properties>
            <build>
                <plugins>
                    <plugin>
                        <groupId>com.github.eirslett</groupId>
                        <artifactId>frontend-maven-plugin</artifactId>
                        <version>1.9.1</version>
                        <executions>
                            <execution>
                                <id>install node and npm</id>
                                <goals>
                                    <goal>install-node-and-npm</goal>
                                </goals>
                                <phase>initialize</phase>
                            </execution>
                        </executions>
                        <configuration>
                            <nodeVersion>${nodejs.version}</nodeVersion>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>build-web-console</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>exec-maven-plugin</artifactId>
                        <version>1.6.0</version>
                        <configuration>
                            <longModulepath>false</longModulepath>
                        </configuration>
                        <executions>
                            <execution>
                                <id>npm-install</id>
                                <goals>
                                    <goal>exec</goal>
                                </goals>
                                <phase>generate-sources</phase>
                                <configuration>
                                    <executable>${nodejs.npm.cmd}</executable>
                                    <arguments>
                                        <argument>install</argument>
                                        <argument>--no-fund</argument>
                                        <argument>--scripts-prepend-node-path=auto</argument>
                                    </arguments>
                                    <workingDirectory>../ui</workingDirectory>
                                </configuration>
                            </execution>
                            <execution>
                                <id>npm-run-build</id>
                                <goals>
                                    <goal>exec</goal>
                                </goals>
                                <phase>generate-sources</phase>
                                <configuration>
                                    <executable>${nodejs.npm.cmd}</executable>
                                    <arguments>
                                        <argument>run</argument>
                                        <argument>build</argument>
                                        <argument>--scripts-prepend-node-path=auto</argument>
                                    </arguments>
                                    <workingDirectory>../ui</workingDirectory>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <profile>
            <id>build-binaries</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>exec-maven-plugin</artifactId>
                        <version>1.6.0</version>
                        <configuration>
                            <longModulepath>false</longModulepath>
                        </configuration>
                        <executions>
                            <execution>
                                <id>jlink</id>
                                <goals>
                                    <goal>exec</goal>
                                </goals>
                                <phase>package</phase>
                                <configuration>
                                    <executable>${java.home}/bin/jlink</executable>
                                    <arguments>
                                        <argument>--module-path</argument>
                                        <argument>${project.build.directory}/questdb-${project.version}.jar</argument>
                                        <argument>--add-modules</argument>
                                        <argument>io.questdb,jdk.crypto.ec</argument>
                                        <argument>--output</argument>
                                        <argument>${project.build.directory}/runtime</argument>
                                        <argument>--no-header-files</argument>
                                        <argument>--no-man-pages</argument>
                                        <argument>--compress=2</argument>
                                        <argument>--strip-debug</argument>
                                        <argument>--vm=server</argument>
                                    </arguments>
                                    <workingDirectory>../core</workingDirectory>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-assembly-plugin</artifactId>
                        <version>3.0.0</version>
                        <configuration>
                            <tarLongFileMode>posix</tarLongFileMode>
                        </configuration>
                        <executions>
                            <execution>
                                <id>create-binary</id>
                                <phase>package</phase>
                                <goals>
                                    <goal>single</goal>
                                </goals>
                                <configuration>
                                    <descriptors>
                                        <descriptor>src/main/assembly/binaries.xml</descriptor>
                                    </descriptors>
                                    <finalName>questdb</finalName>
                                </configuration>
                            </execution>
                            <execution>
                                <id>create-runtime</id>
                                <phase>package</phase>
                                <goals>
                                    <goal>single</goal>
                                </goals>
                                <configuration>
                                    <descriptors>
                                        <descriptor>${runtime.assembly}</descriptor>
                                    </descriptors>
                                    <finalName>questdb</finalName>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>platform-windows-amd64</id>
            <activation>
                <os>
                    <family>windows</family>
                </os>
            </activation>
            <properties>
                <archive.name>${project.version}-rt-windows-amd64</archive.name>
                <runtime.name>questdb-${project.version}-rt-windows-amd64</runtime.name>
                <runtime.assembly>src/main/assembly/windows-runtime.xml</runtime.assembly>
                <nodejs.npm.cmd>${project.basedir}/node/npm.cmd</nodejs.npm.cmd>
            </properties>
        </profile>
        <profile>
            <id>platform-linux-amd64</id>
            <activation>
                <os>
                    <family>unix</family>
                    <arch>amd64</arch>
                </os>
            </activation>
            <properties>
                <archive.name>${project.version}-rt-linux-amd64</archive.name>
                <runtime.name>questdb-${project.version}-rt-linux-amd64</runtime.name>
                <runtime.assembly>src/main/assembly/linux-runtime.xml</runtime.assembly>
            </properties>
        </profile>
        <profile>
            <id>platform-freebsd-amd64</id>
            <activation>
                <os>
                    <family>FreeBSD</family>
                    <arch>amd64</arch>
                </os>
            </activation>
            <properties>
                <archive.name>${project.version}-rt-freebsd-amd64</archive.name>
                <runtime.name>questdb-${project.version}-rt-freebsd-amd64</runtime.name>
                <runtime.assembly>src/main/assembly/linux-runtime.xml</runtime.assembly>
            </properties>
        </profile>
        <profile>
            <id>platform-linux-aarch64</id>
            <activation>
                <os>
                    <family>unix</family>
                    <arch>aarch64</arch>
                </os>
            </activation>
            <properties>
                <archive.name>${project.version}-rt-linux-aarch64</archive.name>
                <runtime.name>questdb-${project.version}-rt-linux-aarch64</runtime.name>
                <runtime.assembly>src/main/assembly/linux-runtime.xml</runtime.assembly>
            </properties>
        </profile>
        <profile>
            <id>platform-osx-amd64</id>
            <activation>
                <os>
                    <family>Mac</family>
                </os>
            </activation>
            <properties>
                <archive.name>${project.version}-rt-osx-amd64</archive.name>
                <runtime.name>questdb-${project.version}-rt-osx-amd64</runtime.name>
                <runtime.assembly>src/main/assembly/linux-runtime.xml</runtime.assembly>
            </properties>
        </profile>
		<profile>
			<id>jacoco</id>
			<build>
				<plugins>
					<plugin>
						<groupId>org.jacoco</groupId>
						<artifactId>jacoco-maven-plugin</artifactId>
						<version>0.8.7</version>
						<executions>
							<execution>
								<id>default-prepare-agent</id>
								<goals>
									<goal>prepare-agent</goal>
								</goals>
							</execution>
							<execution>
								<id>default-report</id>
								<phase>test</phase>
								<goals>
									<goal>report</goal>
								</goals>
							</execution>
						</executions>
					</plugin>
				</plugins>
			</build>
		</profile>
        <profile>
            <id>java8</id>
            <properties>
                <jdk.version>8</jdk.version>
                <java.enforce.version>1.8.0_242</java.enforce.version>
                <questdb.artifactid>questdb-jdk8</questdb.artifactid>
                <compilerArg1></compilerArg1>
                <compilerArg2></compilerArg2>
                <excludePattern1>module-info.java</excludePattern1>
                <excludeTestPattern1>module-info.java</excludeTestPattern1>
                <javac.compile.source>1.8</javac.compile.source>
                <javac.compile.target>1.8</javac.compile.target>
            </properties>
            <activation>
                <jdk>(,1.8]</jdk>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>com.igormaznitsa</groupId>
                        <artifactId>jcp</artifactId>
                        <version>7.0.4</version>
                        <executions>
                            <!-- make preprocessing of sources -->
                            <execution>
                                <id>preprocess-sources</id>
                                <goals>
                                    <goal>preprocess</goal>
                                </goals>
                            </execution>
                        </executions>
                        <configuration>
                            <vars>
                                <jdk.version>${jdk.version}</jdk.version>
                            </vars>
                            <excludeExtensions>
                                <ext>MD</ext>
                                <ext>md</ext>
                                <ext>xml</ext>
                            </excludeExtensions>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
            <dependencies>
                <dependency>
                    <groupId>org.jetbrains</groupId>
                    <artifactId>annotations</artifactId>
                    <version>16.0.2</version>
                    <scope>provided</scope>
                </dependency>
            </dependencies>
        </profile>
        <profile>
            <id>java11+</id>
            <properties>
                <jdk.version>11</jdk.version>
                <java.enforce.version>11</java.enforce.version>
                <questdb.artifactid>questdb</questdb.artifactid>
                <compilerArg1>--add-exports</compilerArg1>
                <compilerArg2>java.base/jdk.internal.math=io.questdb</compilerArg2>
                <excludePattern1>nothing-to-exclude-dummy-value-include-all-java11plus</excludePattern1>
                <excludeTestPattern1>nothing-to-exclude-dummy-value-include-all-java11plus</excludeTestPattern1>
                <javac.compile.source>${javac.target}</javac.compile.source>
                <javac.compile.target>${javac.target}</javac.compile.target>
            </properties>
            <activation>
                <jdk>(1.8,)</jdk>
            </activation>
            <dependencies>
                <dependency>
                    <groupId>org.jetbrains</groupId>
                    <artifactId>annotations</artifactId>
                    <version>17.0.0</version>
                    <scope>provided</scope>
                </dependency>
            </dependencies>
        </profile>
    </profiles>

    <dependencies>
        <!-- test dependencies -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.13.1</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.postgresql</groupId>
            <artifactId>postgresql</artifactId>
            <version>42.2.12</version>
            <scope>test</scope>
        </dependency>
    </dependencies>
</project>
