<?xml version="1.0"?>
<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>
    <parent>
        <groupId>org.hibernate.search</groupId>
        <artifactId>hibernate-search-parent-public</artifactId>
        <version>6.0.10.Final</version>
        <relativePath>../../parents/public</relativePath>
    </parent>
    <artifactId>hibernate-search-mapper-orm</artifactId>

    <name>Hibernate Search ORM Integration</name>
    <description>Hibernate Search integration to Hibernate ORM</description>

    <properties>
        <java.module.name>org.hibernate.search.mapper.orm</java.module.name>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.hibernate.search</groupId>
            <artifactId>hibernate-search-engine</artifactId>
        </dependency>
        <dependency>
            <groupId>org.hibernate.search</groupId>
            <artifactId>hibernate-search-mapper-pojo-base</artifactId>
        </dependency>
        <dependency>
            <groupId>org.hibernate.search</groupId>
            <artifactId>hibernate-search-util-common</artifactId>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core</artifactId>
        </dependency>
        <dependency>
            <groupId>javax.persistence</groupId>
            <artifactId>javax.persistence-api</artifactId>
        </dependency>
        <dependency>
            <groupId>javax.enterprise</groupId>
            <artifactId>cdi-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.hibernate.common</groupId>
            <artifactId>hibernate-commons-annotations</artifactId>
        </dependency>
        <dependency>
            <groupId>org.jboss.logging</groupId>
            <artifactId>jboss-logging</artifactId>
        </dependency>
        <dependency>
            <groupId>org.jboss.logging</groupId>
            <artifactId>jboss-logging-annotations</artifactId>
        </dependency>

        <dependency>
            <groupId>org.hibernate.search</groupId>
            <artifactId>hibernate-search-util-internal-test</artifactId>
            <scope>test</scope>
            <exclusions>
                <!-- Bytebuddy is already imported by Hibernate ORM with a different version -->
                <exclusion>
                    <groupId>net.bytebuddy</groupId>
                    <artifactId>byte-buddy</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
    </dependencies>

    <profiles>
        <profile>
            <id>module-descriptors</id>
            <!--
                TODO HSEARCH-3274
                Trying to generate module info, we got some issues on multi-release dependent modules.

                Invocation of jdeps failed: jdeps -generate-module-info ...
                Error: byte-buddy-1.9.5.jar is a multi-release jar file but -multi-release option is not set.

                Sometimes the error is about jaxb-api-2.3.1.jar.

                Adding this to the moditect configuration removes the message:

                <jdepsExtraArgs>- -multi-release=11</jdepsExtraArgs>

                ... but then we get another error:

                Invocation of jdeps failed: jdeps -generate-module-info ...
                Error: hibernate-search-mapper-orm-6.0.0-SNAPSHOT.jar is not a multi-release jar file but - -multi-release option is set

                So adding - -multi-release=11 probably isn't a good idea.
                Maybe a better solution would be to exclude these dependencies from the scanning,
                since we do not need to expose them anyway?
             -->
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.moditect</groupId>
                        <artifactId>moditect-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>add-module-infos</id>
                                <!-- Disable the plugin, see above -->
                                <phase>none</phase>
                                <goals>
                                    <goal>add-module-info</goal>
                                </goals>
                                <configuration>
                                    <module>
                                        <moduleInfo>
                                            <name>${java.module.name}</name>
                                            <exports>
                                                !org.hibernate.search.*.impl;
                                                !org.hibernate.search.*.impl.*;
                                                *;
                                            </exports>
                                            <requires>
                                                !net.bytebuddy;
                                                !net.bytebuddy.*;
                                                !javax.xml;
                                                !javax.xml.*;
                                                !javax.*;
                                                *;
                                            </requires>
                                        </moduleInfo>
                                    </module>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
