<?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">
    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>org.voltdb</groupId>
        <artifactId>volt-testcontainer-module</artifactId>
        <version>1.8.0</version>
    </parent>

    <artifactId>volt-testcontainer</artifactId>

    <name>VoltDB Test Container</name>
    <description>Provides a volt cluster testcontainer's api to start volt inside docker
        container
    </description>

    <licenses>
        <license>
            <name>MIT License</name>
            <url>https://github.com/git/git-scm.com/blob/main/MIT-LICENSE.txt</url>
            <distribution>repo</distribution>
            <comments>A short and simple permissive license</comments>
        </license>
    </licenses>

    <dependencies>
        <dependency>
            <groupId>org.testcontainers</groupId>
            <artifactId>testcontainers</artifactId>
            <version>${testcontainerVersion}</version>
        </dependency>

        <dependency>
            <groupId>org.voltdb</groupId>
            <artifactId>voltdbclient</artifactId>
            <version>${voltdbclient.version}</version>
        </dependency>

        <!-- slf4j-api is used by the main source (VoltDBCluster, LicenseHelper) -->
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>${slf4jVersion}</version>
        </dependency>

        <!-- Test-only dependencies -->
        <dependency>
            <groupId>org.voltdb</groupId>
            <artifactId>volt-procedure-api</artifactId>
            <version>${volt-procedure-api.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-api</artifactId>
            <version>${junit.jupiter.version}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.junit.platform</groupId>
            <artifactId>junit-platform-launcher</artifactId>
            <version>${junit-platform.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.platform</groupId>
            <artifactId>junit-platform-engine</artifactId>
            <version>${junit-platform.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.assertj</groupId>
            <artifactId>assertj-core</artifactId>
            <version>${assertj.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-simple</artifactId>
            <version>${slf4jVersion}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.google.code.gson</groupId>
            <artifactId>gson</artifactId>
            <version>2.11.0</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <extensions>
            <extension>
                <groupId>com.google.cloud.artifactregistry</groupId>
                <artifactId>artifactregistry-maven-wagon</artifactId>
                <version>2.2.0</version>
            </extension>
        </extensions>
        <plugins>
            <!-- Require a valid VoltDB license before the build proceeds -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-enforcer-plugin</artifactId>
                <version>3.4.1</version>
                <executions>
                    <execution>
                        <id>enforce-voltdb-license</id>
                        <goals><goal>enforce</goal></goals>
                        <phase>validate</phase>
                        <configuration>
                            <rules>
                                <evaluateBeanshell>
                                    <condition>
                                        String license = System.getenv("VOLTDB_LICENSE");
                                        if (license != null &amp;&amp; !license.isEmpty() &amp;&amp; new java.io.File(license).exists()) {
                                            return true;
                                        }
                                        String home = System.getProperty("user.home");
                                        if (new java.io.File(home, "license.xml").exists()) {
                                            return true;
                                        }
                                        return new java.io.File("/tmp/license.xml").exists();
                                    </condition>
                                    <message>
========================================
VoltDB License Required!
========================================
No license file found. Please use one of:
  1. Set VOLTDB_LICENSE environment variable to your license.xml path, OR
  2. Place license.xml in your home directory: ${user.home}/license.xml, OR
  3. Place license file at: /tmp/license.xml

See README.md for more details.
========================================
                                    </message>
                                </evaluateBeanshell>
                            </rules>
                            <fail>true</fail>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <!-- Build a procedures JAR from the test-compiled flash sale classes.
                 This runs during the 'package' phase, before failsafe runs the
                 integration tests in 'integration-test', so the JAR is always ready. -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>3.3.0</version>
                <executions>
                    <execution>
                        <id>procedures-jar</id>
                        <phase>package</phase>
                        <goals><goal>jar</goal></goals>
                        <configuration>
                            <classifier>procedures</classifier>
                            <classesDirectory>${project.build.testOutputDirectory}</classesDirectory>
                            <includes>
                                <include>flashsale/procedures/**</include>
                                <include>flashsale/common/**</include>
                            </includes>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <!-- Copy runtime test dependencies (joda-time) to target/lib/ so that
                 the VoltDBCluster extraJarsDir feature can load them into the server. -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>3.6.1</version>
                <executions>
                    <execution>
                        <id>copy-test-runtime-deps</id>
                        <phase>package</phase>
                        <goals><goal>copy-dependencies</goal></goals>
                        <configuration>
                            <outputDirectory>${project.build.directory}/lib</outputDirectory>
                            <includeArtifactIds>gson</includeArtifactIds>
                            <includeScope>test</includeScope>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <!-- Install volt-testcontainer to the local Maven repo before ITs run.
                 The archetype IT (in a sibling module) spawns a secondary Maven process
                 that resolves volt-testcontainer from ~/.m2, not the reactor. -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-install-plugin</artifactId>
                <version>3.1.2</version>
                <executions>
                    <execution>
                        <id>install-for-archetype-it</id>
                        <phase>pre-integration-test</phase>
                        <goals>
                            <goal>install</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <!-- Run integration tests (*IT.java) after the package phase via failsafe.
                 Surefire is not configured because there are no unit tests here. -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-failsafe-plugin</artifactId>
                <version>3.1.2</version>
                <configuration>
                    <trimStackTrace>false</trimStackTrace>
                    <argLine>--add-opens=java.base/sun.nio.ch=ALL-UNNAMED</argLine>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>integration-test</goal>
                            <goal>verify</goal>
                        </goals>
                        <configuration>
                            <includes>
                                <include>**/*IT.java</include>
                            </includes>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-source-plugin</artifactId>
                <version>2.2.1</version>
                <executions>
                    <execution>
                        <id>attach-sources</id>
                        <goals>
                            <goal>jar-no-fork</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <version>3.7.0</version>
                <configuration>
                    <excludePackageNames>org.voltdb.testparser</excludePackageNames>
                </configuration>
                <executions>
                    <execution>
                        <id>attach-javadocs</id>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>release</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.sonatype.central</groupId>
                        <artifactId>central-publishing-maven-plugin</artifactId>
                        <version>0.8.0</version>
                        <extensions>true</extensions>
                        <configuration>
                            <serverId>central</serverId>
                            <deploymentName>${project.artifactId}-${project.version}
                            </deploymentName>
                            <autoPublish>false
                            </autoPublish>  <!-- or false for manual publishing -->
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-gpg-plugin</artifactId>
                        <version>3.2.6</version>
                        <executions>
                            <execution>
                                <id>sign-artifacts</id>
                                <phase>verify</phase>
                                <goals>
                                    <goal>sign</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
