<?xml version="1.0"?>
<!--
  ~ Copyright (c) 2010-2017 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 http://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.1</version>
    </parent>

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

    <name>midPoint Infrastructure - schema</name>

    <dependencies>
        <dependency>
            <groupId>com.evolveum.midpoint.infra</groupId>
            <artifactId>prism-api</artifactId>
            <version>4.1</version>
            <exclusions>
                <exclusion>
                    <groupId>javax.activation</groupId>
                    <artifactId>activation</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>javax.xml.bind</groupId>
                    <artifactId>jaxb-api</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>com.evolveum.midpoint.infra</groupId>
            <artifactId>prism-impl</artifactId>
            <version>4.1</version>
            <exclusions>
                <exclusion>
                    <groupId>com.sun.activation</groupId>
                    <artifactId>javax.activation</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>javax.xml.bind</groupId>
                    <artifactId>jaxb-api</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>com.evolveum.midpoint.infra</groupId>
            <artifactId>util</artifactId>
            <version>4.1</version>
            <exclusions>
                <exclusion>
                    <groupId>javax.activation</groupId>
                    <artifactId>activation</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>javax.xml.bind</groupId>
                    <artifactId>jaxb-api</artifactId>
                </exclusion>
            </exclusions>
        </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-collections</groupId>
            <artifactId>commons-collections</artifactId>
        </dependency>
        <dependency>
            <groupId>commons-lang</groupId>
            <artifactId>commons-lang</artifactId>
        </dependency>
        <dependency>
            <groupId>commons-codec</groupId>
            <artifactId>commons-codec</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.cxf.xjc-utils</groupId>
            <artifactId>cxf-xjc-runtime</artifactId>
        </dependency>
        <dependency>
            <groupId>com.sun.xml.bind</groupId>
            <artifactId>jaxb-xjc</artifactId>
        </dependency>
        <dependency>
            <groupId>net.sf.jasperreports</groupId>
            <artifactId>jasperreports</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.jvnet.jaxb2_commons</groupId>
            <artifactId>jaxb2-basics-runtime</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>javax.xml.ws</groupId>
            <artifactId>jaxws-api</artifactId>
        </dependency>
        <dependency>
            <groupId>javax.annotation</groupId>
            <artifactId>javax.annotation-api</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.geronimo.specs</groupId>
            <artifactId>geronimo-ws-metadata_2.0_spec</artifactId>
        </dependency>

        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
        </dependency>
        <!--  Testing dependencies  -->
        <dependency>
            <groupId>org.testng</groupId>
            <artifactId>testng</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.evolveum.midpoint.tools</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.midpoint.tools</groupId>
                <artifactId>schema-dist-maven-plugin</artifactId>
                <version>${project.version}</version>
                <executions>
                    <execution>
                        <id>schemadist-prism</id>
                        <phase>initialize</phase>
                        <goals>
                            <goal>schemadist</goal>
                        </goals>
                        <configuration>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>com.evolveum.midpoint.infra</groupId>
                                    <artifactId>prism-impl</artifactId>
                                    <version>${project.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>org.apache.cxf</groupId>
                <artifactId>cxf-codegen-plugin</artifactId>
                <version>${cxf.version}</version>
                <executions>
                    <execution>
                        <id>generate-sources</id>
                        <phase>generate-sources</phase>
                        <configuration>
                            <sourceRoot>${project.build.directory}/generated/cxf</sourceRoot>
                            <wsdlRoot>${project.directory}/src/main/resources/xml</wsdlRoot>
                            <wsdlOptions>
                                <wsdlOption>
                                    <wsdl>src/main/resources/xml/ns/private/webservice/modelService.wsdl</wsdl>
                                    <catalog>${basedir}/src/compile/resources/jax-ws-catalog.xml</catalog>
                                    <extraargs>
                                        <extraarg>-impl</extraarg>
                                        <extraarg>-verbose</extraarg>
                                        <!--<extraarg>-validate</extraarg> ERROR: Property 'http://javax.xml.XMLConstants/property/accessExternalSchema' is not recognized. -->
                                        <extraarg>-xjc-Xts</extraarg>
                                        <extraarg>-xjc-XhashCode</extraarg>
                                        <extraarg>
                                            -xjc-XhashCode-hashCodeStrategyClass=com.evolveum.midpoint.util.xml.DomAwareHashCodeStrategy
                                        </extraarg>
                                        <extraarg>-xjc-Xequals</extraarg>
                                        <extraarg>
                                            -xjc-Xequals-equalsStrategyClass=com.evolveum.midpoint.util.xml.DomAwareEqualsStrategy
                                        </extraarg>
                                        <extraarg>-nexclude</extraarg>
                                        <extraarg>http://prism.evolveum.com/xml/ns/public/types-3</extraarg>
                                        <extraarg>-nexclude</extraarg>
                                        <extraarg>http://prism.evolveum.com/xml/ns/public/annotation-3</extraarg>
                                        <extraarg>-nexclude</extraarg>
                                        <extraarg>http://prism.evolveum.com/xml/ns/public/query-3</extraarg>
                                        <!--                                         <extraargs>-version</extraargs> -->
                                        <extraarg>-xjc-Xmidpoint</extraarg>
                                    </extraargs>
                                </wsdlOption>
                                <wsdlOption>
                                    <!-- Besides generating stub for report web service, this WSDL includes all the other XSD files
                                         we need to compile. This is the only way we found to generate equals and hashCode methods with CXF.
                                         If you find anything better please correct it.

                                         It would be nice if these two web services could be in one WSDL file. Unfortunately it's not possible,
                                         as they are in different target namespaces. -->
                                    <wsdl>src/main/resources/xml/ns/private/webservice/reportService.wsdl</wsdl>
                                    <catalog>${basedir}/src/compile/resources/jax-ws-catalog.xml</catalog>
                                    <extraargs>
                                        <extraarg>-impl</extraarg>
                                        <extraarg>-verbose</extraarg>
                                        <!--<extraarg>-validate</extraarg> ERROR: Property 'http://javax.xml.XMLConstants/property/accessExternalSchema' is not recognized. -->
                                        <extraarg>-xjc-Xts</extraarg>
                                        <extraarg>-xjc-XhashCode</extraarg>
                                        <extraarg>
                                            -xjc-XhashCode-hashCodeStrategyClass=com.evolveum.midpoint.util.xml.DomAwareHashCodeStrategy
                                        </extraarg>
                                        <extraarg>-xjc-Xequals</extraarg>
                                        <extraarg>
                                            -xjc-Xequals-equalsStrategyClass=com.evolveum.midpoint.util.xml.DomAwareEqualsStrategy
                                        </extraarg>
                                        <extraarg>-nexclude</extraarg>
                                        <extraarg>http://prism.evolveum.com/xml/ns/public/types-3</extraarg>
                                        <extraarg>-nexclude</extraarg>
                                        <extraarg>http://prism.evolveum.com/xml/ns/public/annotation-3</extraarg>
                                        <extraarg>-nexclude</extraarg>
                                        <extraarg>http://prism.evolveum.com/xml/ns/public/query-3</extraarg>
                                        <!--                                         <extraargs>-version</extraargs> -->
                                        <extraarg>-xjc-Xmidpoint</extraarg>
                                    </extraargs>
                                </wsdlOption>
                            </wsdlOptions>
                        </configuration>
                        <goals>
                            <goal>wsdl2java</goal>
                        </goals>
                    </execution>
                </executions>
                <dependencies>
                    <dependency>
                        <groupId>org.apache.cxf.xjcplugins</groupId>
                        <artifactId>cxf-xjc-ts</artifactId>
                        <version>${cxf-xjc.version}</version>
                    </dependency>
                    <dependency>
                        <groupId>org.jvnet.jaxb2_commons</groupId>
                        <artifactId>jaxb2-basics</artifactId>
                        <version>0.6.3</version>
                    </dependency>
                    <dependency>
                        <groupId>com.evolveum.midpoint.tools</groupId>
                        <artifactId>xjc-plugin</artifactId>
                        <version>4.1</version>
                    </dependency>
                    <dependency>
                        <groupId>com.sun.xml.bind</groupId>
                        <artifactId>jaxb-xjc</artifactId>
                        <version>${jaxb-xjc.version}</version>
                    </dependency>
                </dependencies>
            </plugin>
            <plugin>
                <groupId>com.evolveum.midpoint.infra</groupId>
                <artifactId>prism-maven-plugin</artifactId>
                <version>4.1</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>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>
                    </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>
        </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>
</project>

