<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>3.3.5</version>
        <relativePath/>
    </parent>

    <groupId>com.shodh</groupId>
    <artifactId>sanchayan-api</artifactId>
    <version>0.1.0-SNAPSHOT</version>
    <name>Shodh Sanchayan API</name>
    <description>Academic Paper Submission, Review &amp; Publishing Platform — Backend API</description>

    <properties>
        <java.version>21</java.version>
        <jjwt.version>0.12.6</jjwt.version>
        <flyway.version>10.21.0</flyway.version>
        <mapstruct.version>1.6.3</mapstruct.version>
        <springdoc.version>2.3.0</springdoc.version>
        <flying-saucer.version>9.1.22</flying-saucer.version>
        <!-- Spring Boot 3.3.5 manages 1.19.8, which speaks Docker API 1.32; Docker
             Engine 29 refuses anything below 1.44. 1.21.4 is the last 1.x release. -->
        <testcontainers.version>1.21.4</testcontainers.version>
    </properties>

    <dependencies>
        <!-- ===== Spring Boot Core ===== -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-validation</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-mail</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-thymeleaf</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>runtime</scope>
            <optional>true</optional>
        </dependency>

        <!-- ===== Security: JWT ===== -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-security</artifactId>
        </dependency>
        <dependency>
            <groupId>io.jsonwebtoken</groupId>
            <artifactId>jjwt-api</artifactId>
            <version>${jjwt.version}</version>
        </dependency>
        <dependency>
            <groupId>io.jsonwebtoken</groupId>
            <artifactId>jjwt-impl</artifactId>
            <version>${jjwt.version}</version>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>io.jsonwebtoken</groupId>
            <artifactId>jjwt-jackson</artifactId>
            <version>${jjwt.version}</version>
            <scope>runtime</scope>
        </dependency>

        <!-- ===== Database ===== -->
        <dependency>
            <groupId>org.postgresql</groupId>
            <artifactId>postgresql</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.flywaydb</groupId>
            <artifactId>flyway-core</artifactId>
            <version>${flyway.version}</version>
        </dependency>
        <dependency>
            <groupId>org.flywaydb</groupId>
            <artifactId>flyway-database-postgresql</artifactId>
            <version>${flyway.version}</version>
        </dependency>
        <!-- ===== Storage: AWS S3 / MinIO ===== -->
        <dependency>
            <groupId>software.amazon.awssdk</groupId>
            <artifactId>s3</artifactId>
            <version>2.29.26</version>
        </dependency>

        <!-- ===== Payment: Razorpay ===== -->
        <dependency>
            <groupId>com.razorpay</groupId>
            <artifactId>razorpay-java</artifactId>
            <version>1.4.8</version>
        </dependency>

        <!-- ===== BouncyCastle: OpenPDF needs it to read signed/encrypted PDFs ===== -->
        <dependency>
            <groupId>org.bouncycastle</groupId>
            <artifactId>bcprov-jdk18on</artifactId>
            <version>1.78.1</version>
        </dependency>
        <dependency>
            <groupId>org.bouncycastle</groupId>
            <artifactId>bcpkix-jdk18on</artifactId>
            <version>1.78.1</version>
        </dependency>
        <!-- ===== PDF Generation: Flying Saucer + OpenPDF ===== -->
        <dependency>
            <groupId>org.xhtmlrenderer</groupId>
            <artifactId>flying-saucer-pdf-openpdf</artifactId>
            <version>${flying-saucer.version}</version>
        </dependency>
        <dependency>
            <groupId>com.github.librepdf</groupId>
            <artifactId>openpdf</artifactId>
            <version>2.0.3</version>
        </dependency>

        <!--
          Complex-script shaping for Devanagari.

          OpenPDF maps characters to glyphs one-to-one, which is wrong for
          Indic scripts: the short-i matra is typed after its consonant but
          must print before it, and conjuncts need substituted glyphs. Without
          shaping the journal's Hindi came out reordered — "सामाजिक" printing
          as "सामाजकि" — on every generated PDF.

          OpenPDF delegates to Apache FOP's glyph processor when it is present
          (FopGlyphProcessor.isFopSupported()), and silently skips shaping when
          it is not. Only complexscripts and the TrueType reader are used, so
          FOP's rendering, imaging and transcoding stacks are excluded.
        -->
        <dependency>
            <groupId>org.apache.xmlgraphics</groupId>
            <artifactId>fop-core</artifactId>
            <version>2.9</version>
            <exclusions>
                <!--
                  FOP is here only for complexscripts and its TrueType reader.
                  Its SVG stack (Batik) is not used, and an exclusion applies to
                  the whole subtree, so every Batik artifact is named rather than
                  just the direct children — excluding one merely promotes
                  another to a direct dependency.
                -->
                <exclusion><groupId>org.apache.xmlgraphics</groupId><artifactId>batik-anim</artifactId></exclusion>
                <exclusion><groupId>org.apache.xmlgraphics</groupId><artifactId>batik-awt-util</artifactId></exclusion>
                <exclusion><groupId>org.apache.xmlgraphics</groupId><artifactId>batik-bridge</artifactId></exclusion>
                <exclusion><groupId>org.apache.xmlgraphics</groupId><artifactId>batik-codec</artifactId></exclusion>
                <exclusion><groupId>org.apache.xmlgraphics</groupId><artifactId>batik-constants</artifactId></exclusion>
                <exclusion><groupId>org.apache.xmlgraphics</groupId><artifactId>batik-css</artifactId></exclusion>
                <exclusion><groupId>org.apache.xmlgraphics</groupId><artifactId>batik-dom</artifactId></exclusion>
                <exclusion><groupId>org.apache.xmlgraphics</groupId><artifactId>batik-ext</artifactId></exclusion>
                <exclusion><groupId>org.apache.xmlgraphics</groupId><artifactId>batik-extension</artifactId></exclusion>
                <exclusion><groupId>org.apache.xmlgraphics</groupId><artifactId>batik-gvt</artifactId></exclusion>
                <exclusion><groupId>org.apache.xmlgraphics</groupId><artifactId>batik-i18n</artifactId></exclusion>
                <exclusion><groupId>org.apache.xmlgraphics</groupId><artifactId>batik-parser</artifactId></exclusion>
                <exclusion><groupId>org.apache.xmlgraphics</groupId><artifactId>batik-script</artifactId></exclusion>
                <exclusion><groupId>org.apache.xmlgraphics</groupId><artifactId>batik-shared-resources</artifactId></exclusion>
                <exclusion><groupId>org.apache.xmlgraphics</groupId><artifactId>batik-svg-dom</artifactId></exclusion>
                <exclusion><groupId>org.apache.xmlgraphics</groupId><artifactId>batik-svggen</artifactId></exclusion>
                <exclusion><groupId>org.apache.xmlgraphics</groupId><artifactId>batik-transcoder</artifactId></exclusion>
                <exclusion><groupId>org.apache.xmlgraphics</groupId><artifactId>batik-util</artifactId></exclusion>
                <exclusion><groupId>org.apache.xmlgraphics</groupId><artifactId>batik-xml</artifactId></exclusion>
                <exclusion><groupId>xml-apis</groupId><artifactId>xml-apis</artifactId></exclusion>
                <exclusion><groupId>xml-apis</groupId><artifactId>xml-apis-ext</artifactId></exclusion>
            </exclusions>
        </dependency>

        <!--
          FOP 2.9 calls UnsynchronizedByteArrayOutputStream.builder(), added in
          commons-io 2.12. Spring Boot's managed version is 2.11, so without this
          pin the magazine generator dies with NoSuchMethodError the first time it
          reads a font — after the shell PDF has already been written, which made
          it look like a permissions failure rather than a classpath one.
        -->
        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
            <version>2.16.1</version>
        </dependency>

        <!-- ===== DOCX Text Extraction: Apache POI ===== -->
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi-ooxml</artifactId>
            <version>5.2.5</version>
        </dependency>

        <!-- ===== API Documentation ===== -->
        <dependency>
            <groupId>org.springdoc</groupId>
            <artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
            <version>${springdoc.version}</version>
        </dependency>

        <!-- ===== Mapping ===== -->
        <dependency>
            <groupId>org.mapstruct</groupId>
            <artifactId>mapstruct</artifactId>
            <version>${mapstruct.version}</version>
        </dependency>

        <!-- ===== Lombok ===== -->
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <optional>true</optional>
        </dependency>

        <!-- ===== Test ===== -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.testcontainers</groupId>
            <artifactId>postgresql</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <excludes>
                        <exclude>
                            <groupId>org.projectlombok</groupId>
                            <artifactId>lombok</artifactId>
                        </exclude>
                    </excludes>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>21</source>
                    <target>21</target>
                    <annotationProcessorPaths>
                        <path>
                            <groupId>org.projectlombok</groupId>
                            <artifactId>lombok</artifactId>
                            <version>${lombok.version}</version>
                        </path>
                        <path>
                            <groupId>org.mapstruct</groupId>
                            <artifactId>mapstruct-processor</artifactId>
                            <version>${mapstruct.version}</version>
                        </path>
                    </annotationProcessorPaths>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>
