<?xml version="1.0" encoding="UTF-8"?>
<!--
 ~ Hibernate Search, full-text search for your domain model
 ~
 ~ License: GNU Lesser General Public License (LGPL), version 2.1 or later
 ~ See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
  -->
<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/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.hibernate.search</groupId>
        <artifactId>hibernate-search-parent</artifactId>
        <version>6.2.1.Final</version>
        <relativePath>../../..</relativePath>
    </parent>
    <artifactId>hibernate-search-parent-public</artifactId>
    <packaging>pom</packaging>

    <name>Hibernate Search Parent POM for Public Artifacts</name>
    <description>Common build configuration for all public artifacts</description>

    <properties>
        <javadoc.packagelists.directory>${project.build.directory}/dependencies-javadoc-packagelists</javadoc.packagelists.directory>
        <documentation.config.properties.skip>false</documentation.config.properties.skip>
    </properties>

    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-jar-plugin</artifactId>
                    <configuration>
                        <archive>
                            <manifestEntries>
                                <Implementation-Title>${project.name}</Implementation-Title>
                                <Implementation-Version>${project.version}</Implementation-Version>
                                <Implementation-Vendor>hibernate.org</Implementation-Vendor>
                                <Implementation-Vendor-Id>hibernate.org</Implementation-Vendor-Id>
                                <Implementation-URL>http://hibernate.org/search/</Implementation-URL>
                                <Automatic-Module-Name>${java.module.name}</Automatic-Module-Name>
                            </manifestEntries>
                        </archive>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-javadoc-plugin</artifactId>
                    <version>${version.javadoc.plugin}</version>
                    <configuration>
                        <!-- Fail on error alternative -->
                        <quiet>true</quiet>
                        <verbose>false</verbose>
                        <failOnWarnings>true</failOnWarnings>
                        <failOnError>true</failOnError>
                        <release>${maven.compiler.release}</release>
                        <!-- Exclude implementation classes from the javadoc -->
                        <excludePackageNames>*.impl,*.impl.*</excludePackageNames>
                        <!--
                            Make sure to always use offline links,
                            otherwise the build will need to access external websites,
                            which leads to build failures from time to time when the websites are not available
                            (used to happen a lot with apache.org in particular).
                            maven-javadoc-plugin needs a package-list file to determine,
                            for each package/class, the most appropriate link.
                            These files are fetched from javadoc Maven artifacts
                            in the build-config module and regrouped in a single ZIP
                            (see maven-assembly-plugin config in the build-config POM)
                            which is then extracted to target/ in each module that needs to generate javadoc
                            (see maven-dependency-plugin config in this POM).
                          -->
                        <offlineLinks>
                            <offlineLink>
                                <url>${javadoc.org.hibernate.url}</url>
                                <location>${javadoc.packagelists.directory}/hibernate-core</location>
                            </offlineLink>
                            <offlineLink>
                                <url>${javadoc.org.apache.lucene.core.url}</url>
                                <location>${javadoc.packagelists.directory}/lucene-core</location>
                            </offlineLink>
                            <offlineLink>
                                <url>${javadoc.org.apache.lucene.analyzers-common.url}</url>
                                <location>${javadoc.packagelists.directory}/lucene-analyzers-common</location>
                            </offlineLink>
                            <offlineLink>
                                <url>${javadoc.org.apache.lucene.queryparser.url}</url>
                                <location>${javadoc.packagelists.directory}/lucene-queryparser</location>
                            </offlineLink>
                            <!-- For javax.batch in the JSR 352 modules -->
                            <offlineLink>
                                <url>${javadoc.javaee.url}</url>
                                <location>${javadoc.packagelists.directory}/batch-api</location>
                            </offlineLink>
                            <!-- For jakarta.batch in the JSR 352 modules -->
                            <offlineLink>
                                <url>${javadoc.jakarta.batch.url}</url>
                                <location>${javadoc.packagelists.directory}/batch-api</location>
                            </offlineLink>
                        </offlineLinks>
                        <bottom>
                            <![CDATA[Copyright &copy; ${project.inceptionYear}-{currentYear} <a href="https://www.redhat.com/">Red Hat, Inc.</a> and others. Licensed under the GNU Lesser General Public License (LGPL), version 2.1 or later.]]>
                        </bottom>
                        <additionalDependencies>
                            <additionalDependency>
                                <groupId>org.jboss.logging</groupId>
                                <artifactId>jboss-logging-annotations</artifactId>
                                <version>${version.org.jboss.logging.jboss-logging-tools}</version>
                            </additionalDependency>
                        </additionalDependencies>
                        <tags>
                            <tag>
                                <name>hsearch.experimental</name>
                                <placement>a</placement>
                                <head>Experimental</head>
                            </tag>
                        </tags>
                        <additionalOptions>
                            <!-- Java 9+ supports HTML5 for javadoc generation -->
                            <additionalOption>-html5</additionalOption>
                            <!-- Java 17+ adds a warning for every single class/method/etc. without a javadoc comment,
                                 and we have lots of those.
                                 The only way to disable those warnings is to disable the group of checks "missing",
                                 and unfortunately this also disables checks such as "no @return" or "missing @param".
                                 I've looked into the javadoc code and there doesn't seem to be a more precise setting.
                                 See https://github.com/openjdk/jdk/blob/9862cd07c162fcc9cd5cbdd0aab564f446f9256c/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlOptions.java#L428-L439
                                 See https://github.com/openjdk/jdk/blob/9862cd07c162fcc9cd5cbdd0aab564f446f9256c/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclint/DocLint.java#L367
                                 See https://github.com/openjdk/jdk/blob/9862cd07c162fcc9cd5cbdd0aab564f446f9256c/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclint/Messages.java#L181-L182
                                 See https://github.com/openjdk/jdk/blob/9862cd07c162fcc9cd5cbdd0aab564f446f9256c/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclint/Messages.java#L74-L78
                                  -->
                            <additionalOption>-Xdoclint:all,-missing</additionalOption>
                        </additionalOptions>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-checkstyle-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>net.revelc.code</groupId>
                <artifactId>impsort-maven-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>net.revelc.code.formatter</groupId>
                <artifactId>formatter-maven-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-source-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.moditect</groupId>
                <artifactId>moditect-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>add-module-infos</id>
                        <phase>package</phase>
                        <goals>
                            <goal>add-module-info</goal>
                        </goals>
                        <configuration>
                            <jvmVersion>9</jvmVersion>
                            <module>
                                <moduleInfo>
                                    <name>${java.module.name}</name>
                                    <!-- Exports:
                                             - some impl packages to org.jboss.logging so that it can instantiate
                                               the generated Log/Messages classes
                                             - all impl packages to org.hibernate.engine so that it can instantiate built-in
                                               beans using reflection (e.g. annotation processors, bridges, binders)
                                             - all non-impl (api, spi) packages to everyone
                                     -->
                                    <exports>
                                        org.hibernate.search.*.logging.impl to org.jboss.logging, org.hibernate.search.engine;
                                        org.hibernate.search.*.reporting.impl to org.jboss.logging, org.hibernate.search.engine;
                                        org.hibernate.search.*.impl to org.hibernate.search.engine;
                                        *;
                                    </exports>
                                    <!-- Requires:
                                             - impl/internal Hibernate ORM and Hibernate Search packages are required non-transitively
                                             - all other Hibernate ORM and Hibernate Search packages are required transitively
                                             - all other packages are required non-transitively
                                     -->
                                    <requires>
                                        org.hibernate.*.impl;
                                        org.hibernate.*.internal;
                                        org.hibernate.*.impl.*;
                                        org.hibernate.*.internal.*;
                                        transitive org.hibernate.*;
                                        *;
                                    </requires>
                                </moduleInfo>
                            </module>
                            <jdepsExtraArgs>
                                <arg>--multi-release=9</arg>
                            </jdepsExtraArgs>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>dist</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-dependency-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>unpack-dependencies-javadoc-packagelists</id>
                                <phase>${javadoc.download.phase}</phase>
                                <goals>
                                    <goal>unpack</goal>
                                </goals>
                                <configuration>
                                    <skip>${javadoc.download.phase}</skip>
                                    <artifactItems>
                                        <artifactItem>
                                            <groupId>${project.groupId}</groupId>
                                            <artifactId>hibernate-search-build-config</artifactId>
                                            <classifier>dependencies-javadoc-packagelists</classifier>
                                            <type>zip</type>
                                            <version>${project.version}</version>
                                        </artifactItem>
                                    </artifactItems>
                                    <outputDirectory>${javadoc.packagelists.directory}</outputDirectory>
                                    <overWriteSnapshots>true</overWriteSnapshots>
                                </configuration>
                            </execution>
                        </executions>
                        <dependencies>
                            <!--
                                This ensures that using mvn install -pl <some project> -am
                                will correctly force the build of the build-config module.
                             -->
                            <dependency>
                                <groupId>${project.groupId}</groupId>
                                <artifactId>hibernate-search-build-config</artifactId>
                                <classifier>dependencies-javadoc-packagelists</classifier>
                                <type>zip</type>
                                <version>${project.version}</version>
                            </dependency>
                        </dependencies>
                    </plugin>
                    <plugin>
                        <artifactId>maven-javadoc-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>generate-javadoc</id>
                                <goals>
                                    <goal>javadoc-no-fork</goal>
                                </goals>
                                <phase>process-resources</phase>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>exec-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>collect-configuration-properties</id>
                                <goals>
                                    <goal>java</goal>
                                </goals>
                                <phase>${documentation.config.properties.phase}</phase>
                                <configuration>
                                    <skip>${documentation.config.properties.skip}</skip>
                                    <mainClass>org.hibernate.search.configuration.properties.collector.impl.ConfigurationPropertyProcessor</mainClass>
                                    <executableDependency>
                                        <groupId>org.hibernate.search</groupId>
                                        <artifactId>hibernate-search-configuration-properties-collector</artifactId>
                                    </executableDependency>
                                    <arguments>
                                        <argument>${javadoc.org.hibernate.search.url}</argument>
                                        <argument>${project.build.directory}</argument>
                                        <argument>${documentation.config.properties.output.directory}</argument>
                                        <argument>${project.artifactId}</argument>
                                        <argument>${project.name}</argument>
                                    </arguments>
                                    <includePluginDependencies>true</includePluginDependencies>
                                </configuration>
                            </execution>
                        </executions>
                        <dependencies>
                            <dependency>
                                <groupId>org.hibernate.search</groupId>
                                <artifactId>hibernate-search-configuration-properties-collector</artifactId>
                                <version>${project.version}</version>
                            </dependency>
                        </dependencies>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>jqassistant</id>
            <build>
                <plugins>
                    <!--
                         This is the last module: we want to execute analysis here so as to fail the build if anything is wrong.
                         Reminder: jqassistant only executes analysis in the last module of the build,
                         so if we skip it in the last module, it just won't execute analysis... ever.
                     -->
                    <plugin>
                        <groupId>com.buschmais.jqassistant</groupId>
                        <artifactId>jqassistant-maven-plugin</artifactId>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>release</id>
            <activation>
                <property>
                    <name>performRelease</name>
                    <value>true</value>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-gpg-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>sign-artifacts</id>
                                <phase>verify</phase>
                                <goals>
                                    <goal>sign</goal>
                                </goals>
                                <configuration>
                                    <homedir>${env.RELEASE_GPG_HOMEDIR}</homedir>
                                    <passphrase>${env.RELEASE_GPG_PASSPHRASE}</passphrase>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
