<?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>
    <name>java-util</name>
    <groupId>com.cedarsoftware</groupId>
    <artifactId>java-util</artifactId>
    <packaging>bundle</packaging>
    <version>4.115.0</version>
    <description>Java Utilities</description>
    <url>https://github.com/jdereg/java-util</url>

    <developers>
        <developer>
            <id>jdereg</id>
            <name>John DeRegnaucourt</name>
            <email>jdereg@gmail.com</email>
        </developer>
        <developer>
            <id>kpartlow</id>
            <name>Kenny Partlow</name>
            <email>kpartlow@gmail.com</email>
        </developer>
    </developers>

    <properties>
        <maven.build.timestamp.format>yyyy-MM-dd'T'HH:mm:ss.SSSZ</maven.build.timestamp.format>
        <!-- remove source encoding warnings from maven output -->
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

        <!-- testing only -->
        <version.junit-jupiter-api>5.14.4</version.junit-jupiter-api>
        <version.junit-jupiter-params>5.14.4</version.junit-jupiter-params>   <!-- JUnit 6 requires Java 17; this project compiles release 8 -->
        <version.mockito-junit-jupiter>4.11.0</version.mockito-junit-jupiter>   <!-- can't update until they have JDK support -->
        <version.assertj-core>3.27.7</version.assertj-core>   <!-- 4.0.0-M1 is a milestone, not a release; stay on 3.x -->
        <version.felix-framework>7.0.5</version.felix-framework>   <!-- OSGi framework for OsgiBundleIT only -->
        <version.json-io>4.114.0</version.json-io>
        <version.agrona>1.22.0</version.agrona> <!-- last agrona compiled for Java 8 (class file 52): 1.23.0+ ships Java 17 bytecode (61) and fails on a JDK 8 test run. Do not increase until abandoning JDK 8 support -->
        <version.commons-collections4>4.6.0</version.commons-collections4>
        <version.guava>33.7.1-jre</version.guava>

        <!-- Build maven-***-plugins -->
        <version.maven-jar-plugin>3.5.1</version.maven-jar-plugin>
        <version.maven-gpg-plugin>3.2.8</version.maven-gpg-plugin>
        <version.maven-compiler-plugin>3.15.0</version.maven-compiler-plugin>
        <version.maven-javadoc-plugin>3.12.0</version.maven-javadoc-plugin>
        <version.maven-surefire-plugin>3.5.6</version.maven-surefire-plugin>
        <version.maven-failsafe-plugin>3.5.6</version.maven-failsafe-plugin>
        <version.maven-enforcer-plugin>3.6.2</version.maven-enforcer-plugin>
        <version.maven-source-plugin>3.4.0</version.maven-source-plugin>
        <version.maven-scr-plugin>1.26.4</version.maven-scr-plugin>
        <version.maven-bundle-plugin>6.2.0</version.maven-bundle-plugin>
        <version.maven-resources-plugin>3.5.0</version.maven-resources-plugin>
        <version.maven-install-plugin>3.1.4</version.maven-install-plugin>
        <version.maven-deploy-plugin>3.1.4</version.maven-deploy-plugin>
        <version.moditect-maven-plugin>1.3.0.Final</version.moditect-maven-plugin>

        <!-- release to Maven Central via Sonatype Nexus -->
        <version.central-publishing-maven-plugin>0.11.0</version.central-publishing-maven-plugin>
        <version.jacoco-maven-plugin>0.8.15</version.jacoco-maven-plugin>

    </properties>

    <profiles>

        <!-- JDK 9 and newer -->
        <profile>
            <id>jdk9-and-above</id>
            <activation>
                <jdk>[9,)</jdk>
            </activation>

            <!-- only the flags that modern javac needs -->
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-compiler-plugin</artifactId>
                        <version>${version.maven-compiler-plugin}</version>
                        <configuration>
                            <release>8</release>
                            <testRelease>8</testRelease>
                            <encoding>${project.build.sourceEncoding}</encoding>
                            <parameters>true</parameters>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <!-- JDK 21 and newer: the classes in src/main/java21, compiled for JDK 21 into META-INF/versions/21 of the
             (multi-release) jar, where only JDK 21+ looks. Build releases on JDK 21+, or the jar lacks them. -->
        <profile>
            <id>jdk21-and-above</id>
            <activation>
                <jdk>[21,)</jdk>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-compiler-plugin</artifactId>
                        <version>${version.maven-compiler-plugin}</version>
                        <executions>
                            <execution>
                                <id>compile-java21</id>
                                <phase>compile</phase>
                                <goals>
                                    <goal>compile</goal>
                                </goals>
                                <configuration>
                                    <release>21</release>
                                    <compileSourceRoots>
                                        <compileSourceRoot>${project.basedir}/src/main/java21</compileSourceRoot>
                                    </compileSourceRoots>
                                    <multiReleaseOutput>true</multiReleaseOutput>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <!-- JDK 8 -->
        <profile>
            <id>jdk8</id>
            <activation>
                <jdk>1.8</jdk>
            </activation>

            <!-- classic - source / target for the legacy tool-chain -->
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-compiler-plugin</artifactId>
                        <version>${version.maven-compiler-plugin}</version>
                        <configuration>
                            <source>1.8</source>
                            <target>1.8</target>
                            <encoding>${project.build.sourceEncoding}</encoding>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <profile>
            <id>release-sign-artifacts</id>
            <activation>
                <property>
                    <name>performRelease</name>
                    <value>true</value>
                </property>
            </activation>
            <build>
                <plugins>

                    <!-- A release is built on JDK 21+: the jar carries a JDK 21 class (META-INF/versions/21, from
                         src/main/java21) that only a JDK 21+ build compiles. Built on JDK 8-20 the jar would still
                         run everywhere, but without it. -->
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-enforcer-plugin</artifactId>
                        <version>${version.maven-enforcer-plugin}</version>
                        <executions>
                            <execution>
                                <id>release-on-jdk21</id>
                                <goals>
                                    <goal>enforce</goal>
                                </goals>
                                <configuration>
                                    <rules>
                                        <requireJavaVersion>
                                            <version>[21,)</version>
                                            <message>Build releases on JDK 21+ (src/main/java21)</message>
                                        </requireJavaVersion>
                                    </rules>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>

                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-gpg-plugin</artifactId>
                        <version>${version.maven-gpg-plugin}</version>
                        <executions>
                            <execution>
                                <id>sign-artifacts</id>
                                <phase>verify</phase>
                                <goals>
                                    <goal>sign</goal>
                                </goals>
                                <configuration>
                                    <keyname>${gpg.keyname}</keyname>
                                    <passphrase>${gpg.passphrase}</passphrase>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>

                </plugins>
            </build>
        </profile>
    </profiles>

    <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/jdereg/java-util</url>
        <connection>scm:git:git://github.com/jdereg/java-util.git</connection>
        <developerConnection>scm:git:git@github.com:jdereg/java-util.git</developerConnection>
    </scm>

    <distributionManagement>
    </distributionManagement>

    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-resources-plugin</artifactId>
                    <version>${version.maven-resources-plugin}</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-install-plugin</artifactId>
                    <version>${version.maven-install-plugin}</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-deploy-plugin</artifactId>
                    <version>${version.maven-deploy-plugin}</version>
                </plugin>
            </plugins>
        </pluginManagement>
        <plugins>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>${version.maven-jar-plugin}</version> <!-- Use the latest version available -->
                <configuration>
                    <archive>
                        <manifestEntries>
                            <Implementation-Title>java-util</Implementation-Title>
                            <Implementation-Version>${project.version}</Implementation-Version>
                            <Implementation-Vendor-Id>com.cedarsoftware</Implementation-Vendor-Id>
                            <Implementation-URL>https://github.com/jdereg/java-util</Implementation-URL>
                            <Built-By>${user.name}</Built-By>
                            <Build-Timestamp>${maven.build.timestamp}</Build-Timestamp>
                            <Build-Jdk>${java.version} (${java.vendor} ${java.vm.version})</Build-Jdk>
                            <Build-OS>${os.name} ${os.arch} ${os.version}</Build-OS>
                        </manifestEntries>
                        <manifest>
                            <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
                        </manifest>
                    </archive>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.felix</groupId>
                <artifactId>maven-scr-plugin</artifactId>
                <version>${version.maven-scr-plugin}</version>
            </plugin>

            <plugin>
                <groupId>org.apache.felix</groupId>
                <artifactId>maven-bundle-plugin</artifactId>
                <version>${version.maven-bundle-plugin}</version>
                <extensions>true</extensions>
                <configuration>
                    <instructions>
                        <!-- internal: for json-io only, as the module descriptor's qualified export; a bundle
                             wires to it only by asking for friend=json-io (a mandatory attribute) -->
                        <Export-Package>
                            com.cedarsoftware.util,
                            com.cedarsoftware.util.cache,
                            com.cedarsoftware.util.convert,
                            com.cedarsoftware.util.geom,
                            com.cedarsoftware.util.internal;friend=json-io;mandatory:=friend
                        </Export-Package>
                        <!-- Unsafe looks these JDK internals up by name, and copes when they are absent: required,
                             they kept the bundle from resolving in any OSGi framework (none exports them) -->
                        <Import-Package>
                            jdk.internal.reflect;resolution:=optional,
                            sun.reflect;resolution:=optional,
                            sun.misc;resolution:=optional,
                            *
                        </Import-Package>
                        <DynamicImport-Package>*</DynamicImport-Package>
                    </instructions>
                </configuration>
                <executions>
                    <execution>
                        <id>bundle-manifest</id>
                        <goals>
                            <goal>
                                manifest
                            </goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-source-plugin</artifactId>
                <version>${version.maven-source-plugin}</version>
                <executions>
                    <execution>
                        <id>attach-sources</id>
                        <goals>
                            <goal>jar-no-fork</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <version>${version.maven-javadoc-plugin}</version>
                <configuration>
                    <additionalOptions>-Xdoclint:none</additionalOptions>
                    <additionalJOption>-Xdoclint:none</additionalJOption>
                    <!-- Register the JDK 9+ standard "API documentation" tags so the
                         javadoc tool doesn't warn "unknown tag" when source files use
                         @apiNote / @implSpec / @implNote. -->
                    <tags>
                        <tag>
                            <name>apiNote</name>
                            <placement>a</placement>
                            <head>API Note:</head>
                        </tag>
                        <tag>
                            <name>implSpec</name>
                            <placement>a</placement>
                            <head>Implementation Requirements:</head>
                        </tag>
                        <tag>
                            <name>implNote</name>
                            <placement>a</placement>
                            <head>Implementation Note:</head>
                        </tag>
                    </tags>
                </configuration>
                <executions>
                    <execution>
                        <id>attach-javadocs</id>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.sonatype.central</groupId>
                <artifactId>central-publishing-maven-plugin</artifactId>
                <version>${version.central-publishing-maven-plugin}</version>
                <extensions>true</extensions>
                <configuration>
                    <publishingServerId>central</publishingServerId>
                    <!--
                    <autoPublish>true</autoPublish>
                    <waitUntil>published</waitUntil>
                    -->
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <version>${version.jacoco-maven-plugin}</version>
                <executions>
                    <execution>
                        <goals><goal>prepare-agent</goal></goals>
                    </execution>
                    <execution>
                        <id>report</id>
                        <phase>test</phase>
                        <goals><goal>report</goal></goals>
                        <configuration>
                            <!-- a JDK 21 version of a class (META-INF/versions/21) has the same name as the class -->
                            <excludes><exclude>META-INF/**</exclude></excludes>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>${version.maven-surefire-plugin}</version>
                <configuration>
                    <argLine>
                        @{argLine}
                        -Duser.timezone=America/New_York
                        -Duser.language=en
                        -Duser.region=US
                        -Duser.country=US
                        -Xmx1500m
                    </argLine>
                    <!-- an OSGi framework is for the integration tests only: unit tests check behavior without one -->
                    <classpathDependencyExcludes>
                        <classpathDependencyExclude>org.apache.felix:org.apache.felix.framework</classpathDependencyExclude>
                    </classpathDependencyExcludes>
                </configuration>
            </plugin>

            <!-- Integration tests (*IT) run against the packaged jar, not target/classes: the jar's layout, and
                 multi-release versions, which the JVM applies only to classes loaded from a jar -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-failsafe-plugin</artifactId>
                <version>${version.maven-failsafe-plugin}</version>
                <configuration>
                    <classesDirectory>${project.build.directory}/${project.build.finalName}.jar</classesDirectory>
                    <useModulePath>false</useModulePath>     <!-- on the classpath, as surefire runs the tests -->
                    <systemPropertyVariables>
                        <java-util.jar>${project.build.directory}/${project.build.finalName}.jar</java-util.jar>
                    </systemPropertyVariables>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>integration-test</goal>
                            <goal>verify</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.moditect</groupId>
                <artifactId>moditect-maven-plugin</artifactId>
                <version>${version.moditect-maven-plugin}</version>
                <executions>
                    <execution>
                        <id>add-module-infos</id>
                        <goals>
                            <goal>add-module-info</goal>
                        </goals>
                        <phase>package</phase>
                        <configuration>
                            <!-- under META-INF/versions/9 of a multi-release jar, where only JDK 9+ looks: at the
                                 root it was the one Java 9 class file in a JDK 8 jar -->
                            <jvmVersion>9</jvmVersion>
                            <module>
                                <moduleInfoSource>
                                    module com.cedarsoftware.util {
                                    requires java.sql;
                                    requires static java.xml;
                                    exports com.cedarsoftware.util;
                                    exports com.cedarsoftware.util.cache;
                                    exports com.cedarsoftware.util.convert;
                                    exports com.cedarsoftware.util.geom;
                                    exports com.cedarsoftware.util.internal to com.cedarsoftware.io;
                                    }
                                </moduleInfoSource>
                            </module>
                            <overwriteExistingFiles>true</overwriteExistingFiles>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

        </plugins>
    </build>

    <dependencies>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-api</artifactId>
            <version>${version.junit-jupiter-api}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-params</artifactId>
            <version>${version.junit-jupiter-params}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-junit-jupiter</artifactId>
            <version>${version.mockito-junit-jupiter}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.assertj</groupId>
            <artifactId>assertj-core</artifactId>
            <version>${version.assertj-core}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.felix</groupId>
            <artifactId>org.apache.felix.framework</artifactId>
            <version>${version.felix-framework}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>com.cedarsoftware</groupId>
            <artifactId>json-io</artifactId>
            <version>${version.json-io}</version>
            <scope>test</scope>
        </dependency>
        
        <dependency>
            <groupId>org.agrona</groupId>
            <artifactId>agrona</artifactId>
            <version>${version.agrona}</version>
            <scope>test</scope>
        </dependency>
        
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-collections4</artifactId>
            <version>${version.commons-collections4}</version>
            <scope>test</scope>
        </dependency>
        
        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
            <version>${version.guava}</version>
            <scope>test</scope>
        </dependency>

    </dependencies>
</project>
