<?xml version="1.0"?>
<!--
  ~ Copyright (C) 2010-2022 Evolveum and contributors
  ~
  ~ This work is dual-licensed under the Apache License 2.0
  ~ and European Union Public License. See LICENSE file for details.
  -->

<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>
        <artifactId>infra</artifactId>
        <groupId>com.evolveum.midpoint.infra</groupId>
        <version>4.9.4</version>
    </parent>

    <artifactId>schema</artifactId>
    <packaging>jar</packaging>

    <name>midPoint Infrastructure - schema</name>

    <dependencies>
        <dependency>
            <groupId>com.evolveum.axiom</groupId>
            <artifactId>axiom</artifactId>
        </dependency>
        <dependency>
            <groupId>com.evolveum.prism</groupId>
            <artifactId>prism-api</artifactId>
        </dependency>
        <dependency>
            <groupId>com.evolveum.prism</groupId>
            <artifactId>prism-impl</artifactId>
        </dependency>
        <dependency>
            <groupId>com.evolveum.commons</groupId>
            <artifactId>util</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-beans</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
        </dependency>

        <dependency>
            <groupId>commons-beanutils</groupId>
            <artifactId>commons-beanutils</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-text</artifactId>
        </dependency>
        <dependency>
            <groupId>org.jetbrains</groupId>
            <artifactId>annotations</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-collections4</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-configuration2</artifactId>
        </dependency>

        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-classic</artifactId>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-annotations</artifactId>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-core</artifactId>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
        </dependency>


        <dependency>
            <groupId>jakarta.annotation</groupId>
            <artifactId>jakarta.annotation-api</artifactId>
        </dependency>

        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
        </dependency>
        <dependency>
            <groupId>com.github.inamik.text.tables</groupId>
            <artifactId>inamik-text-tables</artifactId>
        </dependency>

        <!--  Testing dependencies  -->
        <dependency>
            <groupId>org.testng</groupId>
            <artifactId>testng</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.evolveum.commons</groupId>
            <artifactId>test-ng</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.xmlunit</groupId>
            <artifactId>xmlunit-core</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.xmlunit</groupId>
            <artifactId>xmlunit-legacy</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <!-- Used to pull XSD files from the JAR -->
                <groupId>com.evolveum.prism.tools</groupId>
                <artifactId>schema-dist-maven-plugin</artifactId>
                <version>${prism.version}</version>
                <executions>
                    <execution>
                        <id>schemadist-prism</id>
                        <phase>initialize</phase>
                        <goals>
                            <goal>schemadist</goal>
                        </goals>
                        <configuration>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>com.evolveum.prism</groupId>
                                    <artifactId>prism-impl</artifactId>
                                    <version>${prism.version}</version>
                                    <type>jar</type>
                                </artifactItem>
                            </artifactItems>
                            <translateSchemaLocation>false</translateSchemaLocation>
                            <includes>**/*.xsd,**/*.dtd,**/*.wsdl</includes>
                            <outputDirectory>${project.basedir}/target/additional-schemas/prism-impl</outputDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>com.evolveum.prism</groupId>
                <artifactId>prism-maven-plugin</artifactId>
                <version>${prism.version}</version>
                <configuration>
                    <schemaFiles>
                        <schemaFile>src/main/resources/xml/ns/public/common/common-3.xsd</schemaFile>
                        <schemaFile>src/main/resources/xml/ns/public/common/api-types-3.xsd</schemaFile>
                        <schemaFile>target/additional-schemas/prism-impl/xml/ns/public/annotation-3.xsd</schemaFile>
                        <schemaFile>src/main/resources/xml/ns/public/prism-schema/prism-schema-3.xsd</schemaFile>
                        <schemaFile>src/main/resources/xml/ns/public/connector/icf-1/resource-schema-3.xsd</schemaFile>
                        <schemaFile>src/main/resources/xml/ns/public/model/scripting/scripting-3.xsd</schemaFile>
                        <!--
                        The following ones were not originally here. After fixing the schema parser in 4.9, they need to
                        be parsed as well, otherwise the parsing fails, as the references to them cannot be resolved.
                        TODO we should mark them somehow so that the docs for them won't be generated
                        -->
                        <schemaFile>src/main/resources/xml/ns/public/common/audit-3.xsd</schemaFile>
                        <schemaFile>src/main/resources/xml/ns/public/resource/capabilities-3.xsd</schemaFile>
                        <schemaFile>src/main/resources/xml/ns/public/connector/icf-1/connector-schema-3.xsd</schemaFile>
                    </schemaFiles>
                    <catalogFiles>
                        <catalogFile>src/compile/resources/jax-ws-catalog.xml</catalogFile>
                        <catalogFile>src/main/resources/META-INF/schemas-in-this-module.xml</catalogFile>   <!-- nextCatalog doesn't work for unknown reason -->
                    </catalogFiles>
                    <templateDir>src/main/schemadoc/templates</templateDir>
                </configuration>
                <executions>
                    <execution>
                        <id>schemadoc</id>
                        <phase>package</phase>
                        <goals>
                            <goal>schemadoc</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>com.evolveum.prism</groupId>
                <artifactId>prism-codegen-maven-plugin</artifactId>
                <version>${prism.version}</version>
                <configuration>
                    <schemaFiles>
                        <schemaFile>src/main/resources/xml/ns/public/common/common-3.xsd</schemaFile>
                        <schemaFile>src/main/resources/xml/ns/public/common/audit-3.xsd</schemaFile>
                        <schemaFile>src/main/resources/xml/ns/public/common/api-types-3.xsd</schemaFile>
                        <schemaFile>target/additional-schemas/prism-impl/xml/ns/public/annotation-3.xsd</schemaFile>
                        <schemaFile>src/main/resources/xml/ns/public/prism-schema/prism-schema-3.xsd</schemaFile>
                        <schemaFile>src/main/resources/xml/ns/public/resource/capabilities-3.xsd</schemaFile>
                        <schemaFile>src/main/resources/xml/ns/public/connector/icf-1/resource-schema-3.xsd</schemaFile>
                        <schemaFile>src/main/resources/xml/ns/public/connector/icf-1/connector-schema-3.xsd</schemaFile>
                        <schemaFile>src/main/resources/xml/ns/public/model/scripting/scripting-3.xsd</schemaFile>
                    </schemaFiles>
                    <wsdlFiles>
                        <wsdlFile>src/main/resources/xml/ns/public/common/fault-3.wsdl</wsdlFile>
                        <wsdlFile>src/main/resources/xml/ns/public/model/model-3.wsdl</wsdlFile>
                    </wsdlFiles>
                    <catalogFiles>
                        <catalogFile>src/compile/resources/jax-ws-catalog.xml</catalogFile>
                        <catalogFile>src/main/resources/META-INF/schemas-in-this-module.xml</catalogFile>   <!-- nextCatalog doesn't work for unknown reason -->
                    </catalogFiles>
                    <constants>
                        <constant>
                            <prefix>C</prefix>
                            <namespace>http://midpoint.evolveum.com/xml/ns/public/common/common-3</namespace>
                            <name>COMMON</name>
                        </constant>
                        <constant>
                            <prefix>T</prefix>
                            <namespace>http://prism.evolveum.com/xml/ns/public/types-3</namespace>
                            <name>TYPES</name>
                        </constant>
                        <constant>
                            <prefix>Q</prefix>
                            <namespace>http://prism.evolveum.com/xml/ns/public/query-3</namespace>
                            <name>QUERY</name>
                        </constant>
                        <constant>
                            <prefix>R_CAP</prefix>
                            <namespace>http://midpoint.evolveum.com/xml/ns/public/resource/capabilities-3</namespace>
                            <name>CAPABILITIES</name>
                        </constant>
                        <constant>
                            <prefix>A</prefix>
                            <namespace>http://prism.evolveum.com/xml/ns/public/annotation-3</namespace>
                            <name>ANNOTATION</name>
                        </constant>
                        <constant>
                            <prefix>S</prefix>
                            <namespace>http://midpoint.evolveum.com/xml/ns/public/model/situation-1.xsd</namespace>
                            <name>SITUATION</name>
                        </constant>
                        <constant>
                            <prefix>SC</prefix>
                            <namespace>http://midpoint.evolveum.com/xml/ns/public/model/scripting-3</namespace>
                            <name>SCRIPTING</name>
                        </constant>
                        <constant>
                            <prefix>ICF_S</prefix>
                            <namespace>http://midpoint.evolveum.com/xml/ns/public/connector/icf-1/resource-schema-3</namespace>
                            <name>ICF_SCHEMA</name>
                        </constant>
                        <constant>
                            <prefix>ICF_C</prefix>
                            <namespace>http://midpoint.evolveum.com/xml/ns/public/connector/icf-1/connector-schema-3</namespace>
                            <name>ICF_CONFIGURATION</name>
                        </constant>
                        <constant>
                            <prefix>ENC</prefix>
                            <namespace>http://www.w3.org/2001/04/xmlenc#</namespace>
                            <name>XML_ENC</name>
                        </constant>
                        <constant>
                            <prefix>DSIG</prefix>
                            <namespace>http://www.w3.org/2000/09/xmldsig#</namespace>
                            <name>XML_DSIG</name>
                        </constant>
                        <constant>
                            <prefix>XSD</prefix>
                            <namespace>http://www.w3.org/2001/XMLSchema</namespace>
                            <name>XSD</name>
                        </constant>
                        <constant>
                            <prefix>PRISMS</prefix>
                            <namespace>http://midpoint.evolveum.com/xml/ns/public/common/prism-schema</namespace>
                            <name>PRISM_SCHEMA</name>
                        </constant>
                    </constants>
                </configuration>
                <executions>
                    <execution>
                        <id>codegen</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>codegen</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>build-helper-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>add-sources</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>add-source</goal>
                        </goals>
                        <configuration>
                            <sources>
                                <source>target/generated-sources/prism</source>
                            </sources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
        <resources>
            <resource>
                <filtering>true</filtering>
                <directory>src/main/resources</directory>
                <includes>
                    <include>localization/**</include>
                </includes>
            </resource>
            <resource>
                <directory>src/main/resources</directory>
                <excludes>
                    <exclude>localization/**</exclude>
                </excludes>
            </resource>
            <resource>
                <directory>target/additional-schemas</directory>
            </resource>
        </resources>
    </build>

    <profiles>
        <profile>
            <id>perftest</id>
            <build>
                <plugins>
                    <plugin>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <configuration>
                            <skipTests>false</skipTests>
                            <systemPropertyVariables>
                                <mp.perf.report.prefix>target/PERF</mp.perf.report.prefix>
                            </systemPropertyVariables>
                            <suiteXmlFiles>
                                <suiteXmlFile>testng-perf.xml</suiteXmlFile>
                            </suiteXmlFiles>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
