<?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 MOXy</name>
    <groupId>org.eclipse.persistence</groupId>
    <artifactId>org.eclipse.persistence.moxy</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>
        <comp.xlint>-Xlint:all,-serial,-exports</comp.xlint>

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

    <dependencies>
        <dependency>
            <groupId>jakarta.xml.bind</groupId>
            <artifactId>jakarta.xml.bind-api</artifactId>
        </dependency>
        <dependency>
            <groupId>jakarta.validation</groupId>
            <artifactId>jakarta.validation-api</artifactId>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>jakarta.ws.rs</groupId>
            <artifactId>jakarta.ws.rs-api</artifactId>
            <optional>true</optional>
        </dependency>

        <!--Other modules-->
        <dependency>
            <groupId>org.eclipse.persistence</groupId>
            <artifactId>org.eclipse.persistence.core</artifactId>
        </dependency>

        <dependency>
            <groupId>com.sun.xml.bind</groupId>
            <artifactId>jaxb-xjc</artifactId>
            <scope>provided</scope>
            <optional>true</optional>
        </dependency>

        <dependency>
            <groupId>org.eclipse.angus</groupId>
            <artifactId>angus-activation</artifactId>
        </dependency>
        <dependency>
            <groupId>org.eclipse.angus</groupId>
            <artifactId>angus-mail</artifactId>
        </dependency>

        <!--Test dependencies-->
        <!--Test framework-->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <scope>test</scope>
        </dependency>
        <!--Other modules-->
        <dependency>
            <groupId>org.eclipse.persistence</groupId>
            <artifactId>org.eclipse.persistence.core</artifactId>
            <type>test-jar</type>
            <scope>test</scope>
        </dependency>
        <!--APIs and other libs used in test classes-->
        <dependency>
            <groupId>com.sun.xml.bind</groupId>
            <artifactId>jaxb-impl</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.glassfish</groupId>
            <artifactId>jakarta.el</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.eclipse.parsson</groupId>
            <artifactId>parsson</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.glassfish.jersey.core</groupId>
            <artifactId>jersey-common</artifactId>
            <optional>true</optional>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.hibernate.validator</groupId>
            <artifactId>hibernate-validator</artifactId>
            <optional>true</optional>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <configuration>
                    <!-- required for BeanValidationRuntimeTestCase to pass
                        TODO: fix the test so this can go away -->
                    <includeEmptyDirs>true</includeEmptyDirs>
                </configuration>
            </plugin>
            <!--Add licence files (about.html, license.html, readme.html) to the build output directory-->
            <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-compiler-plugin</artifactId>
                <executions>
                    <execution>
                        <id>default-testCompile</id>
                        <configuration>
                            <compilerArgs>
                                <arg>--add-exports</arg>
                                <arg>org.eclipse.persistence.core/org.eclipse.persistence.internal.oxm.conversion=org.eclipse.persistence.moxy.test</arg>
                                <arg>--add-exports</arg>
                                <arg>org.eclipse.persistence.core/org.eclipse.persistence.internal.oxm.schema=org.eclipse.persistence.moxy.test</arg>
                                <arg>--add-exports</arg>
                                <arg>org.eclipse.persistence.core/org.eclipse.persistence.internal.oxm.schema.model=org.eclipse.persistence.moxy.test</arg>
                            </compilerArgs>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <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.jaxb,
                                    org.eclipse.persistence.internal.jaxb.many,
                                    *
                                </Export-Package>
                                <Import-Package>
                                    org.eclipse.persistence.internal.libraries.asm*;version="${version;==;${@}}",
                                    *
                                </Import-Package>
                            </instructions>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <!--Run specified tests/test suite-->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <workingDirectory>${project.build.directory}/test-run</workingDirectory>
                    <systemPropertyVariables>
                        <eclipselink.xml.platform>${test.xml.platform}</eclipselink.xml.platform>
                        <parser>${test.xml.parser}</parser>
                    </systemPropertyVariables>
                </configuration>
                <executions>
                    <execution>
                        <id>default-test</id>
                        <configuration>
                            <skipTests>${test-skip-moxy-srg}</skipTests>
                            <excludes>
                                <exclude>*</exclude>
                            </excludes>
                        </configuration>
                    </execution>
                    <execution>
                        <id>test-moxy-jaxb-srg</id>
                        <goals>
                            <goal>test</goal>
                        </goals>
                        <configuration>
                            <skipTests>${test-skip-moxy-jaxb-srg}</skipTests>
                            <reportNameSuffix>test-moxy-jaxb-srg</reportNameSuffix>
                            <includes>
                                <include>org.eclipse.persistence.testing.jaxb.JAXBSRGTestSuite</include>
                            </includes>
                        </configuration>
                    </execution>
                    <execution>
                        <id>test-moxy-jaxb</id>
                        <goals>
                            <goal>test</goal>
                        </goals>
                        <configuration>
                            <skipTests>${test-skip-moxy-jaxb}</skipTests>
                            <reportNameSuffix>test-moxy-jaxb</reportNameSuffix>
                            <forkCount>1</forkCount>
                            <reuseForks>false</reuseForks>
                            <includes>
                                <include>org.eclipse.persistence.testing.jaxb.JAXBTestSuite</include>
                                <include>org.eclipse.persistence.testing.jaxb.JAXBTestSuite2</include>
                                <include>org.eclipse.persistence.testing.jaxb.JAXBTestSuite3</include>
                                <include>org.eclipse.persistence.testing.jaxb.JAXBTestSuite4</include>
                                <include>org.eclipse.persistence.testing.jaxb.JAXBBeanValidationTestSuite</include>
                                <include>org.eclipse.persistence.testing.jaxb.beanvalidation.BeanValidationHelperTestCase</include>
                                <include>org.eclipse.persistence.testing.jaxb.listofobjects.JAXBListOfObjectsSuite</include>
                                <include>org.eclipse.persistence.testing.jaxb.annotations.AnnotationsTestSuite</include>
                                <include>org.eclipse.persistence.testing.jaxb.externalizedmetadata.ExternalizedMetadataTestSuite</include>
                                <include>org.eclipse.persistence.testing.jaxb.javadoc.JavadocAnnotationExamplesTestSuite</include>
                                <include>org.eclipse.persistence.testing.jaxb.typemappinginfo.TypeMappingInfoTestSuite</include>
                                <include>org.eclipse.persistence.testing.jaxb.schemagen.SchemaGenTestSuite</include>
                                <include>org.eclipse.persistence.testing.jaxb.xmladapter.XmlAdapterTestSuite</include>
                                <include>org.eclipse.persistence.testing.jaxb.dynamic.DynamicJAXBTestSuite</include>
                                <include>org.eclipse.persistence.testing.jaxb.json.JSONTestSuite</include>
                                <include>org.eclipse.persistence.testing.jaxb.rs.RESTfulTestSuite</include>
                                <include>org.eclipse.persistence.testing.moxy.unit.**.*TestCase</include>
                                <include>org.eclipse.persistence.testing.jaxb.annotations.xmlidref.XmlIdSystemPropertyNotSetTestCase</include>
                                <include>org.eclipse.persistence.testing.jaxb.annotations.xmlvalue.XmlValueSystemPropertyNotSetTestCase</include>
                                <include>org.eclipse.persistence.testing.jaxb.annotations.xmlvalue.XmlValueSystemPropertyTestCase</include>
                            </includes>
                            <excludes>
                                <exclude>org.eclipse.persistence.testing.moxy.unit.**.*NonDefaultTestCase</exclude>
                                <exclude>org.eclipse.persistence.testing.jaxb.**.*NonDefaultTestCase</exclude>
                            </excludes>
                        </configuration>
                    </execution>
                    <execution>
                        <id>test-moxy-jaxb-non-default-system-properties</id>
                        <goals>
                            <goal>test</goal>
                        </goals>
                        <configuration>
                            <skipTests>${test-skip-moxy-jaxb}</skipTests>
                            <reportNameSuffix>test-moxy-jaxb-non-default-system-properties</reportNameSuffix>
                            <systemPropertyVariables>
                                <org.eclipse.persistence.moxy.annotation.xml-id-extension>true</org.eclipse.persistence.moxy.annotation.xml-id-extension>
                                <org.eclipse.persistence.moxy.annotation.xml-value-extension>true</org.eclipse.persistence.moxy.annotation.xml-value-extension>
                                <org.eclipse.persistence.json.type-compatibility>true</org.eclipse.persistence.json.type-compatibility>
                                <org.eclipse.persistence.json.use-xsd-types-prefix>true</org.eclipse.persistence.json.use-xsd-types-prefix>
                                <eclipselink.logging.level.moxy>FINE</eclipselink.logging.level.moxy>
                                <eclipselink.logging.payload.moxy>true</eclipselink.logging.payload.moxy>
                            </systemPropertyVariables>
                            <includes>
                                <include>org.eclipse.persistence.testing.moxy.unit.**.*NonDefaultTestCase</include>
                                <include>org.eclipse.persistence.testing.jaxb.**.*NonDefaultTestCase</include>
                            </includes>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <!--
            To run tests on JPMS, remove all surefire executions except of the default-test
            and uncomment following:
            -->
