<?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.tabletest</groupId>
    <artifactId>tabletest-formatter</artifactId>
    <version>1.1.1</version>
    <packaging>pom</packaging>

    <inceptionYear>2025</inceptionYear>

    <name>TableTest Formatter</name>
    <description>Tools to format TableTest tables.</description>
    <url>https://github.com/nchaugen/tabletest-formatter</url>

    <properties>
        <copyright.holder>Nils Christian Haugen</copyright.holder>
        <maven.compiler.release>17</maven.compiler.release>
        <maven.compiler.source>17</maven.compiler.source>
        <maven.compiler.target>17</maven.compiler.target>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <repository.url.https>https://github.com/nchaugen/tabletest-formatter.git</repository.url.https>
        <repository.url.ssh>git@github.com:nchaugen/tabletest-formatter.git</repository.url.ssh>
        <project.scm.id>github</project.scm.id>
        <version.plugin.license>5.0.0</version.plugin.license>
        <version.plugin.clean>3.5.0</version.plugin.clean>
        <version.plugin.resources>3.5.0</version.plugin.resources>
        <version.plugin.compiler>3.15.0</version.plugin.compiler>
        <version.plugin.surefire>3.5.5</version.plugin.surefire>
        <version.plugin.jar>3.5.0</version.plugin.jar>
        <version.plugin.install>3.1.4</version.plugin.install>
        <version.plugin.deploy>3.1.4</version.plugin.deploy>
        <version.plugin.site>3.21.0</version.plugin.site>
        <version.plugin.help>3.5.1</version.plugin.help>
        <version.plugin.assembly>3.8.0</version.plugin.assembly>
        <version.plugin.dependency>3.10.0</version.plugin.dependency>
        <version.plugin.javadoc>3.12.0</version.plugin.javadoc>
        <version.plugin.source>3.4.0</version.plugin.source>
        <version.plugin.reports>3.9.0</version.plugin.reports>
        <version.plugin.staging>1.7.0</version.plugin.staging>
        <version.plugin.gpg>3.2.8</version.plugin.gpg>
        <version.plugin.publishing>0.10.0</version.plugin.publishing>
        <version.plugin.release>3.3.1</version.plugin.release>
        <version.plugin.spotless>3.3.0</version.plugin.spotless>
        <version.plugin.versions>2.21.0</version.plugin.versions>
        <version.tabletest>1.2.0</version.tabletest>
        <version.tabletest.parser>1.2.0</version.tabletest.parser>
        <version.junit>6.0.3</version.junit>
        <version.assertj>3.27.7</version.assertj>
        <surefire.arguments />
    </properties>

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

    <developers>
        <developer>
            <id>nchaugen</id>
            <name>Nils Christian Haugen</name>
            <email>nchaugen@gmail.com</email>
            <roles>
                <role>developer</role>
            </roles>
            <timezone>+1</timezone>
        </developer>
    </developers>

    <issueManagement>
        <system>github.com</system>
        <url>${project.url}</url>
    </issueManagement>

    <scm>
        <connection>scm:git:${repository.url.https}</connection>
        <developerConnection>scm:git:${repository.url.ssh}</developerConnection>
        <url>https://github.com/nchaugen/tabletest-formatter</url>
        <tag>HEAD</tag>
    </scm>

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

    <modules>
        <module>tabletest-formatter-core</module>
        <module>tabletest-formatter-cli</module>
    </modules>

    <build>
        <plugins>
            <!-- Format Java code automatically -->
            <plugin>
                <groupId>com.diffplug.spotless</groupId>
                <artifactId>spotless-maven-plugin</artifactId>
                <version>${version.plugin.spotless}</version>
                <configuration>
                    <java>
                        <palantirJavaFormat>
                            <version>2.83.0</version>
                        </palantirJavaFormat>
                        <removeUnusedImports />
                        <importOrder>
                            <order>,javax,java,\#</order>
                        </importOrder>
                    </java>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>apply</goal>
                        </goals>
                        <phase>process-sources</phase>
                    </execution>
                </executions>
            </plugin>

            <!-- Add licence headers to all files. -->
            <plugin>
                <groupId>com.mycila</groupId>
                <artifactId>license-maven-plugin</artifactId>
                <version>${version.plugin.license}</version>
                <inherited>false</inherited>
                <configuration>
                    <header>${project.basedir}/HEADER</header>
                    <aggregate>true</aggregate>
                    <failIfMissing>true</failIfMissing>
                    <encoding>${project.build.sourceEncoding}</encoding>
                    <properties>
                        <copyright.holder>${copyright.holder}</copyright.holder>
                    </properties>
                    <includes>
                        <include>**/main/java/**/*.java</include>
                    </includes>
                    <strictCheck>true</strictCheck>
                    <mapping>
                        <java>SLASHSTAR_STYLE</java>
                    </mapping>
                </configuration>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>format</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <!-- Dogfooding: format our own @TableTest tables -->
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>3.6.3</version>
                <inherited>false</inherited>
                <executions>
                    <execution>
                        <id>dogfood-format-tabletests</id>
                        <phase>verify</phase>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                        <configuration>
                            <executable>java</executable>
                            <arguments>
                                <argument>-jar</argument>
                                <argument>${project.basedir}/tabletest-formatter-cli/target/tabletest-formatter-cli-${project.version}.jar</argument>
                                <argument>${project.basedir}/tabletest-formatter-core/src/test/java</argument>
                                <argument>${project.basedir}/tabletest-formatter-cli/src/test/java</argument>
                            </arguments>
                            <successCodes>
                                <successCode>0</successCode>
                                <successCode>1</successCode>
                            </successCodes>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <!-- Release changed modules -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-release-plugin</artifactId>
                <version>${version.plugin.release}</version>
                <configuration>
                    <releaseProfiles>release</releaseProfiles>
                    <autoVersionSubmodules>false</autoVersionSubmodules>
                </configuration>
            </plugin>
        </plugins>

        <pluginManagement>
            <plugins>
                <plugin>
                    <artifactId>maven-clean-plugin</artifactId>
                    <version>${version.plugin.clean}</version>
                </plugin>
                <plugin>
                    <artifactId>maven-jar-plugin</artifactId>
                    <version>${version.plugin.jar}</version>
                </plugin>
                <plugin>
                    <artifactId>maven-resources-plugin</artifactId>
                    <version>${version.plugin.resources}</version>
                    <configuration>
                        <!-- Setting this property suppresses a warning on implicit setting the filter encoding. -->
                        <encoding>${project.build.sourceEncoding}</encoding>
                        <propertiesEncoding>${project.build.sourceEncoding}</propertiesEncoding>
                    </configuration>
                </plugin>
                <plugin>
                    <artifactId>maven-install-plugin</artifactId>
                    <version>${version.plugin.install}</version>
                </plugin>
                <plugin>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <version>${version.plugin.surefire}</version>
                    <configuration>
                        <argLine>${surefire.arguments}</argLine>
                        <trimStackTrace>false</trimStackTrace>
                    </configuration>
                </plugin>
                <plugin>
                    <artifactId>maven-deploy-plugin</artifactId>
                    <version>${version.plugin.deploy}</version>
                </plugin>
                <plugin>
                    <artifactId>maven-site-plugin</artifactId>
                    <version>${version.plugin.site}</version>
                </plugin>
                <plugin>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>${version.plugin.compiler}</version>
                    <inherited>true</inherited>
                    <configuration>
                        <encoding>${project.build.sourceEncoding}</encoding>
                        <showWarnings>true</showWarnings>
                        <showDeprecation>true</showDeprecation>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-javadoc-plugin</artifactId>
                    <version>${version.plugin.javadoc}</version>
                    <configuration>
                        <failOnWarnings>false</failOnWarnings>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-assembly-plugin</artifactId>
                    <version>${version.plugin.assembly}</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-dependency-plugin</artifactId>
                    <version>${version.plugin.dependency}</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-help-plugin</artifactId>
                    <version>${version.plugin.help}</version>
                </plugin>
                <plugin>
                    <artifactId>maven-project-info-reports-plugin</artifactId>
                    <version>${version.plugin.reports}</version>
                </plugin>
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>versions-maven-plugin</artifactId>
                    <version>${version.plugin.versions}</version>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>

    <profiles>
        <!-- Creates additional artefacts that are required for deployment. -->
        <profile>
            <id>release</id>
            <build>
                <plugins>
                    <!-- Create source code artefact. -->
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-source-plugin</artifactId>
                        <version>${version.plugin.source}</version>
                        <executions>
                            <execution>
                                <id>attach-sources</id>
                                <goals>
                                    <goal>jar-no-fork</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>

                    <!-- Create javadoc artifact. -->
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-javadoc-plugin</artifactId>
                        <version>${version.plugin.javadoc}</version>
                        <executions>
                            <execution>
                                <id>attach-javadocs</id>
                                <goals>
                                    <goal>jar</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>

                    <!-- Sign artefacts. (Requires configuration of gpg on the executing machine.) -->
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-gpg-plugin</artifactId>
                        <version>${version.plugin.gpg}</version>
                        <executions>
                            <execution>
                                <id>sign-artifacts</id>
                                <phase>verify</phase>
                                <goals>
                                    <goal>sign</goal>
                                </goals>
                                <configuration>
                                    <gpgArguments>
                                        <arg>--pinentry-mode</arg>
                                        <arg>loopback</arg>
                                    </gpgArguments>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>

                    <!-- Publish to Maven Central -->
                    <plugin>
                        <groupId>org.sonatype.central</groupId>
                        <artifactId>central-publishing-maven-plugin</artifactId>
                        <version>${version.plugin.publishing}</version>
                        <extensions>true</extensions>
                        <configuration>
                            <publishingServerId>central</publishingServerId>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
