<?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/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <parent>
    <groupId>org.tentackle</groupId>
    <artifactId>tentackle-parent</artifactId>
    <version>21.16.2.0</version>
  </parent>

  <artifactId>tentackle-test-pdo</artifactId>
  <packaging>jar</packaging>
  <name>Tentackle PDO Tests</name>
  <description>
    Test depdendency to support writing PDO-based tests.
    Also generates the SQL-scripts for the TT tables and
    contains some PDO tests.
    This artifact must be included in test-scope only!
  </description>
  <url>https://tentackle.org</url>

  <properties>
    <rootBasedir>${project.parent.basedir}</rootBasedir>
  </properties>

  <dependencies>

    <dependency>
      <groupId>${project.groupId}</groupId>
      <artifactId>tentackle-pdo</artifactId>
      <version>${project.version}</version>
    </dependency>
    <dependency>
      <groupId>${project.groupId}</groupId>
      <artifactId>tentackle-model</artifactId>
      <version>${project.version}</version>
    </dependency>
    <dependency>
      <groupId>org.testng</groupId>
      <artifactId>testng</artifactId>
      <scope>compile</scope>  <!-- override test -->
      <optional>true</optional>
    </dependency>
    <dependency>
      <groupId>org.junit.jupiter</groupId>
      <artifactId>junit-jupiter-api</artifactId>
      <optional>true</optional>
    </dependency>

    <dependency>
      <groupId>${project.groupId}</groupId>
      <artifactId>tentackle-persistence</artifactId>
      <version>${project.version}</version>
      <optional>true</optional>   <!-- don't mix up classpath order -->
    </dependency>
    <dependency>
      <groupId>${project.groupId}</groupId>
      <artifactId>tentackle-domain</artifactId>
      <version>${project.version}</version>
      <optional>true</optional>   <!-- don't mix up classpath order -->
    </dependency>

    <dependency>
      <groupId>org.postgresql</groupId>
      <artifactId>postgresql</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>com.h2database</groupId>
      <artifactId>h2</artifactId>
      <scope>test</scope>
    </dependency>

  </dependencies>

  <build>

    <resources>
      <!-- generated SQL and model source -->
      <resource>
        <directory>target/generated-resources</directory>
      </resource>
    </resources>

    <!-- backend properties -->
    <testResources>
      <testResource>
        <directory>src/test/filtered-resources</directory>
        <filtering>true</filtering>
      </testResource>
      <testResource>
        <directory>src/test/resources</directory>
      </testResource>
    </testResources>

    <plugins>

      <plugin>
        <groupId>org.tentackle</groupId>
        <artifactId>tentackle-maven-plugin</artifactId>
        <version>${project.version}</version>
        <executions>
          <execution>
            <id>analyze</id>
            <goals>
              <goal>analyze</goal>
            </goals>
          </execution>
          <execution>
            <id>test-analyze</id>
            <goals>
              <goal>test-analyze</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <verbosity>info</verbosity>
          <showCompileOutput>true</showCompileOutput>
          <index>META-INF/RESOURCE-INDEX.LIST</index>
        </configuration>
      </plugin>

      <plugin>
        <!-- create the SQL-files -->
        <groupId>org.tentackle</groupId>
        <artifactId>tentackle-sql-maven-plugin</artifactId>
        <version>${project.version}</version>
        <executions>
          <execution>
            <phase>generate-resources</phase>
            <goals>
              <goal>create</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <verbosity>info</verbosity>
          <generateHeaderComment>false</generateHeaderComment>
          <checkReservedTables>false</checkReservedTables>
          <backendNames>all</backendNames>
          <sqlDir>${project.build.directory}/generated-resources/META-INF/sql</sqlDir>
          <sqlFileName>createttmodel.sql</sqlFileName>
          <dumpDir>${project.build.directory}/generated-resources/META-INF/model</dumpDir>
          <dumpModelSource>true</dumpModelSource>
          <dumpModelIndex>${project.build.directory}/generated-resources/META-INF/MODEL-INDEX.LIST</dumpModelIndex>
          <backends>
            <!-- for migration only -->
            <backend>
              <url>${dbUrl}</url>
              <user>${dbUser}</user>
              <password>${dbPasswd}</password>
            </backend>
          </backends>
          <sequences>
            <sequence>
              <name>object_sequence_id</name>
              <comment>to generate the ID of PDOs</comment>
            </sequence>
          </sequences>
          <prependFilesets>
            <prependFileset>
              <directory>${project.basedir}/src/sql</directory>
              <includes>
                <include>*.sql</include>
              </includes>
            </prependFileset>
          </prependFilesets>
        </configuration>
        <dependencies>
          <!-- for migration only -->
          <dependency>
            <groupId>org.postgresql</groupId>
            <artifactId>postgresql</artifactId>
            <version>${postgresql.version}</version>
          </dependency>
        </dependencies>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>
        <configuration>
          <archive>
            <manifestEntries>
              <Automatic-Module-Name>org.tentackle.pdo.test</Automatic-Module-Name>
            </manifestEntries>
          </archive>
        </configuration>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-javadoc-plugin</artifactId>
        <configuration>
          <!-- automatic module name screws it up -->
          <legacyMode>true</legacyMode>
        </configuration>
      </plugin>

    </plugins>

  </build>

</project>
