<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.clazzes.svc</groupId>
    <artifactId>svc-runner</artifactId>
    <version>1.3.7</version>
    <relativePath>..</relativePath>
  </parent>
  <artifactId>svc-runner-jdbc</artifactId>
  <name>Service Runner JDBC provider</name>

  <dependencies>
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-simple</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>com.zaxxer</groupId>
      <artifactId>HikariCP</artifactId>
      <version>${hikaricp.version}</version>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <plugin>
        <!--
          Exclude main dependencies from svc-runner-core, this way we can collect our
          dependencies using

          mvn -DincludeScope=compile -DoutputDirectory=... dependency:copy-dependencies
        -->
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
        <configuration>
          <excludeArtifactIds>
            svc-api,
            slf4j-api
          </excludeArtifactIds>
          <excludeTransitive>true</excludeTransitive>
          <includeScope>compile</includeScope>
        </configuration>
      </plugin>
    </plugins>
  </build>

  <!--
    Enable collection of JDBC drivers using

    mvn -Djdbc.dialect=<dialect> -DincludeScope=provided dependency:copy-dependencies

    <dialect> is one of:

      postgres
      mariadb
      mssql
      oracle
  -->
  <profiles>
    <profile>
      <id>postgres-driver</id>
      <activation>
        <property>
          <name>jdbc.dialect</name>
          <value>postgres</value>
        </property>
      </activation>
      <dependencies>
        <dependency>
          <groupId>org.postgresql</groupId>
          <artifactId>postgresql</artifactId>
          <version>${postgres.version}</version>
          <scope>provided</scope>
        </dependency>
      </dependencies>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <configuration>
              <includeArtifactIds>
                postgresql
              </includeArtifactIds>
              <excludeTransitive>true</excludeTransitive>
              <outputDirectory>${project.build.directory}/postgres-dependency</outputDirectory>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
    <profile>
      <id>mariadb-driver</id>
      <activation>
        <property>
          <name>jdbc.dialect</name>
          <value>mariadb</value>
        </property>
      </activation>
      <dependencies>
        <dependency>
          <groupId>org.mariadb.jdbc</groupId>
          <artifactId>mariadb-java-client</artifactId>
          <version>${mariadb.version}</version>
          <scope>provided</scope>
        </dependency>
      </dependencies>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <configuration>
              <includeArtifactIds>
                mariadb-java-client
              </includeArtifactIds>
              <excludeTransitive>true</excludeTransitive>
              <outputDirectory>${project.build.directory}/mariadb-dependency</outputDirectory>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
    <profile>
      <id>mssql-driver</id>
      <activation>
        <property>
          <name>jdbc.dialect</name>
          <value>mssql</value>
        </property>
      </activation>
      <dependencies>
        <dependency>
          <groupId>com.microsoft.sqlserver</groupId>
          <artifactId>mssql-jdbc</artifactId>
          <version>${mssql.version}</version>
          <scope>provided</scope>
        </dependency>
      </dependencies>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <configuration>
              <includeArtifactIds>
                mssql-jdbc
              </includeArtifactIds>
              <excludeTransitive>true</excludeTransitive>
              <outputDirectory>${project.build.directory}/mssql-dependency</outputDirectory>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
    <profile>
      <id>oracle-driver</id>
      <activation>
        <property>
          <name>jdbc.dialect</name>
          <value>oracle</value>
        </property>
      </activation>
      <dependencies>
        <dependency>
          <groupId>com.oracle.database.jdbc</groupId>
          <artifactId>ojdbc17</artifactId>
          <version>${oracle.version}</version>
          <scope>provided</scope>
        </dependency>
      </dependencies>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <configuration>
              <includeArtifactIds>
                ojdbc17
              </includeArtifactIds>
              <excludeTransitive>true</excludeTransitive>
              <outputDirectory>${project.build.directory}/oracle-dependency</outputDirectory>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>

</project>
