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

    <artifactId>ch.sbb.polarion.extension.excel-importer</artifactId>
    <version>6.2.0</version>
    <packaging>jar</packaging>

    <name>Polarion ALM extension to process WorkItems by uploading xlsx-files</name>
    <description>This Polarion extension provides possibility to update (or create) WorkItems using xlsx-file</description>
    <url>https://github.com/SchweizerischeBundesbahnen/ch.sbb.polarion.extension.excel-importer</url>

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

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

    <properties>
        <maven-jar-plugin.Extension-Context>excel-importer</maven-jar-plugin.Extension-Context>
        <maven-jar-plugin.Automatic-Module-Name>ch.sbb.polarion.extension.excel_importer</maven-jar-plugin.Automatic-Module-Name>
        <maven-jar-plugin.Discover-Base-Package>ch.sbb.polarion.extension.excel_importer</maven-jar-plugin.Discover-Base-Package>

        <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
            org.jsoup
        -->
        <maven-jar-plugin.Require-Bundle.extension>org.apache.commons.commons-collections4,org.apache.commons.lang3,org.jsoup</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>

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

        <!-- this extension is designed for latest version of Apache POI -->
        <apache-poi.version>5.5.1</apache-poi.version>

        <!-- A broken README.md -> about.html conversion fails the build instead of shipping an
             empty About page. markdown2html renders locally since 1.7.x - no GitHub API, no token -
             so the same setting is right in CI, in a deploy job and on a developer machine. -->
        <markdown2html-maven-plugin.failOnError>true</markdown2html-maven-plugin.failOnError>
        <markdown2html-maven-plugin.user-guide.inputFile>${project.basedir}/USER_GUIDE.md</markdown2html-maven-plugin.user-guide.inputFile>
        <markdown2html-maven-plugin.user-guide.outputFileName>user-guide.html</markdown2html-maven-plugin.user-guide.outputFileName>
        <markdown2html-maven-plugin.user-guide.outputFile>${markdown2html-maven-plugin.extensionContextAdminHtml}/${markdown2html-maven-plugin.user-guide.outputFileName}</markdown2html-maven-plugin.user-guide.outputFile>
    </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>org.apache.poi</groupId>
            <artifactId>poi</artifactId>
            <version>${apache-poi.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi-ooxml</artifactId>
            <version>${apache-poi.version}</version>
        </dependency>

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

        <dependency>
            <groupId>com.polarion.thirdparty</groupId>
            <artifactId>org.apache.commons.lang3_3.12.0</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>
    </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>
                <executions>
                    <execution>
                        <id>readme.md-to-about.html</id>
                        <phase>generate-resources</phase>
                        <goals>
                            <goal>convert</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>user_guide.md-to-user-guide.html</id>
                        <phase>generate-resources</phase>
                        <goals>
                            <goal>convert</goal>
                        </goals>
                        <configuration>
                            <inputFile>USER_GUIDE.md</inputFile>
                            <outputFile>${markdown2html-maven-plugin.user-guide.outputFile}</outputFile>
                            <tokenEnvVarName>${markdown2html-maven-plugin.tokenEnvVarName}</tokenEnvVarName>
                            <failOnError>${markdown2html-maven-plugin.failOnError}</failOnError>
                            <generateHeadingIds>${markdown2html-maven-plugin.generateHeadingIds}</generateHeadingIds>
                            <relativeLinkPrefix>${project.scm.url}</relativeLinkPrefix>
                            <openExternalLinksInNewTab>true</openExternalLinksInNewTab>
                            <imageProcessingType>EMBED</imageProcessingType>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

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

            <!-- Polarion 2606's JakartaCompatibilityChecker rejects a bundled jar only if a class makes a
                 real TYPE reference to a forbidden javax.* package. In POI's transitive xmlbeans, exactly
                 three SAAJ factory classes (MessageFactory, SOAPConnectionFactory, SOAPFactory) reference
                 javax.xml.soap; nothing else in xmlbeans references THEM and xlsx/OOXML never uses them.
                 Drop just those three from the bundled xmlbeans jar (keeping the rest — incl. impl.soap.Text,
                 which the xmlbeans core needs for XSSFWorkbook) so startup passes and xlsx still works.
                 Verified against the real checker (0/1032 flagged) + XSSFWorkbook round-trip. -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-antrun-plugin</artifactId>
                <executions>
                    <execution>
                        <id>strip-xmlbeans-javax-soap-factories</id>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>run</goal>
                        </goals>
                        <configuration>
                            <target>
                                <pathconvert property="xmlbeans.lib">
                                    <fileset dir="${project.build.outputDirectory}/webapp/${web.app.name}/WEB-INF/lib" includes="xmlbeans-*.jar"/>
                                </pathconvert>
                                <zip destfile="${xmlbeans.lib}.stripped">
                                    <zipfileset src="${xmlbeans.lib}">
                                        <exclude name="org/apache/xmlbeans/impl/soap/MessageFactory.class"/>
                                        <exclude name="org/apache/xmlbeans/impl/soap/SOAPConnectionFactory.class"/>
                                        <exclude name="org/apache/xmlbeans/impl/soap/SOAPFactory.class"/>
                                    </zipfileset>
                                </zip>
                                <move file="${xmlbeans.lib}.stripped" tofile="${xmlbeans.lib}"/>
                            </target>
                        </configuration>
                    </execution>
                </executions>
            </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-jakarta</artifactId>
                <configuration>
                    <outputFormat>JSON</outputFormat>
                    <!-- Stable ordering, so a rebuild does not reshuffle docs/openapi.json. -->
                    <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.excel_importer.rest.controller</package>
                        <package>ch.sbb.polarion.extension.excel_importer.rest.model</package>
                    </resourcePackages>
                </configuration>
            </plugin>
            <plugin>
                <groupId>io.github.grigoriev</groupId>
                <artifactId>pre-commit-run-maven-plugin</artifactId>
            </plugin>

        </plugins>
    </build>

</project>
