<?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 SDO</name>
    <groupId>org.eclipse.persistence</groupId>
    <artifactId>org.eclipse.persistence.sdo</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>
        <dep.sources>${project.build.directory}/generated-sources/dependencies</dep.sources>
        <jdoc.doclint>-missing</jdoc.doclint>
        <!-- XXX deprecated comes from commonj.sdo which we don't want to touch,
             we also do not want to see what has already been reported earlier -->
        <comp.xlint>-Xlint:all,-rawtypes,-unchecked,-serial,-deprecation,-dep-ann</comp.xlint>
        <comp.test.xlint>-Xlint:all,-rawtypes,-unchecked,-serial,-deprecation,-dep-ann</comp.test.xlint>
        <comp.xdoclint>-Xdoclint:none</comp.xdoclint>

        <test-skip-sdo-srg>${skipTests}</test-skip-sdo-srg>
        <test-skip-sdo>true</test-skip-sdo>
    </properties>

    <dependencies>
        <dependency>
            <groupId>jakarta.activation</groupId>
            <artifactId>jakarta.activation-api</artifactId>
            <scope>provided</scope>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>jakarta.mail</groupId>
            <artifactId>jakarta.mail-api</artifactId>
            <scope>provided</scope>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.eclipse.persistence</groupId>
            <artifactId>org.eclipse.persistence.moxy</artifactId>
            <optional>true</optional>
        </dependency>

        <dependency>
            <groupId>org.eclipse.persistence</groupId>
            <artifactId>commonj.sdo</artifactId>
            <scope>provided</scope>
        </dependency>

        <!--Test dependencies-->
        <!--Test framework-->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.eclipse.angus</groupId>
            <artifactId>angus-activation</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.eclipse.angus</groupId>
            <artifactId>angus-mail</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <id>unpack-sources</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>unpack-dependencies</goal>
                        </goals>
                        <configuration>
                            <includeGroupIds>${project.groupId}</includeGroupIds>
                            <includeArtifactIds>commonj.sdo</includeArtifactIds>
                            <classifier>sources</classifier>
                            <excludeTransitive>true</excludeTransitive>
                            <excludes>module-info.*,META-INF/versions/**,META-INF/MANIFEST.MF,
                                META-INF/*.SF,META-INF/*.DSA,META-INF/*.RSA,META-INF/*.inf,plugin.properties</excludes>
                            <outputDirectory>${dep.sources}</outputDirectory>
                        </configuration>
                    </execution>
                    <!--Resolve and store into maven property build classpath-->
                    <execution>
                        <phase>compile</phase>
                        <goals>
                            <goal>build-classpath</goal>
                        </goals>
                        <configuration>
                            <outputProperty>maven.compile.classpath</outputProperty>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
           <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>build-helper-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>add-resource</id>
                        <phase>generate-resources</phase>
                        <goals>
                            <goal>add-resource</goal>
                        </goals>
                        <configuration>
                            <resources>
                                <resource>
                                    <directory>${dep.sources}</directory>
                                    <excludes>
                                        <exclude>**/*.java</exclude>
                                    </excludes>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                    <execution>
                        <id>add-source</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>add-source</goal>
                        </goals>
                        <configuration>
                            <sources>
                                <source>${dep.sources}</source>
                            </sources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <!--Required for tests, because working directory for EclipseLink SDO compiler tests is .../target/test-run-->
            <plugin>
                <artifactId>maven-resources-plugin</artifactId>
                <executions>
                    <execution>
                        <id>copy-resources</id>
                        <!-- here the phase you need -->
                        <phase>test</phase>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${project.build.directory}/test-run</outputDirectory>
                            <resources>
                                <resource>
                                    <directory>${project.testResources[0].directory}</directory>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <!-- XXX deprecated comes from commonj.sdo which we don't want to touch -->
                    <showDeprecation>false</showDeprecation>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <workingDirectory>${project.build.directory}/test-run</workingDirectory>
                    <!--Set system properties required for tests-->
                    <systemPropertyVariables>
                        <loggingLevelFinest>false</loggingLevelFinest>
                        <!--<customContext>true</customContext>-->
                        <eclipselink.xml.platform>${test.xml.platform}</eclipselink.xml.platform>
                        <tempFileDir>${project.build.directory}/test-run</tempFileDir>
                        <ignoreCRLF>true</ignoreCRLF>
                        <useLogging>false</useLogging>
                        <sdo.classgen.compile.path>${project.build.outputDirectory}${path.separator}${project.build.testOutputDirectory}${path.separator}${maven.compile.classpath}</sdo.classgen.compile.path>
                        <useSAXParsing>true</useSAXParsing>
                        <useDeploymentXML>false</useDeploymentXML>
                        <jaxb.test.contextpath>oracle.toplink.testing.ox.jaxb.sax</jaxb.test.contextpath>
                    </systemPropertyVariables>
                </configuration>
                <executions>
                    <execution>
                        <id>default-test</id>
                        <configuration>
                            <skipTests>true</skipTests>
                            <excludes>
                                <exclude>*</exclude>
                            </excludes>
                        </configuration>
                    </execution>
                    <execution>
                        <id>test-sdo-srg</id>
                        <goals>
                            <goal>test</goal>
                        </goals>
                        <configuration>
                            <skipTests>${test-skip-sdo-srg}</skipTests>
                            <reportNameSuffix>test-sdo-srg</reportNameSuffix>
                            <includes>
                                <include>org.eclipse.persistence.testing.sdo.SDOSRGTestSuite</include>
                            </includes>
                        </configuration>
                    </execution>
                    <execution>
                        <id>test-sdo</id>
                        <goals>
                            <goal>test</goal>
                        </goals>
                        <configuration>
                            <skipTests>${test-skip-sdo}</skipTests>
                            <reportNameSuffix>test-sdo</reportNameSuffix>
                            <includes>
                                <!--<include>org.eclipse.persistence.testing.sdo.helper.xmlhelper.loadandsave.nodenullpolicy.IsSetLoadAndSaveTestSuite</include>-->
                                <include>**.*TestSuite</include>
                            </includes>
                            <excludes>
                                <exclude>org.eclipse.persistence.testing.sdo.SDOTestSuite</exclude>
                                <exclude>org.eclipse.persistence.testing.sdo.SDOSRGTestSuite</exclude>
                                <exclude>org.eclipse.persistence.testing.sdo.helper.SDOHelperTestSuite</exclude>
                                <exclude>org.eclipse.persistence.testing.sdo.helper.xmlhelper.SDOXMLHelperTestSuite</exclude>
                                <exclude>org.eclipse.persistence.testing.sdo.helper.typehelper.define.SDOTypeHelperDefineTestSuite</exclude>
                                <exclude>org.eclipse.persistence.testing.sdo.helper.xsdhelper.define.XSDHelperDefineTestSuite</exclude>
                                <exclude>org.eclipse.persistence.testing.sdo.model.SDOModelTestSuite</exclude>
                                <exclude>org.eclipse.persistence.testing.sdo.performance.*TestSuite</exclude>
                            </excludes>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <!--Generate OSGi bundle/manifest-->
            <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>
                                    !META-INF.*,
                                    *
                                </Export-Package>
                                <Import-Package>
                                    org.eclipse.persistence.internal.libraries.asm*;version="${version;==;${@}}",
                                    jakarta.activation;resolution:=optional,
                                    jakarta.mail.internet;resolution:=optional,
                                    *
                                </Import-Package>
                            </instructions>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <configuration>
                    <archive>
                        <manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
                        <manifest>
                            <addDefaultEntries>false</addDefaultEntries>
                        </manifest>
                    </archive>
                </configuration>
            </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>
        <!--SDO related profiles-->
        <profile>
            <id>test-sdo-srg</id>
            <properties>
                <test-skip-sdo-srg>false</test-skip-sdo-srg>
            </properties>
        </profile>
        <profile>
            <id>test-sdo</id>
            <properties>
                <test-skip-sdo-srg>true</test-skip-sdo-srg>
                <test-skip-sdo>false</test-skip-sdo>
            </properties>
        </profile>
    </profiles>
</project>
