<?xml version="1.0"?>
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">

    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>dev.getelements.elements</groupId>
        <artifactId>eci-elements</artifactId>
        <version>3.3.4</version>
    </parent>

    <artifactId>sdk-local-maven</artifactId>
    <name>${project.artifactId}</name>
    <version>3.3.4</version>

    <dependencies>

        <!-- SDK Dependencies -->
        <dependency>
            <groupId>dev.getelements.elements</groupId>
            <artifactId>sdk-local</artifactId>
        </dependency>

        <!-- Test Dependencies -->
        <!-- These should never be included in the final build -->
        <dependency>
            <groupId>org.testng</groupId>
            <artifactId>testng</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>dev.getelements.elements</groupId>
            <artifactId>mongo-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>dev.getelements.elements</groupId>
            <artifactId>sdk-test-element-rs</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>dev.getelements.elements</groupId>
            <artifactId>sdk-test-element-ws</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>dev.getelements.elements</groupId>
            <artifactId>sdk-spi-guice</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>dev.getelements.elements</groupId>
            <artifactId>sdk-logback</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>dev.getelements.elements</groupId>
            <artifactId>sdk-local-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>3.6.0</version>
                <executions>
                    <execution>
                        <id>copy-sdk-deps</id>
                        <phase>generate-resources</phase>
                        <goals>
                            <goal>copy-dependencies</goal>
                        </goals>
                        <configuration>
                            <includeArtifactIds>sdk-local</includeArtifactIds>
                            <includeGroupIds>dev.getelements.elements</includeGroupIds>
                            <outputDirectory>${project.build.directory}/sdk-libs</outputDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <!--
                The project layout makes this messy and we need to use multiple passes here. This isn't
                ideal but works. It also shoudln't be necessary for client code projects.
            -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>3.6.0</version>
                <executions>
                    <execution>
                        <id>copy-element-deps</id>
                        <phase>generate-resources</phase>
                        <goals>
                            <goal>copy-dependencies</goal>
                        </goals>
                        <configuration>
                            <includeGroupIds>
                                aopalliance,
                                jakarta.inject,
                                com.google.guava,
                                com.google.inject,
                                dev.getelements.elements,
                                com.fasterxml.jackson
                            </includeGroupIds>
                            <includeArtifactIds>
                                guice,
                                failureaccess,
                                inject-api,
                                aopalliance,
                                sdk-test-element-rs,
                                sdk-test-element-ws,
                                sdk-spi,
                                sdk-guice,
                                guava,
                                sdk-spi-guice,
                                jackson-core,
                                jackson-databind,
                                jackson-annotations,
                                jackson-jakarta-rs-base,
                                jackson-jakarta-rs-json-provider,
                                jackson-module-jakarta-xmlbind-annotations
                            </includeArtifactIds>
                            <outputDirectory>${project.build.directory}/element-libs</outputDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

        </plugins>
    </build>

    <profiles>
        <profile>
            <id>sdk-local-test</id>
            <activation>
                <activeByDefault>false</activeByDefault>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <version>3.0.0</version>
                        <configuration>
                            <suiteXmlFiles>
                                <suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile>
                            </suiteXmlFiles>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

</project>
