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

    Copyright (c) 2019, 2023 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 DBWS</name>
    <groupId>org.eclipse.persistence</groupId>
    <artifactId>org.eclipse.persistence.dbws</artifactId>
    <packaging>jar</packaging>

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

    <properties>
        <!-- disable warnings for exports for now -->
        <comp.xlint>-Xlint:all</comp.xlint>
        <test-skip-dbws>${skipTests}</test-skip-dbws>
    </properties>

    <dependencies>
        <!--Other modules-->
        <dependency>
            <groupId>org.eclipse.persistence</groupId>
            <artifactId>org.eclipse.persistence.jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>org.eclipse.persistence</groupId>
            <artifactId>org.eclipse.persistence.moxy</artifactId>
        </dependency>
        <!--API dependencies-->
        <dependency>
            <groupId>jakarta.activation</groupId>
            <artifactId>jakarta.activation-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>jakarta.mail</groupId>
            <artifactId>jakarta.mail-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>jakarta.servlet</groupId>
            <artifactId>jakarta.servlet-api</artifactId>
            <scope>provided</scope>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>jakarta.xml.bind</groupId>
            <artifactId>jakarta.xml.bind-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>jakarta.xml.soap</groupId>
            <artifactId>jakarta.xml.soap-api</artifactId>
            <scope>provided</scope>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>jakarta.xml.ws</groupId>
            <artifactId>jakarta.xml.ws-api</artifactId>
            <scope>provided</scope>
            <optional>true</optional>
        </dependency>
        <!--Test dependencies-->
        <!--Test framework-->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</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>
        <plugins>
            <plugin>
                <groupId>org.apache.felix</groupId>
                <artifactId>maven-bundle-plugin</artifactId>
                <executions>
                    <execution>
                        <id>bundle-manifest</id>
                        <goals>
                            <goal>manifest</goal>
                        </goals>
                        <configuration>
                            <instructions>
                                <Export-Package>
                                    org.eclipse.persistence.internal.dbws,
                                    org.eclipse.persistence.internal.xr,
                                    org.eclipse.persistence.internal.xr.sxf,
                                    *
                                </Export-Package>
                                <Import-Package>
                                    org.eclipse.persistence.internal.libraries.asm*;version="${version;==;${@}}",
                                    *
                                </Import-Package>
                            </instructions>
                        </configuration>
                    </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>
                    <!--Set system properties required for tests-->
                    <systemPropertiesFile>${test.properties.file}</systemPropertiesFile>
                    <workingDirectory>${project.build.directory}/test-run</workingDirectory>
                </configuration>
                <executions>
                    <execution>
                        <id>test-dbws</id>
                        <goals>
                            <goal>integration-test</goal>
                        </goals>
                        <configuration>
                            <skipTests>${test-skip-dbws}</skipTests>
                            <reportNameSuffix>test-dbws</reportNameSuffix>
                            <includes>
                                <include>**/KeyMappingsTest*</include>
                                <include>**/RelationshipsTest*</include>
                                <include>**/XRDynamicEntityTest*</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>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>
            <!--This plugin sql-maven-plugin must be after maven-surefire-plugin to call dbteardown*.sql scripts after tests-->
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>sql-maven-plugin</artifactId>
                <configuration>
                    <!--all executions are ignored if -Dmaven.test.skip=true-->
                    <skip>${test-skip-dbws}</skip>
                </configuration>
                <executions>
                    <!-- create db tables after test -->
                    <execution>
                        <id>create-tables-before-test</id>
                        <phase>pre-integration-test</phase>
                        <goals>
                            <goal>execute</goal>
                        </goals>
                        <configuration>
                            <autocommit>true</autocommit>
                            <delimiter>|</delimiter>
                            <onError>continue</onError>
                            <srcFiles>
                                <srcFile>${integration.test.resources.directory}/sql/dbsetup_keymappings.sql</srcFile>
                                <srcFile>${integration.test.resources.directory}/sql/dbsetup_relationships.sql</srcFile>
                            </srcFiles>
                        </configuration>
                    </execution>
                    <!-- drop db tables after test -->
                    <execution>
                        <id>drop-tables-after-test</id>
                        <phase>post-integration-test</phase>
                        <goals>
                            <goal>execute</goal>
                        </goals>
                        <configuration>
                            <autocommit>true</autocommit>
                            <delimiter>|</delimiter>
                            <onError>continue</onError>
                            <srcFiles>
                                <srcFile>${integration.test.resources.directory}/sql/dbteardown_keymappings.sql</srcFile>
                                <srcFile>${integration.test.resources.directory}/sql/dbteardown_relationships.sql</srcFile>
                            </srcFiles>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>oracle</id>
            <build>
                <plugins>
                    <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>sql-maven-plugin</artifactId>
                        <configuration>
                            <skip>true</skip>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-failsafe-plugin</artifactId>
                        <configuration>
                            <skip>true</skip>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>test-srg</id>
            <properties>
                <test-skip-dbws>false</test-skip-dbws>
            </properties>
        </profile>
        <!--DBWS related profiles-->
        <profile>
            <id>test-dbws</id>
            <properties>
                <test-skip-dbws>false</test-skip-dbws>
            </properties>
        </profile>
    </profiles>
</project>
