<?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>dev.javai18n</groupId>
    <artifactId>i18n-core</artifactId>
    <version>1.3.1</version>
    <packaging>jar</packaging>

    <name>i18n-core</name>
    <description>A Java framework for internationalization that provides interfaces to identify localizable classes, an event mechanism to support dynamic locale selection, polymorphic resource inheritance, and use of complex resource objects defined in JSON or XML files.</description>
    <url>https://github.com/clydegerber/i18n</url>

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

    <developers>
        <developer>
            <name>Clyde Gerber</name>
        </developer>
    </developers>

    <scm>
        <connection>scm:git:https://github.com/clydegerber/i18n.git</connection>
        <developerConnection>scm:git:https://github.com/clydegerber/i18n.git</developerConnection>
        <url>https://github.com/clydegerber/i18n</url>
    </scm>

    <dependencies>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-engine</artifactId>
            <version>6.0.3</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>tools.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <version>3.1.0</version>
        </dependency>
        <dependency>
            <groupId>org.junit.platform</groupId>
            <artifactId>junit-platform-console</artifactId>
            <version>6.0.3</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.platform</groupId>
            <artifactId>junit-platform-launcher</artifactId>
            <version>6.0.3</version>
            <scope>test</scope>
        </dependency>
    </dependencies>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.release>17</maven.compiler.release>
    </properties>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.15.0</version>
            </plugin>
            <plugin>
                <groupId>com.ruleoftech</groupId>
                <artifactId>markdown-page-generator-plugin</artifactId>
                <version>2.4.2</version>
                <executions>
                    <execution>
                        <phase>process-resources</phase>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <inputDirectory>${project.basedir}</inputDirectory>
                    <outputDirectory>${project.build.directory}/html</outputDirectory>
                    <pegdownExtensions>TABLES,FENCED_CODE_BLOCKS</pegdownExtensions>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>3.10.0</version>
                <executions>
                    <execution>
                        <id>build-modulepath</id>
                        <phase>process-test-classes</phase>
                        <goals>
                            <goal>build-classpath</goal>
                        </goals>
                        <configuration>
                            <outputFile>${project.build.directory}/modulepath.txt</outputFile>
                            <includeScope>test</includeScope>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
    <profiles>
        <profile>
            <id>test-classpath</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <version>3.5.5</version>
                        <configuration>
                            <useModulePath>false</useModulePath>
                            <argLine>-Djava.util.logging.config.file=${project.basedir}/src/test/resources/test-logging.properties</argLine>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>test-modulepath</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <version>3.5.5</version>
                        <configuration>
                            <skip>true</skip>
                        </configuration>
                    </plugin>
                    <!-- Create a shell script that runs the tests -->
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-antrun-plugin</artifactId>
                        <version>3.2.0</version>
                        <executions>
                            <execution>
                                <id>create-test-script</id>
                                <phase>test</phase>
                                <goals>
                                    <goal>run</goal>
                                </goals>
                                <configuration>
                                    <target>
                                        <!-- Build the full module path -->
                                        <loadfile property="dep.classpath" srcFile="${project.build.directory}/modulepath.txt"/>
                                        <property name="full.modulepath" value="${project.build.testOutputDirectory}:${project.build.outputDirectory}:${dep.classpath}"/>
                                        
                                        <!-- Create shell script -->
                                        <echo file="${project.build.directory}/run-module-tests.sh">#!/bin/sh
java -Djava.util.logging.config.file=${project.basedir}/src/test/resources/test-logging.properties --module-path "${full.modulepath}" --add-modules ALL-MODULE-PATH -m org.junit.platform.console execute --select-module dev.javai18n.core.test
</echo>
                                        <chmod file="${project.build.directory}/run-module-tests.sh" perm="755"/>
                                        
                                        <!-- Run the script -->
                                        <exec executable="${project.build.directory}/run-module-tests.sh" failonerror="true"/>
                                    </target>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>release</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-source-plugin</artifactId>
                        <version>3.4.0</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>3.12.0</version>
                        <configuration>
                            <doclint>all</doclint>
                        </configuration>
                        <executions>
                            <execution>
                                <id>attach-javadocs</id>
                                <goals>
                                    <goal>jar</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-antrun-plugin</artifactId>
                        <version>3.2.0</version>
                        <executions>
                            <execution>
                                <id>add-readme-to-javadoc-jar</id>
                                <phase>package</phase>
                                <goals>
                                    <goal>run</goal>
                                </goals>
                                <configuration>
                                    <target>
                                        <jar destfile="${project.build.directory}/${project.artifactId}-${project.version}-javadoc.jar" update="true">
                                            <fileset dir="${project.build.directory}/html" includes="README.html"/>
                                        </jar>
                                    </target>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-gpg-plugin</artifactId>
                        <version>3.2.8</version>
                        <executions>
                            <execution>
                                <id>sign-artifacts</id>
                                <phase>verify</phase>
                                <goals>
                                    <goal>sign</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.sonatype.central</groupId>
                        <artifactId>central-publishing-maven-plugin</artifactId>
                        <version>0.10.0</version>
                        <extensions>true</extensions>
                        <configuration>
                            <publishingServerId>central</publishingServerId>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