<!--        <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-antrun-plugin</artifactId>
                <dependencies>
                    <dependency>
                        <groupId>org.apache.ant</groupId>
                        <artifactId>ant</artifactId>
                        <version>${ant.version}</version>
                    </dependency>
                    <dependency>
                        <groupId>org.apache.ant</groupId>
                        <artifactId>ant-junitlauncher</artifactId>
                        <version>${ant.version}</version>
                    </dependency>
                    <dependency>
                        <groupId>org.apache.ant</groupId>
                        <artifactId>ant-junit</artifactId>
                        <version>${ant.version}</version>
                    </dependency>
                </dependencies>
                <executions>
                    <execution>
                        <phase>test</phase>
                        <goals>
                            <goal>run</goal>
                        </goals>
                        <configuration>
                            <target>
                                <record name="${project.build.directory}/build.txt" loglevel="verbose" action="start" />

                                <path id="moxy.test.module.path">
                                    <pathelement path="${project.build.outputDirectory}"/>
                                    <pathelement path="${project.build.testOutputDirectory}"/>

                                    <pathelement path="${org.glassfish:jakarta.json:jar}"/>

                                    <pathelement path="${org.eclipse.persistence:org.eclipse.persistence.asm:jar}"/>
                                    <pathelement path="${org.eclipse.persistence:org.eclipse.persistence.core:jar}"/>

                                    <pathelement path="${jakarta.annotation:jakarta.annotation-api:jar}"/>
                                    <pathelement path="${jakarta.el:jakarta.el-api:jar}"/>
                                    <pathelement path="${jakarta.inject:jakarta.inject-api:jar}"/>
                                    <pathelement path="${jakarta.validation:jakarta.validation-api:jar}"/>
                                    <pathelement path="${jakarta.ws.rs:jakarta.ws.rs-api:jar}"/>
                                    <pathelement path="${jakarta.xml.bind:jakarta.xml.bind-api:jar}"/>

                                    <pathelement path="${com.fasterxml:classmate:jar}"/>
                                    <pathelement path="${com.sun.activation:jakarta.activation:jar}"/>
                                    <pathelement path="${com.sun.mail:jakarta.mail:jar}"/>
                                    <pathelement path="${com.sun.xml.bind:jaxb-core:jar}"/>
                                    <pathelement path="${com.sun.xml.bind:jaxb-impl:jar}"/>
                                    <pathelement path="${com.sun.xml.bind:jaxb-xjc:jar}"/>

                                    <pathelement path="${org.glassfish:jakarta.el:jar}"/>
                                    <pathelement path="${org.glassfish.jersey.core:jersey-common:jar}"/>
                                    <pathelement path="${org.hamcrest:hamcrest-core:jar}"/>
                                    <pathelement path="${org.hibernate.validator:hibernate-validator:jar}"/>
                                    <pathelement path="${org.jboss.logging:jboss-logging:jar}"/>
                                    <pathelement path="${junit:junit:jar}"/>
                                </path>

                                <path id="moxy.test.class.path">
                                    <pathelement path="${org.glassfish.hk2:osgi-resource-locator:jar}"/>
                                </path>

                                <echo message="Running moxy tests on JPMS"/>
                                <property name="report.dir" location="${project.build.directory}"/>
                                <property name="src.dir" location="${project.build.testSourceDirectory}"/>
                                <property name="build.dir" location="${project.build.directory}/ant-run"/>
                                <delete dir="${report.dir}/jaxb" failonerror="false"/>
                                <mkdir dir="${report.dir}/jaxb"/>
                                <mkdir dir="${build.dir}"/>
                                <mkdir dir="${build.dir}/tmp"/>

                                <junit fork="true" failureproperty="junit.failed.jaxb" logfailedtests="true" showoutput="yes" printsummary="yes"
                                       dir="${build.dir}" tempdir="${build.dir}/tmp" >
                                    <jvmarg value="-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005"/>
                                    <modulepath refid="moxy.test.module.path"/>
                                    <classpath refid="moxy.test.class.path"/>
                                    <jvmarg value="-ea"/>
                                    <jvmarg line="- -add-modules jakarta.json,org.eclipse.persistence.moxy.test,com.fasterxml.classmate"/>
                                    <sysproperty key="platformType" value="SAX"/>
                                    <sysproperty key="metadataType" value="JAVA"/>
                                    <sysproperty key="useLogging" value="false"/>
                                    <sysproperty key="eclipselink.xml.platform" value="org.eclipse.persistence.platform.xml.jaxp.JAXPPlatform"/>
                                    <sysproperty key="parser" value="org.eclipse.persistence.platform.xml.jaxp.JAXPParser"/>
                                    <batchtest todir="${report.dir}/jaxb">
                                        <fileset dir="${src.dir}">
                                            <include name="org/eclipse/persistence/testing/jaxb/JAXBTestSuite.java"/>
                                            <include name="org/eclipse/persistence/testing/jaxb/JAXBTestSuite2.java"/>
                                            <include name="org/eclipse/persistence/testing/jaxb/JAXBTestSuite3.java"/>
                                            <include name="org/eclipse/persistence/testing/jaxb/JAXBTestSuite4.java"/>
                                            <include name="org/eclipse/persistence/testing/jaxb/JAXBBeanValidationTestSuite.java" />
                                            <include name="org/eclipse/persistence/testing/jaxb/beanvalidation/BeanValidationHelperTestCase.java"/>
                                            <include name="org/eclipse/persistence/testing/jaxb/listofobjects/JAXBListOfObjectsSuite.java"/>
                                            <include name="org/eclipse/persistence/testing/jaxb/annotations/AnnotationsTestSuite.java"/>
                                            <include
                                                name="org/eclipse/persistence/testing/jaxb/externalizedmetadata/ExternalizedMetadataTestSuite.java"/>
                                            <include
                                                name="org/eclipse/persistence/testing/jaxb/javadoc/JavadocAnnotationExamplesTestSuite.java"/>
                                            <include
                                                name="org/eclipse/persistence/testing/jaxb/typemappinginfo/TypeMappingInfoTestSuite.java"/>
                                            <include name="org/eclipse/persistence/testing/jaxb/schemagen/SchemaGenTestSuite.java"/>
                                            <include name="org/eclipse/persistence/testing/jaxb/xmladapter/XmlAdapterTestSuite.java"/>
                                            <include name="org/eclipse/persistence/testing/jaxb/dynamic/DynamicJAXBTestSuite.java"/>
                                            <include name="org/eclipse/persistence/testing/jaxb/json/JSONTestSuite.java"/>
                                            <include name="org/eclipse/persistence/testing/jaxb/rs/RESTfulTestSuite.java"/>
                                            <include name="org/eclipse/persistence/testing/moxy/unit/**/*TestCase.java"/>
                                            <include name="org/eclipse/persistence/testing/jaxb/annotations/xmlidref/XmlIdSystemPropertyNotSetTestCase.java"/>
                                            <include name="org/eclipse/persistence/testing/jaxb/annotations/xmlidref/XmlValueSystemPropertyNotSetTestCase.java"/>
                                            <include name="org/eclipse/persistence/testing/jaxb/annotations/xmlidref/XmlValueSystemPropertyTestCase.java"/>
                                        </fileset>
                                        <formatter type="xml"/>
                                    </batchtest>
                                </junit>

                                <junitreport todir="${report.dir}/jaxb">
                                    <fileset dir="${report.dir}/jaxb">
                                        <include name="**/*.xml"/>
                                    </fileset>
                                    <report todir="${report.dir}/jaxb"/>
                                </junitreport>

                                <fail message="TESTS FAILED !">
                                    <condition>
                                        <and>
                                            <isset property="junit.failed.jaxb"/>
                                            <istrue value="${test.fail.fast}"/>
                                        </and>
                                    </condition>
                                </fail>
                            </target>
                        </configuration>
                    </execution>
                </executions>
            </plugin>-->
        </plugins>
    </build>

    <profiles>
        <!--MOXy related profiles-->
        <profile>
            <id>test-srg</id>
            <properties>
                <test-skip-moxy-jaxb-srg>false</test-skip-moxy-jaxb-srg>
            </properties>
        </profile>
        <profile>
            <id>test-lrg</id>
            <properties>
                <test-skip-moxy-jaxb-srg>true</test-skip-moxy-jaxb-srg>
                <test-skip-moxy-jaxb>false</test-skip-moxy-jaxb>
            </properties>
        </profile>
        <profile>
            <id>test-moxy-srg</id>
            <properties>
                <test-skip-moxy-jaxb-srg>false</test-skip-moxy-jaxb-srg>
            </properties>
        </profile>
        <profile>
            <id>test-moxy-lrg</id>
            <properties>
                <test-skip-moxy-jaxb-srg>true</test-skip-moxy-jaxb-srg>
                <test-skip-moxy-jaxb>false</test-skip-moxy-jaxb>
            </properties>
        </profile>
        <profile>
            <id>test-moxy-jaxb-srg</id>
            <properties>
                <test-skip-moxy-jaxb-srg>false</test-skip-moxy-jaxb-srg>
            </properties>
        </profile>
        <profile>
            <id>test-moxy-jaxb</id>
            <properties>
                <test-skip-moxy-jaxb>false</test-skip-moxy-jaxb>
            </properties>
        </profile>
        <profile>
            <!-- excluded for codeql build -->
            <id>no-test-deps</id>
            <activation>
                <property>
                    <name>!notests</name>
                </property>
            </activation>
            <dependencies>
                <!--Test dependencies-->
                <!--Test framework-->
                <dependency>
                    <groupId>junit</groupId>
                    <artifactId>junit</artifactId>
                    <scope>test</scope>
                </dependency>
                <!--Other modules-->
                <dependency>
                    <groupId>org.eclipse.persistence</groupId>
                    <artifactId>org.eclipse.persistence.core</artifactId>
                    <type>test-jar</type>
                    <scope>test</scope>
                </dependency>
                <!--APIs and other libs used in test classes-->
                <dependency>
                    <groupId>com.sun.xml.bind</groupId>
                    <artifactId>jaxb-impl</artifactId>
                    <scope>test</scope>
                </dependency>
                <dependency>
                    <groupId>org.glassfish</groupId>
                    <artifactId>jakarta.el</artifactId>
                    <scope>test</scope>
                </dependency>
                <dependency>
                    <groupId>org.eclipse.parsson</groupId>
                    <artifactId>parsson</artifactId>
                    <scope>test</scope>
                </dependency>
                <dependency>
                    <groupId>org.glassfish.jersey.core</groupId>
                    <artifactId>jersey-common</artifactId>
                    <optional>true</optional>
                    <scope>test</scope>
                </dependency>
                <dependency>
                    <groupId>org.hibernate.validator</groupId>
                    <artifactId>hibernate-validator</artifactId>
                    <optional>true</optional>
                    <scope>test</scope>
                </dependency>
            </dependencies>
        </profile>
    </profiles>
</project>
