<?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>14.1.5</version>
    </parent>

    <artifactId>ch.sbb.polarion.extension.diff-tool</artifactId>
    <version>8.3.3</version>
    <packaging>jar</packaging>

    <name>Polarion ALM extension to diff/merge Documents/WorkItems</name>
    <description>This Polarion extension provides functionality to diff Polarion Documents/WorkItems with further possibility to merge selected diffs. This is an alternative to native Polarion's solution.</description>
    <url>https://github.com/SchweizerischeBundesbahnen/ch.sbb.polarion.extension.diff-tool</url>

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

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

    <properties>
        <node.version>v20.11.0</node.version>
        <frontend-maven-plugin.version>2.0.0</frontend-maven-plugin.version>

        <maven-jar-plugin.Extension-Context>diff-tool</maven-jar-plugin.Extension-Context>
        <maven-jar-plugin.Automatic-Module-Name>ch.sbb.polarion.extension.diff_tool</maven-jar-plugin.Automatic-Module-Name>
        <maven-jar-plugin.Discover-Base-Package>ch.sbb.polarion.extension.diff_tool</maven-jar-plugin.Discover-Base-Package>
        <maven-jar-plugin.Configuration-Properties-Prefix>ch.sbb.polarion.extension.diff-tool.</maven-jar-plugin.Configuration-Properties-Prefix>

        <web.app.name>${maven-jar-plugin.Extension-Context}</web.app.name>

        <!-- Extension-specific Require-Bundle (in addition to common ones from parent POM):
            org.apache.commons.commons-collections4
            org.apache.commons.lang3
            com.polarion.subterra.persistence
            com.polarion.platform.jobs
            org.ehcache
            org.jsoup
            ch.sbb.polarion.extension.pdf-exporter;resolution:=optional
        -->
        <maven-jar-plugin.Require-Bundle.extension>org.apache.commons.commons-collections4,org.apache.commons.lang3,com.polarion.subterra.persistence,com.polarion.platform.jobs,org.ehcache,org.jsoup,ch.sbb.polarion.extension.pdf-exporter;resolution:=optional</maven-jar-plugin.Require-Bundle.extension>
        <maven-jar-plugin.Require-Bundle>${maven-jar-plugin.Require-Bundle.common},${maven-jar-plugin.Require-Bundle.extension}</maven-jar-plugin.Require-Bundle>

        <html5diff.version>1.4.5</html5diff.version>
        <ehcache.version>3.8.0</ehcache.version>

        <pdf-exporter.version>12.4.2</pdf-exporter.version>

        <awaitility.version>4.3.0</awaitility.version>

        <swagger-maven-plugin.version>2.2.22</swagger-maven-plugin.version>

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

        <nextjs.sources.root>${project.basedir}/ui</nextjs.sources.root>
        <nextjs.destination.root>${project.basedir}/src/main/resources/webapp/diff-tool-app</nextjs.destination.root>

        <skipJsTests>false</skipJsTests>
    </properties>

    <profiles>
        <profile>
            <id>polarion2512</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <properties>
                <commons-collections4.artifactId>org.apache.commons.commons-collections4_4.4.0</commons-collections4.artifactId>
                <commons-lang3.artifactId>org.apache.commons.lang3_3.12.0</commons-lang3.artifactId>
                <org.jsoup.artifactId>org.jsoup_1.15.2</org.jsoup.artifactId>
            </properties>
        </profile>
    </profiles>

    <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>${commons-collections4.artifactId}</artifactId>
            <version>${polarion.version}</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>com.polarion.subterra.persistence</groupId>
            <artifactId>subterra-uniform-persistence</artifactId>
            <version>${polarion.version}</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>com.polarion.thirdparty</groupId>
            <artifactId>${commons-lang3.artifactId}</artifactId>
            <version>${polarion.version}</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>ch.sbb.polarion.extensions</groupId>
            <artifactId>ch.sbb.polarion.extension.pdf-exporter</artifactId>
            <version>${pdf-exporter.version}</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>ch.sbb.html5diff</groupId>
            <artifactId>html5diff</artifactId>
            <version>${html5diff.version}</version>
        </dependency>

        <dependency>
            <groupId>org.ehcache</groupId>
            <artifactId>ehcache</artifactId>
            <version>${ehcache.version}</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>com.polarion.thirdparty</groupId>
            <artifactId>${org.jsoup.artifactId}</artifactId>
            <version>${polarion.version}</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>ch.sbb.polarion.extensions</groupId>
            <artifactId>ch.sbb.polarion.extension.generic.app</artifactId>
            <version>${project.parent.version}</version>
            <type>test-jar</type>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.awaitility</groupId>
            <artifactId>awaitility</artifactId>
            <version>${awaitility.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.polarion.thirdparty</groupId>
            <artifactId>net.htmlparser.jericho_3.1.0</artifactId>
            <version>${polarion.version}</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-clean-plugin</artifactId>
                <configuration>
                    <filesets>
                        <fileset>
                            <directory>${markdown2html-maven-plugin.extensionContextAdminHtml}</directory>
                            <includes>
                                <include>${markdown2html-maven-plugin.outputFileName}</include>
                            </includes>
                            <followSymlinks>false</followSymlinks>
                        </fileset>
                        <fileset>
                            <directory>${nextjs.destination.root}/app</directory>
                            <followSymlinks>false</followSymlinks>
                        </fileset>
                    </filesets>
                </configuration>
            </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.info</package>
                        <package>ch.sbb.polarion.extension.generic.rest.controller.settings</package>
                        <package>ch.sbb.polarion.extension.generic.rest.model</package>
                        <package>ch.sbb.polarion.extension.diff_tool.rest.controller</package>
                        <package>ch.sbb.polarion.extension.diff_tool.rest.model</package>
                    </resourcePackages>
                </configuration>
            </plugin>
            <plugin>
                <groupId>io.github.grigoriev</groupId>
                <artifactId>pre-commit-run-maven-plugin</artifactId>
            </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>
                        <phase>generate-resources</phase>
                    </execution>
                    <execution>
                        <id>npm install</id>
                        <goals>
                            <goal>npm</goal>
                        </goals>
                        <phase>generate-resources</phase>
                    </execution>
                    <execution>
                        <id>install-playwright-browsers</id>
                        <goals>
                            <goal>npx</goal>
                        </goals>
                        <phase>generate-resources</phase>
                        <configuration>
                            <arguments>playwright install --with-deps</arguments>
                        </configuration>
                    </execution>
                    <execution>
                        <id>npm build</id>
                        <goals>
                            <goal>npm</goal>
                        </goals>
                        <phase>generate-resources</phase>
                        <configuration>
                            <arguments>run build</arguments>
                        </configuration>
                    </execution>
                    <execution>
                        <id>npm test</id>
                        <goals>
                            <goal>npm</goal>
                        </goals>
                        <phase>test</phase>
                        <configuration>
                            <arguments>run playwright:test:headless</arguments>
                            <skip>${skipJsTests}</skip>
                        </configuration>
                    </execution>
                </executions>
                <configuration>
                    <nodeVersion>${node.version}</nodeVersion>
                    <workingDirectory>ui</workingDirectory>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <executions>
                    <execution>
                        <id>copy-nextjs-build</id>
                        <phase>generate-resources</phase>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${nextjs.destination.root}</outputDirectory>
                            <resources>
                                <resource>
                                    <directory>${nextjs.sources.root}/dist</directory>
                                    <filtering>false</filtering>
                                    <includes>
                                        <include>**/*</include>
                                    </includes>
                                </resource>
                            </resources>
                            <overwrite>true</overwrite>
                            <includeEmptyDirs>true</includeEmptyDirs>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

</project>
