<?xml version="1.0" encoding="UTF-8"?>
<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>

    <groupId>org.omnifaces</groupId>
    <artifactId>omnipersistence</artifactId>
    <version>0.22.J4</version>
    <packaging>jar</packaging>

    <name>OmniPersistence</name>
    <description>Utilities for JPA, JDBC and DataSources</description>
    <url>https://github.com/omnifaces/omnipersistence</url>
    <organization>
        <name>OmniFaces</name>
        <url>https://omnifaces.org</url>
    </organization>
    <inceptionYear>2015</inceptionYear>

    <developers>
        <developer>
            <id>balusc</id>
            <name>Bauke Scholtz</name>
            <email>balusc@gmail.com</email>
        </developer>
        <developer>
            <id>arjan.tijms</id>
            <name>Arjan Tijms</name>
            <email>arjan.tijms@gmail.com</email>
        </developer>
        <developer>
            <id>jan.beernink</id>
            <name>Jan Beernink</name>
            <email>jan.beernink@gmail.com</email>
        </developer>
    </developers>

    <licenses>
        <license>
            <name>The Apache Software License, Version 2.0</name>
            <url>https://www.apache.org/licenses/LICENSE-2.0.txt</url>
            <distribution>repo</distribution>
        </license>
    </licenses>

    <scm>
        <url>https://github.com/omnifaces/omnipersistence</url>
        <connection>scm:git:git://github.com/omnifaces/omnipersistence.git</connection>
        <developerConnection>scm:git:git@github.com:omnifaces/omnipersistence.git</developerConnection>
    </scm>

    <distributionManagement>
        <snapshotRepository>
            <id>ossrh</id>
            <url>https://oss.sonatype.org/content/repositories/snapshots</url>
        </snapshotRepository>
    </distributionManagement>

    <properties>

        <!-- Minimum required Java versions. -->
        <javase.version>17</javase.version>
        <jakartaee.version>10</jakartaee.version>

        <!-- Essential Maven defaults. -->
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <maven.compiler.release>${javase.version}</maven.compiler.release>
        <maven.source.excludeResources>true</maven.source.excludeResources>

        <!-- Test versions. -->
        <test.wildfly.version>33.0.1.Final</test.wildfly.version> <!-- https://mvnrepository.com/artifact/org.wildfly.bom/wildfly -->
        <test.glassfish.version>7.0.17</test.glassfish.version> <!-- https://mvnrepository.com/artifact/org.glassfish.main.distributions/glassfish -->
        <test.h2.version>1.4.200</test.h2.version> <!-- https://mvnrepository.com/artifact/com.h2database/h2 TODO: bump to 2.x once EclipseLink is compatible with it https://github.com/eclipse-ee4j/eclipselink/issues/1393 -->
    </properties>

    <dependencies>

        <!-- Jakarta EE 9 web profile dependencies. -->
        <dependency>
            <groupId>jakarta.platform</groupId>
            <artifactId>jakarta.jakartaee-web-api</artifactId>
            <version>${jakartaee.version}.0.0</version> <!-- minimum version for OmniFaces 4.0 -->
            <scope>provided</scope> <!-- by enduser (of course enduser can provide a newer version) -->
        </dependency>

        <!-- OmniFaces dependencies. -->
        <dependency>
            <groupId>org.omnifaces</groupId>
            <artifactId>omniutils</artifactId>
            <version>0.16</version>
        </dependency>

        <!-- Hibernate Metamodel generator. -->
        <dependency>
            <groupId>org.hibernate.orm</groupId>
            <artifactId>hibernate-jpamodelgen</artifactId>
            <version>6.6.0.Final</version>
            <scope>provided</scope>
        </dependency>

        <!-- Test dependencies.    -->
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter</artifactId>
            <version>5.11.0</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.jboss.arquillian.junit5</groupId>
            <artifactId>arquillian-junit5-container</artifactId>
            <version>1.8.0.Final</version> <!-- NOTE: 1.9.x is incompatible with arquillian-glassfish-server-managed 1.6 -->
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.jboss.shrinkwrap.resolver</groupId>
            <artifactId>shrinkwrap-resolver-impl-maven-archive</artifactId>
            <version>3.3.1</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>

            <!-- Prevent wrong JDK from being used to build the project. -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-enforcer-plugin</artifactId>
                <version>3.5.0</version>
                <executions>
                    <execution>
                        <phase>validate</phase>
                        <goals>
                            <goal>enforce</goal>
                        </goals>
                        <configuration>
                            <rules>
                                <requireJavaVersion>
                                    <version>[${javase.version},)</version>
                                </requireJavaVersion>
                            </rules>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <!-- Add missing license headers to source files. -->
            <plugin>
                <groupId>com.mycila</groupId>
                <artifactId>license-maven-plugin</artifactId>
                <version>4.5</version>
                <configuration>
                    <header>license.txt</header>
                    <excludes>
                        <exclude>*.*</exclude>
                    </excludes>
                    <mapping>
                        <java>SLASHSTAR_STYLE</java>
                    </mapping>
                </configuration>
                <executions>
                    <execution>
                        <phase>process-sources</phase>
                        <goals>
                            <goal>format</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <!-- Configure the compiler. -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.13.0</version>
            </plugin>

            <!-- Configure the jar with the binaries and test binaries. -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>3.4.2</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>test-jar</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <archive>
                        <manifest>
                            <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
                            <addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
                        </manifest>
                        <manifestEntries>
                            <URL>${project.url}</URL>
                            <Extension-Name>${project.artifactId}</Extension-Name>
                        </manifestEntries>
                    </archive>
                </configuration>
            </plugin>

            <!-- Configure the jar with the sources. -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-source-plugin</artifactId>
                <version>3.3.1</version>
                <executions>
                    <execution>
                        <id>attach-sources</id>
                        <goals>
                            <goal>jar-no-fork</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <!-- Configure the jar with the javadoc. -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <version>3.10.0</version>
                <configuration>
                    <javadocExecutable>${java.home}/bin/javadoc</javadocExecutable>
                    <javadocVersion>${javase.version}</javadocVersion>
                    <notimestamp>true</notimestamp>
                    <splitindex>true</splitindex>
                    <doclint>all,-missing</doclint>
                    <doctitle>OmniPersistence API documentation</doctitle>
                    <links>
                        <link>https://jakarta.ee/specifications/platform/${jakartaee.version}/apidocs/</link>
                    </links>
                </configuration>
                <executions>
                    <execution>
                        <id>attach-javadocs</id>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <!-- Configure snapshot deployment to Sonatype. -->
            <plugin>
                <groupId>org.sonatype.plugins</groupId>
                <artifactId>nexus-staging-maven-plugin</artifactId>
                <version>1.7.0</version>
                <extensions>true</extensions>
                <configuration>
                    <serverId>ossrh</serverId>
                    <nexusUrl>https://oss.sonatype.org/</nexusUrl>
                    <autoReleaseAfterClose>true</autoReleaseAfterClose>
                </configuration>
            </plugin>
        </plugins>

        <pluginManagement>
            <plugins>

                <!-- Make sure Eclipse itself also runs license format during build. -->
                <plugin>
                    <groupId>org.eclipse.m2e</groupId>
                    <artifactId>lifecycle-mapping</artifactId>
                    <version>1.0.0</version>
                    <configuration>
                        <lifecycleMappingMetadata>
                            <pluginExecutions>
                                <pluginExecution>
                                    <pluginExecutionFilter>
                                        <groupId>com.mycila</groupId>
                                        <artifactId>license-maven-plugin</artifactId>
                                        <versionRange>[4.4,)</versionRange>
                                        <goals>
                                            <goal>format</goal>
                                        </goals>
                                    </pluginExecutionFilter>
                                    <action>
                                        <execute>
                                            <runOnConfiguration>true</runOnConfiguration>
                                        </execute>
                                    </action>
                                </pluginExecution>
                            </pluginExecutions>
                        </lifecycleMappingMetadata>
                    </configuration>
                </plugin>

                <!-- Global configuration for test profiles. -->
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-dependency-plugin</artifactId>
                    <version>3.8.0</version>
                    <executions>
                        <execution>
                            <phase>process-test-classes</phase>
                            <goals>
                                <goal>unpack</goal>
                            </goals>
                        </execution>
                    </executions>
                    <configuration>
                        <outputDirectory>${project.build.directory}</outputDirectory>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <version>3.5.0</version>
                    <configuration>
                        <trimStackTrace>false</trimStackTrace>
                        <systemPropertyVariables>
                            <profile.id>${project.activeProfiles[0].id}</profile.id>
                            <test.h2.version>${test.h2.version}</test.h2.version>
                        </systemPropertyVariables>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>

    <profiles>
        <!-- NOTE: If Eclipse+M2E shows "Plugin execution not covered by lifecycle configuration" error in one of -->
        <!-- below sections, then you need to add a default lifecycle mapping as instructed in M2E documentation: -->
        <!-- https://www.eclipse.org/m2e/documentation/m2e-execution-not-covered.html#common-problems -->

        <!-- WildFly/Hibernate test profile: mvn verify -P wildfly-hibernate -->
        <profile>
            <id>wildfly-hibernate</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <dependencies>
                <dependency>
                    <groupId>org.wildfly.arquillian</groupId>
                    <artifactId>wildfly-arquillian-container-managed</artifactId>
                    <version>5.0.1.Final</version>
                    <scope>test</scope>
                </dependency>
            </dependencies>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-dependency-plugin</artifactId>
                        <executions>
                            <execution>
                                <configuration>
                                    <artifactItems>
                                        <artifactItem>
                                            <groupId>org.wildfly</groupId>
                                            <artifactId>wildfly-preview-dist</artifactId>
                                            <version>${test.wildfly.version}</version>
                                            <type>zip</type>
                                        </artifactItem>
                                    </artifactItems>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <configuration>
                            <systemPropertyVariables>
                                <jboss.home>${project.build.directory}/wildfly-preview-${test.wildfly.version}</jboss.home>
                            </systemPropertyVariables>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <!-- GlassFish/EclipseLink test profile: mvn verify -P glassfish-eclipselink -->
        <profile>
            <id>glassfish-eclipselink</id>
            <dependencies>
                <dependency>
                    <groupId>org.omnifaces.arquillian</groupId>
                    <artifactId>arquillian-glassfish-server-managed</artifactId>
                    <version>1.6</version>
                    <scope>test</scope>
                </dependency>
            </dependencies>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-dependency-plugin</artifactId>
                        <executions>
                            <execution>
                                <configuration>
                                    <artifactItems>
                                        <artifactItem>
                                            <groupId>org.glassfish.main.distributions</groupId>
                                            <artifactId>glassfish</artifactId>
                                            <version>${test.glassfish.version}</version>
                                            <type>zip</type>
                                        </artifactItem>
                                    </artifactItems>
                                </configuration>
                            </execution>
                            <execution>
                                <id>install-h2-in-glassfish</id>
                                <phase>process-test-classes</phase>
                                <goals>
                                    <goal>copy</goal>
                                </goals>
                                <configuration>
                                    <artifactItems>
                                        <artifactItem>
                                            <groupId>com.h2database</groupId>
                                            <artifactId>h2</artifactId>
                                            <version>${test.h2.version}</version>
                                            <type>jar</type>
                                            <outputDirectory>${project.build.directory}/glassfish7/glassfish/modules</outputDirectory>
                                        </artifactItem>
                                    </artifactItems>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <configuration>
                            <systemPropertyVariables>
                                <glassfish.home>${project.build.directory}/glassfish7</glassfish.home>
                            </systemPropertyVariables>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <!-- Release deploy: mvn clean deploy -P release -->
        <profile>
            <id>release</id>
            <build>
                <plugins>

                    <!-- Signing with GPG is a requirement for a release deployment to Maven central. -->
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-gpg-plugin</artifactId>
                        <version>3.0.1</version>
                        <executions>
                            <execution>
                                <id>sign-artifacts</id>
                                <phase>verify</phase>
                                <goals>
                                    <goal>sign</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

</project>