<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>ch.sbb.maven.plugins</groupId>
    <artifactId>markdown2html-maven-plugin</artifactId>
    <version>1.7.1</version>
    <packaging>maven-plugin</packaging>

    <name>Markdown to HTML Maven Plugin</name>
    <description>This Maven plugin converts Markdown to HTML locally, using a GitHub Flavored Markdown renderer.</description>
    <url>https://github.com/SchweizerischeBundesbahnen/markdown2html-maven-plugin</url>

    <licenses>
        <license>
            <name>The SBB License, Version 1.0</name>
            <url>https://github.com/SchweizerischeBundesbahnen/markdown2html-maven-plugin/blob/main/LICENSES/SBB.txt</url>
        </license>
    </licenses>

    <developers>
        <developer>
            <name>SBB Polarion Team</name>
            <email>polarion-opensource@sbb.ch</email>
            <organization>SBB AG</organization>
            <organizationUrl>https://www.sbb.ch</organizationUrl>
        </developer>
    </developers>

    <scm>
        <connection>scm:git:git://github.com/SchweizerischeBundesbahnen/markdown2html-maven-plugin.git</connection>
        <developerConnection>scm:git:ssh://github.com/SchweizerischeBundesbahnen/markdown2html-maven-plugin.git</developerConnection>
        <url>https://github.com/SchweizerischeBundesbahnen/markdown2html-maven-plugin/tree/main</url>
    </scm>

    <issueManagement>
        <system>GitHub</system>
        <url>https://github.com/SchweizerischeBundesbahnen/markdown2html-maven-plugin/issues</url>
    </issueManagement>

    <distributionManagement>
        <snapshotRepository>
            <id>sonatype-central</id>
            <url>https://central.sonatype.com/</url>
        </snapshotRepository>
        <repository>
            <id>sonatype-central</id>
            <url>https://central.sonatype.com/</url>
        </repository>
    </distributionManagement>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>21</maven.compiler.source>
        <maven.compiler.target>21</maven.compiler.target>

        <maven-compiler-plugin.version>3.15.0</maven-compiler-plugin.version>
        <maven-plugin-plugin.version>3.15.2</maven-plugin-plugin.version>
        <maven-plugin-annotations.version>3.13.1</maven-plugin-annotations.version>
        <maven-plugin-api.version>3.9.8</maven-plugin-api.version>
        <maven-surefire-plugin.version>3.5.6</maven-surefire-plugin.version>
        <lombok.version>1.18.46</lombok.version>

        <httpclient5.version>5.6.2</httpclient5.version>
        <commonmark.version>0.29.0</commonmark.version>
        <rsyntaxtextarea.version>4.0.1</rsyntaxtextarea.version>
        <jackson-databind.version>2.22.1</jackson-databind.version>
        <icu4j.version>78.3</icu4j.version>
        <jsoup.version>1.22.2</jsoup.version>

        <junit-jupiter-api.version>6.1.2</junit-jupiter-api.version>
        <mockito-core.version>5.23.0</mockito-core.version>
        <annotations.version>24.0.1</annotations.version>
        <slf4j.version>2.0.18</slf4j.version>

        <playwright.version>1.61.0</playwright.version>
        <build-helper-maven-plugin.version>3.6.1</build-helper-maven-plugin.version>
        <exec-maven-plugin.version>3.6.3</exec-maven-plugin.version>
        <!-- Pinned to the playwright dependency: a browser of another version rasterises differently -->
        <playwright.image>mcr.microsoft.com/playwright/java:v1.61.0</playwright.image>
        <visual.baseline.update>false</visual.baseline.update>

        <maven-gpg-plugin.version>3.2.8</maven-gpg-plugin.version>
        <maven-source-plugin.version>3.4.0</maven-source-plugin.version>
        <maven-javadoc-plugin.version>3.12.0</maven-javadoc-plugin.version>
        <sonar-maven-plugin.version>5.7.0.6970</sonar-maven-plugin.version>

        <!-- Sonar and JaCoCo -->
        <jacoco.version>0.8.15</jacoco.version>
        <sonar.projectKey>SchweizerischeBundesbahnen_${project.artifactId}</sonar.projectKey>
        <sonar.organization>schweizerischebundesbahnen</sonar.organization>
        <sonar.projectName>${project.artifactId}</sonar.projectName>
        <sonar.host.url>https://sonarcloud.io</sonar.host.url>
        <sonar.java.coveragePlugin>jacoco</sonar.java.coveragePlugin>
        <sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis>
        <sonar.language>java</sonar.language>
        <sonar.coverage.jacoco.xmlReportPaths>${project.basedir}/target/site/jacoco/jacoco.xml</sonar.coverage.jacoco.xmlReportPaths>
        <sonar.verbose>true</sonar.verbose>
        <sonar.qualitygate.wait>true</sonar.qualitygate.wait>

        <central-publishing-maven-plugin.version>0.11.0</central-publishing-maven-plugin.version>
        <central-publishing-maven-plugin.autoPublish>true</central-publishing-maven-plugin.autoPublish>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.apache.maven.plugin-tools</groupId>
            <artifactId>maven-plugin-annotations</artifactId>
            <version>${maven-plugin-annotations.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.maven</groupId>
            <artifactId>maven-plugin-api</artifactId>
            <version>${maven-plugin-api.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>${lombok.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.jetbrains</groupId>
            <artifactId>annotations</artifactId>
            <version>${annotations.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>${slf4j.version}</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.apache.httpcomponents.client5</groupId>
            <artifactId>httpclient5</artifactId>
            <version>${httpclient5.version}</version>
        </dependency>
        <dependency>
            <groupId>org.commonmark</groupId>
            <artifactId>commonmark</artifactId>
            <version>${commonmark.version}</version>
        </dependency>
        <dependency>
            <groupId>org.commonmark</groupId>
            <artifactId>commonmark-ext-gfm-tables</artifactId>
            <version>${commonmark.version}</version>
        </dependency>
        <dependency>
            <groupId>org.commonmark</groupId>
            <artifactId>commonmark-ext-gfm-strikethrough</artifactId>
            <version>${commonmark.version}</version>
        </dependency>
        <dependency>
            <groupId>org.commonmark</groupId>
            <artifactId>commonmark-ext-task-list-items</artifactId>
            <version>${commonmark.version}</version>
        </dependency>
        <dependency>
            <groupId>org.commonmark</groupId>
            <artifactId>commonmark-ext-autolink</artifactId>
            <version>${commonmark.version}</version>
        </dependency>
        <dependency>
            <groupId>org.commonmark</groupId>
            <artifactId>commonmark-ext-footnotes</artifactId>
            <version>${commonmark.version}</version>
        </dependency>
        <!-- Only its lexers are used, to tokenize fenced code blocks; no Swing component is created -->
        <dependency>
            <groupId>com.fifesoft</groupId>
            <artifactId>rsyntaxtextarea</artifactId>
            <version>${rsyntaxtextarea.version}</version>
        </dependency>
        <dependency>
            <groupId>com.ibm.icu</groupId>
            <artifactId>icu4j</artifactId>
            <version>${icu4j.version}</version>
        </dependency>
        <dependency>
            <groupId>org.jsoup</groupId>
            <artifactId>jsoup</artifactId>
            <version>${jsoup.version}</version>
        </dependency>

        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-api</artifactId>
            <version>${junit-jupiter-api.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-params</artifactId>
            <version>${junit-jupiter-api.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-core</artifactId>
            <version>${mockito-core.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-simple</artifactId>
            <version>${slf4j.version}</version>
            <scope>test</scope>
        </dependency>
        <!-- Only the GitHub parity tests need it, to build the request body for the markdown API -->
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <version>${jackson-databind.version}</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>${maven-compiler-plugin.version}</version>
                <configuration>
                    <!--
                        Since JDK 23 javac no longer runs an annotation processor it merely finds on the
                        classpath. Without asking for it, Lombok is skipped without a word and every member
                        it generates goes missing, which is what happens on the JDK 25 of the Playwright
                        image. Harmless on the JDK 21 the build targets.
                    -->
                    <proc>full</proc>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-plugin-plugin</artifactId>
                <version>${maven-plugin-plugin.version}</version>
            </plugin>
            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <version>${jacoco.version}</version>
                <configuration>
                    <excludes>**/*.jar</excludes>
                </configuration>
                <executions>
                    <execution>
                        <id>prepare-agent</id>
                        <goals>
                            <goal>prepare-agent</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>report</id>
                        <phase>package</phase>
                        <goals>
                            <goal>report</goal>
                        </goals>
                        <configuration>
                            <formats>
                                <format>XML</format>
                            </formats>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>${maven-surefire-plugin.version}</version>
                <configuration>
                    <!-- hide unwanted exceptions logging -->
                    <redirectTestOutputToFile>true</redirectTestOutputToFile>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.sonarsource.scanner.maven</groupId>
                <artifactId>sonar-maven-plugin</artifactId>
                <version>${sonar-maven-plugin.version}</version>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <!--
            The visual parity test renders both HTMLs in a browser and compares the screenshots. Playwright
            downloads a browser of ~130 MB the first time it runs, so neither the test nor its dependency is
            part of the normal build: it lives in its own source root, compiled only by this profile.
        -->
        <profile>
            <id>visual-parity</id>
            <dependencies>
                <dependency>
                    <groupId>com.microsoft.playwright</groupId>
                    <artifactId>playwright</artifactId>
                    <version>${playwright.version}</version>
                    <scope>test</scope>
                </dependency>
            </dependencies>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>build-helper-maven-plugin</artifactId>
                        <version>${build-helper-maven-plugin.version}</version>
                        <executions>
                            <execution>
                                <id>add-visual-test-sources</id>
                                <phase>generate-test-sources</phase>
                                <goals>
                                    <goal>add-test-source</goal>
                                    <goal>add-test-resource</goal>
                                </goals>
                                <configuration>
                                    <sources>
                                        <source>src/visual-test/java</source>
                                    </sources>
                                    <resources>
                                        <resource>
                                            <directory>src/visual-test/resources</directory>
                                        </resource>
                                    </resources>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>exec-maven-plugin</artifactId>
                        <version>${exec-maven-plugin.version}</version>
                        <executions>
                            <!-- The browser VisualParityTest drives, on this machine -->
                            <execution>
                                <id>install-browser</id>
                                <phase>pre-integration-test</phase>
                                <goals>
                                    <goal>exec</goal>
                                </goals>
                                <configuration>
                                    <!--
                                        In a process of its own: the Playwright CLI ends with System.exit,
                                        which run in Maven's own JVM would take the build down with it
                                        before anything bound after this ever runs.
                                    -->
                                    <executable>${java.home}/bin/java</executable>
                                    <classpathScope>test</classpathScope>
                                    <arguments>
                                        <argument>-classpath</argument>
                                        <classpath/>
                                        <argument>com.microsoft.playwright.CLI</argument>
                                        <argument>install</argument>
                                        <argument>chromium</argument>
                                    </arguments>
                                </configuration>
                            </execution>
                            <!--
                                The image baselines, on the other hand, only hold where they were recorded:
                                text rasterises differently on every platform, so this one runs in the
                                Playwright image pinned to the version of the dependency, on the
                                architecture the CI runner uses. The classes are already built here - the
                                container contributes nothing but its browser and its fonts.

                                Record them again with -Dvisual.baseline.update=true, then review the diff.
                            -->
                            <execution>
                                <id>check-visual-baselines</id>
                                <phase>integration-test</phase>
                                <goals>
                                    <goal>exec</goal>
                                </goals>
                                <configuration>
                                    <executable>docker</executable>
                                    <arguments>
                                        <argument>run</argument>
                                        <argument>--rm</argument>
                                        <argument>--platform</argument>
                                        <argument>linux/amd64</argument>
                                        <argument>--volume</argument>
                                        <argument>${project.basedir}:/repository</argument>
                                        <argument>--volume</argument>
                                        <argument>${settings.localRepository}:/root/.m2/repository</argument>
                                        <argument>--workdir</argument>
                                        <argument>/repository</argument>
                                        <argument>--env</argument>
                                        <argument>VISUAL_BASELINE_CONTAINER=1</argument>
                                        <argument>${playwright.image}</argument>
                                        <argument>mvn</argument>
                                        <argument>--batch-mode</argument>
                                        <argument>-P</argument>
                                        <argument>visual-parity</argument>
                                        <argument>surefire:test</argument>
                                        <argument>-Dtest=VisualBaselineTest</argument>
                                        <argument>-DfailIfNoSpecifiedTests=false</argument>
                                        <argument>-Dvisual.baseline.update=${visual.baseline.update}</argument>
                                    </arguments>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>

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

        <profile>
            <id>central-publishing</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-source-plugin</artifactId>
                        <version>${maven-source-plugin.version}</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>${maven-javadoc-plugin.version}</version>
                        <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>${central-publishing-maven-plugin.version}</version>
                        <extensions>true</extensions>
                        <configuration>
                            <publishingServerId>sonatype-central</publishingServerId>
                            <autoPublish>${central-publishing-maven-plugin.autoPublish}</autoPublish>
                            <waitUntil>published</waitUntil>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
