<?xml version="1.0" encoding="UTF-8"?>
<project>
    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>ch.sbb.polarion.extensions</groupId>
        <artifactId>ch.sbb.polarion.extension.generic</artifactId>
        <version>7.2.0</version>
    </parent>

    <artifactId>ch.sbb.polarion.extension.pdf-exporter</artifactId>
    <version>7.2.0</version>
    <packaging>jar</packaging>

    <name>Polarion ALM extension to convert Documents to PDF files</name>
    <description>This Polarion extension provides possibility to convert Polarion Documents to PDF files. This is an alternative to native Polarion's solution.</description>
    <url>https://github.com/SchweizerischeBundesbahnen/ch.sbb.polarion.extension.pdf-exporter</url>

    <licenses>
        <license>
            <name>The SBB License, Version 1.0</name>
            <url>https://github.com/SchweizerischeBundesbahnen/ch.sbb.polarion.extension.pdf-exporter/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/ch.sbb.polarion.extension.pdf-exporter.git</connection>
        <developerConnection>scm:git:ssh://github.com/SchweizerischeBundesbahnen/ch.sbb.polarion.extension.pdf-exporter.git</developerConnection>
        <url>https://github.com/SchweizerischeBundesbahnen/ch.sbb.polarion.extension.pdf-exporter/tree/main</url>
    </scm>

    <issueManagement>
        <system>GitHub</system>
        <url>https://github.com/SchweizerischeBundesbahnen/ch.sbb.polarion.extension.pdf-exporter/issues</url>
    </issueManagement>

    <properties>
        <pdfbox.version>3.0.3</pdfbox.version>
        <okapi.xliff.version>1.46.0</okapi.xliff.version>
        <byte-buddy.version>1.15.3</byte-buddy.version>

        <slf4j.version>1.7.36</slf4j.version>
        <testcontainers.version>1.20.2</testcontainers.version>
        <javax.transaction-api.version>1.3</javax.transaction-api.version>

        <exec-maven-plugin.version>3.3.0</exec-maven-plugin.version>
        <weasyprint.version>62.3</weasyprint.version>
        <awaitility.version>4.2.2</awaitility.version>
        <tika.version>1.28.5</tika.version>

        <maven-jar-plugin.Extension-Context>pdf-exporter</maven-jar-plugin.Extension-Context>
        <maven-jar-plugin.Automatic-Module-Name>ch.sbb.polarion.extension.pdf_exporter</maven-jar-plugin.Automatic-Module-Name>
        <maven-jar-plugin.Discover-Base-Package>ch.sbb.polarion.extension.pdf_exporter</maven-jar-plugin.Discover-Base-Package>
        <maven-jar-plugin.Configuration-Properties-Prefix>ch.sbb.polarion.extension.pdf-exporter.</maven-jar-plugin.Configuration-Properties-Prefix>
        <web.app.name>${maven-jar-plugin.Extension-Context}</web.app.name>

        <!--suppress UnresolvedMavenProperty -->
        <markdown2html-maven-plugin.failOnError>${env.MARKDOWN2HTML_MAVEN_PLUGIN_FAIL_ON_ERROR}</markdown2html-maven-plugin.failOnError>
        <swagger-maven-plugin.version>2.2.22</swagger-maven-plugin.version>

        <frontend-maven-plugin.version>1.15.1</frontend-maven-plugin.version>
        <frontend-maven-plugin.nodeVersion>v20.17.0</frontend-maven-plugin.nodeVersion>
        <frontend-maven-plugin.npmVersion>10.8.3</frontend-maven-plugin.npmVersion>

        <!--suppress UnresolvedMavenProperty -->
        <skipJavaScriptTests>${skipTests}</skipJavaScriptTests>
    </properties>

    <dependencies>
        <dependency>
            <groupId>ch.sbb.polarion.extensions</groupId>
            <artifactId>ch.sbb.polarion.extension.generic.app</artifactId>
            <version>${project.parent.version}</version>
        </dependency>

        <dependency>
            <groupId>com.polarion.thirdparty</groupId>
            <artifactId>velocity-engine-core-2.3</artifactId>
            <version>${polarion.version}</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>com.polarion.alm.wiki</groupId>
            <artifactId>sidecar</artifactId>
            <version>${polarion.version}</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.apache.tika</groupId>
            <artifactId>tika-core</artifactId>
            <version>${tika.version}</version>
            <scope>provided</scope>
        </dependency>

        <!--  3rd-party libraries to be packaged into resulting jar  -->
        <dependency>
            <groupId>org.apache.pdfbox</groupId>
            <artifactId>pdfbox</artifactId>
            <version>${pdfbox.version}</version>
            <exclusions> <!-- pdfbox 3.0.0 has scope test for junit, pdfbox 3.0.1 has no such scope, that's why this exclusion has been added -->
                <exclusion>
                    <groupId>org.junit.jupiter</groupId>
                    <artifactId>junit-jupiter</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>net.sf.okapi.lib</groupId>
            <artifactId>okapi-lib-xliff2</artifactId>
            <version>${okapi.xliff.version}</version>
        </dependency>
        <dependency>
            <groupId>net.bytebuddy</groupId>
            <artifactId>byte-buddy</artifactId>
            <version>${byte-buddy.version}</version>
        </dependency>

        <!--  Test dependencies  -->
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>${slf4j.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-simple</artifactId>
            <version>${slf4j.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.testcontainers</groupId>
            <artifactId>testcontainers</artifactId>
            <version>${testcontainers.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>javax.transaction</groupId>
            <artifactId>javax.transaction-api</artifactId>
            <version>${javax.transaction-api.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.awaitility</groupId>
            <artifactId>awaitility</artifactId>
            <version>${awaitility.version}</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-clean-plugin</artifactId>
            </plugin>

            <plugin>
                <groupId>ch.sbb.maven.plugins</groupId>
                <artifactId>markdown2html-maven-plugin</artifactId>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
            </plugin>

            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-source-plugin</artifactId>
            </plugin>

            <plugin>
                <groupId>io.swagger.core.v3</groupId>
                <artifactId>swagger-maven-plugin</artifactId>
                <configuration>
                    <outputFormat>JSON</outputFormat>
                    <resourcePackages>
                        <package>ch.sbb.polarion.extension.generic.rest.controller</package>
                        <package>ch.sbb.polarion.extension.generic.rest.model</package>
                        <package>ch.sbb.polarion.extension.pdf_exporter.rest.controller</package>
                        <package>ch.sbb.polarion.extension.pdf_exporter.rest.model</package>
                    </resourcePackages>
                </configuration>
            </plugin>

            <plugin>
                <groupId>com.github.eirslett</groupId>
                <artifactId>frontend-maven-plugin</artifactId>
                <version>${frontend-maven-plugin.version}</version>
                <executions>
                    <execution>
                        <id>install-node-and-npm</id>
                        <goals>
                            <goal>install-node-and-npm</goal>
                        </goals>
                        <configuration>
                            <nodeVersion>${frontend-maven-plugin.nodeVersion}</nodeVersion>
                            <npmVersion>${frontend-maven-plugin.npmVersion}</npmVersion>
                            <skip>${skipJavaScriptTests}</skip>
                        </configuration>
                        <phase>test</phase>
                    </execution>

                    <!-- Install JavaScript dependencies using npm -->
                    <execution>
                        <id>npm-install</id>
                        <goals>
                            <goal>npm</goal>
                        </goals>
                        <configuration>
                            <arguments>install</arguments>
                            <skip>${skipJavaScriptTests}</skip>
                        </configuration>
                        <phase>test</phase>
                    </execution>

                    <!-- Run JavaScript tests -->
                    <execution>
                        <id>npm-test</id>
                        <goals>
                            <goal>npm</goal>
                        </goals>
                        <configuration>
                            <arguments>run test</arguments>
                            <skip>${skipJavaScriptTests}</skip>
                        </configuration>
                        <phase>test</phase>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>tests-with-weasyprint-docker</id>

            <build>
                <plugins>
                    <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>
                            <systemPropertyVariables>
                                <wpExporterImpl>docker</wpExporterImpl>
                            </systemPropertyVariables>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
