<?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/xsd/maven-4.0.0.xsd">
    <parent>
        <groupId>com.github.database-rider</groupId>
        <artifactId>rider-parent</artifactId>
        <version>1.41.0</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>

    <artifactId>rider-core</artifactId>
    <properties>
        <!-- must be overriden when releasing a new version with release profile -->
        <docs.outputdir>docs/latest</docs.outputdir>
        <src.dir>src/main/java</src.dir>
        <test.dir>src/test/java</test.dir>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.dbunit</groupId>
            <artifactId>dbunit</artifactId>
            <exclusions>
            	<exclusion>
            		<groupId>postgresql</groupId>
            		<artifactId>postgresql</artifactId>
            	</exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.yaml</groupId>
            <artifactId>snakeyaml</artifactId>
        </dependency>

        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
        </dependency>

        <dependency>
            <groupId>it.unibo.tuprolog</groupId>
            <artifactId>solve-classic-jvm</artifactId>
        </dependency>

        <dependency>
            <groupId>it.unibo.tuprolog</groupId>
            <artifactId>parser-theory-jvm</artifactId>
        </dependency>


        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core</artifactId>
            <version>4.3.5.Final</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.eclipse.persistence</groupId>
            <artifactId>eclipselink</artifactId>
            <version>2.5.2</version>
            <scope>provided</scope>
        </dependency>
        <!-- bdd tests -->
        <!--tag::cucumber-deps[]-->
        <dependency> <!--1-->
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-junit</artifactId>
            <version>1.2.5</version>
            <scope>test</scope>
        </dependency>
        <dependency> <!--1-->
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-java</artifactId>
            <version>1.2.4</version>
            <scope>test</scope>
        </dependency>
        <!--end::cucumber-deps[]-->
        <dependency>
            <groupId>org.codehaus.groovy</groupId>
            <artifactId>groovy-all</artifactId>
            <version>2.4.21</version>
            <scope>test</scope>
        </dependency>
        <!-- export datasets to excel -->
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi-ooxml</artifactId>
            <scope>compile</scope>
            <optional>true</optional>
        </dependency>

        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-core</artifactId>
            <version>3.10.0</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>com.github.stefanbirkner</groupId>
            <artifactId>system-rules</artifactId>
            <version>1.19.0</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>com.h2database</groupId>
            <artifactId>h2</artifactId>
            <version>2.1.212</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.flywaydb</groupId>
            <artifactId>flyway-core</artifactId>
            <version>3.2.1</version>
            <scope>test</scope>
        </dependency>

        <!-- postgresql tests -->

        <dependency>
            <groupId>org.testcontainers</groupId>
            <artifactId>postgresql</artifactId>
            <version>${testcontainers.version}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.postgresql</groupId>
            <artifactId>postgresql</artifactId>
            <version>42.2.5</version>
            <scope>test</scope>
        </dependency>

        <!-- msql server tests -->
        <dependency>
            <groupId>org.testcontainers</groupId>
            <artifactId>mssqlserver</artifactId>
            <version>${testcontainers.version}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>com.microsoft.sqlserver</groupId>
            <artifactId>mssql-jdbc</artifactId>
            <version>7.4.1.jre8</version>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>commons-codec</groupId>
                    <artifactId>commons-codec</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <!-- mysql test -->
        <dependency>
            <groupId>org.testcontainers</groupId>
            <artifactId>mysql</artifactId>
            <version>${testcontainers.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.mysql</groupId>
            <artifactId>mysql-connector-j</artifactId>
            <version>8.0.31</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.openjdk.jmh</groupId>
            <artifactId>jmh-core</artifactId>
            <version>1.11.3</version>
            <scope>provided</scope>
        </dependency>

    </dependencies>

    <build>
        <sourceDirectory>${src.dir}</sourceDirectory>
        <testSourceDirectory>${test.dir}</testSourceDirectory>
        <resources>
            <resource>
                <filtering>true</filtering>
                <directory>src/main/resources</directory>
            </resource>
        </resources>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <reuseForks>false</reuseForks>
                    <threadCount>2</threadCount>
                    <includes>
                        <include>**/*It.java</include>
                        <include>**/*Test.java</include>
                        <include>**/*Bdd.java</include>
                    </includes>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>jakarta</id>
            <properties>
                <src.dir>${project.build.directory}/classes</src.dir>
                <test.dir>${project.build.directory}/test-classes</test.dir>
            </properties>
            <dependencies>
                <dependency>
                    <groupId>org.hibernate</groupId>
                    <artifactId>hibernate-core</artifactId>
                    <version>6.2.3.Final</version>
                    <scope>provided</scope>
                </dependency>
                <dependency>
                    <groupId>org.eclipse.persistence</groupId>
                    <artifactId>eclipselink</artifactId>
                    <version>4.0.1</version>
                    <scope>provided</scope>
                </dependency>
            </dependencies>
            <build>
                <resources>
                    <resource>
                        <directory>src/main/java</directory>
                        <includes>
                            <include>**/*.java</include>
                            <include>**/*.jv</include>
                        </includes>
                    </resource>
                </resources>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-jar-plugin</artifactId>
                        <version>3.0.2</version>
                        <configuration>
                            <classifier>jakarta</classifier>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>com.coderplus.maven.plugins</groupId>
                        <artifactId>copy-rename-maven-plugin</artifactId>
                        <version>1.0.1</version>
                        <executions>
                            <execution>
                                <id>copy-and-rename-sources</id>
                                <phase>generate-sources</phase>
                                <goals>
                                    <goal>copy</goal>
                                </goals>
                                <configuration>
                                    <fileSets>
                                        <fileSet>
                                            <sourceFile>
                                                ${project.basedir}/src/main/java/com/github/database/rider/core/util/EntityManagerProvider.jv
                                            </sourceFile>
                                            <destinationFile>
                                                ${project.build.outputDirectory}/com/github/database/rider/core/util/EntityManagerProvider.java
                                            </destinationFile>
                                        </fileSet>
                                        <fileSet>
                                            <sourceFile>
                                                ${project.basedir}/src/main/java/com/github/database/rider/core/dataset//builder/BuilderUtil.jv
                                            </sourceFile>
                                            <destinationFile>
                                                ${project.build.outputDirectory}/com/github/database/rider/core/dataset/builder/BuilderUtil.java
                                            </destinationFile>
                                        </fileSet>
                                    </fileSets>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>io.github.floverfelt</groupId>
                        <artifactId>find-and-replace-maven-plugin</artifactId>
                        <version>1.1.0</version>
                        <executions>
                            <execution>
                                <id>exec</id>
                                <phase>process-resources</phase>
                                <goals>
                                    <goal>find-and-replace</goal>
                                </goals>
                                <configuration>
                                    <replacementType>file-contents</replacementType>
                                    <baseDir>target/classes/</baseDir>
                                    <fileMask>.java</fileMask>
                                    <findRegex>javax</findRegex>
                                    <replaceValue>jakarta</replaceValue>
                                    <recursive>true</recursive>
                                </configuration>
                            </execution>
                            <execution>
                                <id>exec-tests</id>
                                <phase>process-test-resources</phase>
                                <goals>
                                    <goal>find-and-replace</goal>
                                </goals>
                                <configuration>
                                    <replacementType>file-contents</replacementType>
                                    <baseDir>target/test-classes/</baseDir>
                                    <fileMask>.java</fileMask>
                                    <findRegex>javax</findRegex>
                                    <replaceValue>jakarta</replaceValue>
                                    <recursive>true</recursive>
                                </configuration>
                            </execution>
                            <execution>
                                <id>exec-sql</id>
                                <phase>process-resources</phase>
                                <goals>
                                    <goal>find-and-replace</goal>
                                </goals>
                                <configuration>
                                    <replacementType>file-contents</replacementType>
                                    <baseDir>target/classes/</baseDir>
                                    <fileMask>.java</fileMask>
                                    <findRegex>jakarta.sql.DataSource</findRegex>
                                    <replaceValue>javax.sql.DataSource</replaceValue>
                                    <recursive>true</recursive>
                                </configuration>
                            </execution>
                            <execution>
                                <id>exec-script</id>
                                <phase>process-resources</phase>
                                <goals>
                                    <goal>find-and-replace</goal>
                                </goals>
                                <configuration>
                                    <replacementType>file-contents</replacementType>
                                    <baseDir>target/classes/com/github/database/rider/core/script/</baseDir>
                                    <fileMask>.java</fileMask>
                                    <findRegex>jakarta</findRegex>
                                    <replaceValue>javax</replaceValue>
                                    <recursive>false</recursive>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-antrun-plugin</artifactId>
                        <version>1.7</version>
                        <executions>
                            <execution>
                                <phase>prepare-package</phase>
                                <goals>
                                    <goal>run</goal>
                                </goals>
                                <configuration>
                                    <target>
                                        <delete>
                                            <fileset dir="${project.build.directory}/classes" includes="**/*.java" />
                                            <fileset dir="${project.build.directory}/classes" includes="**/*.jv" />
                                            <fileset dir="${project.build.directory}/classes" includes="**/beans-jakarta.xml" />
                                        </delete>
                                    </target>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <version>3.1.0</version>
                        <configuration>
                            <skipTests>true</skipTests>
                        </configuration>
                    </plugin>
                    <!-- Override version for maven-install-plugin because there is a bug in
 3.0.0-M1 preventing installing of modules with packaging of feature
 see: https://issues.apache.org/jira/browse/MINSTALL-151 -->
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-install-plugin</artifactId>
                        <version>2.5.2</version>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>docs</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>com.github.cukedoctor</groupId>
                        <artifactId>cukedoctor-maven-plugin</artifactId>
                        <version>3.9.0</version>
                        <configuration>
                            <outputFileName>documentation</outputFileName>
                            <!-- by default it resolves to 'latest' and is overriden by release profile -->
                            <outputDir>${docs.outputdir}</outputDir>
                            <!--pdf and html5 -->
                            <format>all</format>
                            <documentTitle>Database Rider Documentation</documentTitle>
                            <hideSummarySection>true</hideSummarySection>
                            <hideScenarioKeyword>true</hideScenarioKeyword>
                            <hideStepTime>true</hideStepTime>
                            <hideFeaturesSection>true</hideFeaturesSection>
                            <hideTags>true</hideTags>
                            <sourceHighlighter>coderay</sourceHighlighter>
                            <toc>center</toc>
                            <numbered>true</numbered>
                            <docVersion>${project.version}</docVersion>
                        </configuration>
                        <executions>
                            <execution>
                                <goals>
                                    <goal>execute</goal>
                                </goals>
                                <phase>verify</phase>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-scm-publish-plugin</artifactId>
                        <version>1.1</version>
                        <configuration>
                            <checkoutDirectory>${project.build.outputDirectory}</checkoutDirectory>
                            <checkinComment>Publishing Database Rider ${project.parent.version} living documentation.
                            </checkinComment>
                            <content>target/docs</content>
                            <skipDeletedFiles>true</skipDeletedFiles>
                            <pubScmUrl>scm:git:https://${GH_TOKEN}@github.com/database-rider/database-rider.git
                            </pubScmUrl>
                            <scmBranch>gh-pages</scmBranch>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <profile>
            <id>perf</id>
            <dependencies>
                <dependency>
                    <groupId>org.openjdk.jmh</groupId>
                    <artifactId>jmh-core</artifactId>
                    <version>1.11.3</version>
                </dependency>
                <dependency>
                    <groupId>org.openjdk.jmh</groupId>
                    <artifactId>jmh-generator-annprocess</artifactId>
                    <version>1.11.3</version>
                    <scope>provided</scope>
                </dependency>
                <dependency>
                    <groupId>org.slf4j</groupId>
                    <artifactId>slf4j-simple</artifactId>
                </dependency>
            </dependencies>
            <build>
                <resources>
                    <resource>
                        <directory>src/perf/resources</directory>
                        <filtering>true</filtering>
                    </resource>
                    <resource>
                        <directory>src/perf/resources</directory>
                        <filtering>true</filtering>
                    </resource>
                </resources>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-compiler-plugin</artifactId>
                        <configuration>
                            <compilerVersion>1.7</compilerVersion>
                            <source>1.7</source>
                            <target>1.7</target>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>exec-maven-plugin</artifactId>
                        <configuration>
                            <executable>java</executable>
                            <arguments>
                                <argument>-classpath</argument>
                                <classpath />
                                <argument>com.github.database.rider.RiderDataSetBenchmark</argument>
                                <commandlineArgs>-Xms512m</commandlineArgs>
                                <commandlineArgs>-Xmx512m</commandlineArgs>
                                <commandlineArgs>-XX:+PrintGCTimeStamps</commandlineArgs>
                                <commandlineArgs>-XX:+PrintGCDetails</commandlineArgs>
                                <commandlineArgs>-XX:+HeapDumpOnOutOfMemoryError</commandlineArgs>
                            </arguments>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>build-helper-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <phase>generate-sources</phase>
                                <goals>
                                    <goal>add-source</goal>
                                </goals>
                                <configuration>
                                    <sources>
                                        <source>src/perf/java</source>
                                    </sources>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>release</id>
            <properties>
                <docs.outputdir>docs/${project.version}</docs.outputdir>
            </properties>
        </profile>
    </profiles>

</project>
