<?xml version="1.0" encoding="UTF-8"?>
<!--

    Copyright (c) 2019, 2021 Oracle and/or its affiliates. All rights reserved.

    This program and the accompanying materials are made available under the
    terms of the Eclipse Public License v. 2.0 which is available at
    http://www.eclipse.org/legal/epl-2.0,
    or the Eclipse Distribution License v. 1.0 which is available at
    http://www.eclipse.org/org/documents/edl-v10.php.

    SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause

-->

<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <modelVersion>4.0.0</modelVersion>

    <name>EclipseLink JPA-RS</name>
    <groupId>org.eclipse.persistence</groupId>
    <artifactId>org.eclipse.persistence.jpars</artifactId>
    <packaging>jar</packaging>

    <parent>
        <groupId>org.eclipse.persistence</groupId>
        <artifactId>org.eclipse.persistence.parent</artifactId>
        <version>3.0.4</version>
        <relativePath>../../pom.xml</relativePath>
    </parent>

    <properties>
        <!--Properties used for test resources filtering/replacement-->
        <!--DB connection properties-->
        <db_user>${db.user}</db_user>
        <db_pwd>${db.pwd}</db_pwd>
        <db_driver>${db.driver}</db_driver>
        <db_url>${db.url}</db_url>

        <test-skip-jpa-jpars>${skipTests}</test-skip-jpa-jpars>
    </properties>

    <dependencies>
        <!--Other modules-->
        <dependency>
            <groupId>org.eclipse.persistence</groupId>
            <artifactId>org.eclipse.persistence.dbws</artifactId>
        </dependency>
        <!--API dependencies-->
        <dependency>
            <groupId>jakarta.ws.rs</groupId>
            <artifactId>jakarta.ws.rs-api</artifactId>
        </dependency>
        <dependency>
            <groupId>jakarta.annotation</groupId>
            <artifactId>jakarta.annotation-api</artifactId>
        </dependency>
        <dependency>
            <groupId>jakarta.activation</groupId>
            <artifactId>jakarta.activation-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <!--Test dependencies-->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <scope>test</scope>
        </dependency>
        <!--API/Implementation dependencies-->
        <dependency>
            <groupId>jakarta.ejb</groupId>
            <artifactId>jakarta.ejb-api</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.glassfish</groupId>
            <artifactId>jakarta.json</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.glassfish.jersey.core</groupId>
            <artifactId>jersey-client</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.glassfish.jersey.core</groupId>
            <artifactId>jersey-common</artifactId>
            <scope>test</scope>
        </dependency>
        <!--JDBC driver (test dependency)-->
        <dependency>
            <groupId>${db.driver.groupId}</groupId>
            <artifactId>${db.driver.artifactId}</artifactId>
            <version>${db.driver.version}</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <!--Filtering enables generate/substitute test properties from Maven into test resource files.-->
        <testResources>
            <testResource>
                <directory>${integration.test.resources.directory}</directory>
                <filtering>true</filtering>
            </testResource>
        </testResources>

        <plugins>
            <!--Required for EL Weaving (-javaagent:${org.eclipse.persistence:org.eclipse.persistence.jpa:jar})-->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <!--Resolve dependencies into Maven properties like ${org.eclipse.persistence:org.eclipse.persistence.jpa:jar} for JPA module-->
                    <execution>
                        <id>get-test-classpath-to-properties</id>
                        <goals>
                            <goal>properties</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <skip>true</skip>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-failsafe-plugin</artifactId>
                <configuration>
                    <workingDirectory>${project.build.directory}/test-run</workingDirectory>
                    <!--EclipseLink Weaving is enabled.
                        When it will be disabled by -Dignore or without arg switch it leads into test errors-->
                    <argLine>-javaagent:${org.eclipse.persistence:org.eclipse.persistence.jpa:jar}</argLine>
                    <!--Set system properties required for tests-->
                    <systemPropertiesFile>${test.properties.file}</systemPropertiesFile>
                </configuration>
                <executions>
                    <execution>
                        <id>test-jpa-jpars</id>
                        <goals>
                            <goal>integration-test</goal>
                        </goals>
                        <configuration>
                            <skipTests>${test-skip-jpa-jpars}</skipTests>
                            <reportNameSuffix>test-jpa-jpars</reportNameSuffix>
                            <includes>
                                <include>org.eclipse.persistence.jpars.test.AllJavaSETests</include>
                            </includes>
                        </configuration>
                    </execution>
                    <execution>
                        <id>verify-integration-tests</id>
                        <goals>
                            <goal>verify</goal>
                        </goals>
                        <configuration>
                            <skip>${integration.test.skip.verify}</skip>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.carlspring.maven</groupId>
                <artifactId>derby-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>start-derby</id>
                        <phase>pre-integration-test</phase>
                        <goals>
                            <goal>start</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>stop-derby</id>
                        <phase>post-integration-test</phase>
                        <goals>
                            <goal>stop</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <executions>
                    <!-- need javadoc even in normal/short build
                        for inclusion in binary distribution -->
                    <execution>
                        <id>attach-javadocs</id>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>oracle</id>
            <dependencies>
                <!--db.platform=org.eclipse.persistence.platform.database.oracle.Oracle12Platform comes from there-->
                <dependency>
                    <groupId>org.eclipse.persistence</groupId>
                    <artifactId>org.eclipse.persistence.oracle</artifactId>
                    <scope>test</scope>
                </dependency>
            </dependencies>
        </profile>
    </profiles>
</project>
