<?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.4.4</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>se.idsec.sigval</groupId>
    <artifactId>sigval-service</artifactId>
    <version>1.3.2</version>
    <name>sigval-service</name>
    <description>Demo project for Spring Boot</description>

    <properties>
        <java.version>21</java.version>
        <signature-validation.version>1.3.1</signature-validation.version>
    </properties>

    <scm>
        <connection>scm:https://github.com/idsec-solutions/sig-validation-service.git</connection>
        <developerConnection>scm:https://github.com/idsec-solutions/sig-validation-service.git</developerConnection>
        <url>https://github.com/idsec-solutions/sig-validation-service/tree/main</url>
    </scm>

    <developers>
        <developer>
            <name>Stefan Santesson</name>
            <email>stefan@idsec.se</email>
            <organization>IDsec Solutions AB</organization>
            <organizationUrl>https://www.idsec.se</organizationUrl>
        </developer>

        <developer>
            <name>Martin Lindström</name>
            <email>martin@idsec.se</email>
            <organization>IDsec Solutions AB</organization>
            <organizationUrl>https://www.idsec.se</organizationUrl>
        </developer>
    </developers>

    <organization>
        <name>IDsec Solutions AB</name>
        <url>https://idsec.se</url>
    </organization>

    <repositories>
        <repository>
            <id>central</id>
            <name>Maven Central</name>
            <url>https://repo1.maven.org/maven2/</url>
        </repository>
    </repositories>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>se.idsec.signservice.commons</groupId>
                <artifactId>signservice-bom</artifactId>
                <version>2.3.0</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
            <dependency>
                <groupId>org.bouncycastle</groupId>
                <artifactId>bcprov-jdk18on</artifactId>
                <version>1.80</version>
            </dependency>
            <dependency>
                <groupId>org.bouncycastle</groupId>
                <artifactId>bcpkix-jdk18on</artifactId>
                <version>1.80</version>
            </dependency>
            <dependency>
                <groupId>org.bouncycastle</groupId>
                <artifactId>bcutil-jdk18on</artifactId>
                <version>1.80</version>
            </dependency>
            <dependency>
                <groupId>org.projectlombok</groupId>
                <artifactId>lombok</artifactId>
                <version>1.18.36</version>
            </dependency>
            <dependency>
                <groupId>com.google.guava</groupId>
                <artifactId>guava</artifactId>
                <version>33.4.0-jre</version>
            </dependency>
            <dependency>
                <groupId>org.glassfish.jaxb</groupId>
                <artifactId>jaxb-runtime</artifactId>
                <version>4.0.5</version>
            </dependency>
            <dependency>
                <groupId>org.cryptacular</groupId>
                <artifactId>cryptacular</artifactId>
                <version>1.2.7</version>
            </dependency>

            <dependency>
                <groupId>com.nimbusds</groupId>
                <artifactId>nimbus-jose-jwt</artifactId>
                <version>10.0.2</version>
            </dependency>

            <!-- Convergence error corrections -->
            <dependency>
                <groupId>com.google.errorprone</groupId>
                <artifactId>error_prone_annotations</artifactId>
                <version>2.36.0</version>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</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-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-webflux</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>runtime</scope>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.bouncycastle</groupId>
            <artifactId>bcprov-jdk18on</artifactId>
        </dependency>
        <dependency>
            <groupId>org.bouncycastle</groupId>
            <artifactId>bcpkix-jdk18on</artifactId>
        </dependency>
        <dependency>
            <groupId>org.bouncycastle</groupId>
            <artifactId>bcutil-jdk18on</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <!-- JAXB -->
        <dependency>
            <groupId>org.apache.santuario</groupId>
            <artifactId>xmlsec</artifactId>
        </dependency>
        <!-- JAXB -->
        <dependency>
            <groupId>jakarta.xml.bind</groupId>
            <artifactId>jakarta.xml.bind-api</artifactId>
            <version>4.0.2</version>
        </dependency>
        <dependency>
            <groupId>org.glassfish.jaxb</groupId>
            <artifactId>jaxb-runtime</artifactId>
        </dependency>
        <dependency>
            <groupId>javax.activation</groupId>
            <artifactId>activation</artifactId>
            <version>1.1.1</version>
        </dependency>

        <!-- IDsec sig val lib -->
        <dependency>
            <groupId>se.swedenconnect.sigval</groupId>
            <artifactId>sigval-pdf</artifactId>
            <version>${signature-validation.version}</version>
        </dependency>
        <dependency>
            <groupId>se.swedenconnect.sigval</groupId>
            <artifactId>sigval-xml</artifactId>
            <version>${signature-validation.version}</version>
        </dependency>
        <dependency>
            <groupId>se.swedenconnect.sigval</groupId>
            <artifactId>sigval-jose</artifactId>
            <version>${signature-validation.version}</version>
        </dependency>
        <dependency>
            <groupId>se.swedenconnect.sigval</groupId>
            <artifactId>sigvalreport</artifactId>
            <version>${signature-validation.version}</version>
        </dependency>
        <dependency>
            <groupId>se.swedenconnect.opensaml</groupId>
            <artifactId>opensaml-security-ext</artifactId>
            <version>4.1.4</version>
        </dependency>
        <dependency>
            <groupId>se.swedenconnect.security</groupId>
            <artifactId>credentials-support</artifactId>
            <version>2.0.5</version>
        </dependency>

        <!-- Web Jar dependencies -->
        <dependency>
            <groupId>org.webjars</groupId>
            <artifactId>bootstrap</artifactId>
            <version>5.3.3</version>
        </dependency>
        <dependency>
            <groupId>org.webjars</groupId>
            <artifactId>jquery</artifactId>
            <version>3.7.1</version>
        </dependency>
        <dependency>
            <groupId>org.webjars.npm</groupId>
            <artifactId>popper.js</artifactId>
            <version>1.16.1</version>
        </dependency>
        <dependency>
            <groupId>org.webjars.npm</groupId>
            <artifactId>js-cookie</artifactId>
            <version>3.0.5</version>
        </dependency>
        <dependency>
            <groupId>org.webjars</groupId>
            <artifactId>font-awesome</artifactId>
            <version>6.4.0</version>
        </dependency>
        <dependency>
            <groupId>org.webjars</groupId>
            <artifactId>highlightjs</artifactId>
            <version>11.5.0</version>
        </dependency>
        <dependency>
            <groupId>org.webjars.bower</groupId>
            <artifactId>bootstrap-fileinput</artifactId>
            <version>5.5.2</version>
        </dependency>
        <!-- Ensure this matches your current Netty version -->
        <!-- for Apple Silicon, or omit for Intel -->
        <dependency>
            <groupId>io.netty</groupId>
            <artifactId>netty-resolver-dns-native-macos</artifactId>
            <version>4.1.119.Final</version> <!-- Ensure this matches your current Netty version -->
            <classifier>osx-aarch_64</classifier> <!-- for Apple Silicon, or omit for Intel -->
            <scope>runtime</scope>
        </dependency>

    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-enforcer-plugin</artifactId>
                <version>3.1.0</version>
                <executions>
                    <execution>
                        <id>enforce</id>
                        <configuration>
                            <rules>
                                <dependencyConvergence />
                            </rules>
                        </configuration>
                        <goals>
                            <goal>enforce</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
    <profiles>
        <profile>
            <id>css</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>exec-maven-plugin</artifactId>
                        <version>3.1.0</version>
                        <executions>
                            <!-- Step 1: Run npm install -->
                            <execution>
                                <id>npm-install</id>
                                <phase>generate-resources</phase>
                                <goals>
                                    <goal>exec</goal>
                                </goals>
                                <configuration>
                                    <executable>npm</executable>
                                    <arguments>
                                        <argument>install</argument>
                                    </arguments>
                                    <workingDirectory>${project.basedir}/bootstrap</workingDirectory>
                                </configuration>
                            </execution>
                            <!-- Step 2: Run npm build -->
                            <execution>
                                <id>npm-build</id>
                                <phase>generate-resources</phase>
                                <goals>
                                    <goal>exec</goal>
                                </goals>
                                <configuration>
                                    <executable>npm</executable>
                                    <arguments>
                                        <argument>run</argument>
                                        <argument>build</argument>
                                    </arguments>
                                    <workingDirectory>${project.basedir}/bootstrap</workingDirectory>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>

                    <!-- Copy the built CSS to the Spring Boot static folder -->
                    <plugin>
                        <artifactId>maven-resources-plugin</artifactId>
                        <version>3.3.1</version>
                        <executions>
                            <execution>
                                <id>copy-css</id>
                                <phase>generate-resources</phase>
                                <goals>
                                    <goal>copy-resources</goal>
                                </goals>
                                <configuration>
                                    <outputDirectory>${project.basedir}/src/main/resources/static/css</outputDirectory>
                                    <resources>
                                        <resource>
                                            <directory>${project.basedir}/bootstrap/dist/css</directory>
                                            <includes>
                                                <include>*.css</include>
                                            </includes>
                                        </resource>
                                    </resources>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>release</id>
            <!-- See http://central.sonatype.org/pages/apache-maven.html for setup -->
            <build>
                <plugins>
                    <!--
                      See https://central.sonatype.org/publish/publish-portal-maven/
                    -->
                    <plugin>
                        <groupId>org.sonatype.central</groupId>
                        <artifactId>central-publishing-maven-plugin</artifactId>
                        <version>0.7.0</version>
                        <extensions>true</extensions>
                        <configuration>
                            <publishingServerId>central</publishingServerId>
                            <autoPublish>true</autoPublish>
                        </configuration>
                    </plugin>

                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-gpg-plugin</artifactId>
                        <version>3.2.6</version>
                        <executions>
                            <execution>
                                <id>sign-artifacts</id>
                                <phase>verify</phase>
                                <goals>
                                    <goal>sign</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>

                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-source-plugin</artifactId>
                        <version>3.3.1</version>
                        <executions>
                            <execution>
                                <id>attach-sources</id>
                                <goals>
                                    <goal>jar-no-fork</goal>
                                </goals>
                            </execution>
                            <execution>
                                <id>attach-test-sources</id>
                                <goals>
                                    <goal>test-jar-no-fork</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>

                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-javadoc-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>attach-javadoc</id>
                                <goals>
                                    <goal>jar</goal>
                                </goals>
                                <configuration>
                                    <source>${java.version}</source>
                                    <doclint>none</doclint>
                                    <sourceFileExcludes>
                                        <sourceFileExclude>**/generated-sources/**/*.java</sourceFileExclude>
                                    </sourceFileExcludes>
                                    <additionalJOptions>
                                        <additionalJOption>--add-modules</additionalJOption>
                                        <additionalJOption>java.base</additionalJOption>
                                        <additionalJOption>--add-exports</additionalJOption>
                                        <additionalJOption>java.base/sun.security.x509=ALL-UNNAMED</additionalJOption>
                                    </additionalJOptions>
                                    <failOnError>false</failOnError>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>

                </plugins>
            </build>

        </profile>
    </profiles>

</project>
