<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>no.bekk.db-scheduler-ui</groupId>
    <artifactId>db-scheduler-ui-parent</artifactId>
    <version>3.2.0</version>
    <packaging>pom</packaging>

    <name>db-scheduler-ui: Parent</name>
    <description>Provides a UI for db-scheduler</description>
    <url>https://github.com/bekk/db-scheduler-ui</url>
    <inceptionYear>2023</inceptionYear>

    <licenses>
        <license>
            <name>The Apache Software License, Version 2.0</name>
            <url>https://www.apache.org/licenses/LICENSE-2.0.txt</url>
            <distribution>repo</distribution>
        </license>
    </licenses>

    <developers>
        <developer>
            <name>Svein Manum</name>
            <email>svein.manum@bekk.no</email>
        </developer>
        <developer>
            <name>Johanna Björemo</name>
            <email>johanna.bjoremo@bekk.no</email>
        </developer>
        <developer>
            <name>Eskil Torland</name>
            <email>eskil.torland@bekk.no</email>
        </developer>
        <developer>
            <name>Vegard Rognstad Smines</name>
            <email>vegard.smines@bekk.no</email>
        </developer>
        <developer>
            <name>Geir Sagberg</name>
            <email>geir.sagberg@bekk.no</email>
        </developer>
    </developers>

    <modules>
        <module>db-scheduler-ui</module>
        <module>db-scheduler-ui-starter</module>
        <module>example-app</module>
        <module>example-app-webflux</module>
    </modules>

    <scm>
        <connection>scm:git:https://github.com/bekk/db-scheduler-ui.git</connection>
        <developerConnection>scm:git:https://github.com/bekk/db-scheduler-ui.git</developerConnection>
        <tag>HEAD</tag>
        <url>https://github.com/bekk/db-scheduler-ui.git</url>
    </scm>

    <distributionManagement>
        <repository>
            <id>ossrh</id>
            <url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
        </repository>
        <snapshotRepository>
            <id>ossrh</id>
            <url>https://oss.sonatype.org/content/repositories/snapshots</url>
        </snapshotRepository>
    </distributionManagement>

    <properties>
        <maven.compiler.release>11</maven.compiler.release>
        <spring-boot.version>2.7.18</spring-boot.version>
        <db-scheduler.version>14.0.0</db-scheduler.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.junit</groupId>
                <artifactId>junit-bom</artifactId>
                <version>5.10.2</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
            <dependency>
                <!-- Import dependency management from Spring Boot -->
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-dependencies</artifactId>
                <version>${spring-boot.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
            <dependency>
                <groupId>com.github.kagkarlsson</groupId>
                <artifactId>db-scheduler</artifactId>
                <version>${db-scheduler.version}</version>
            </dependency>
            <dependency>
                <groupId>com.github.kagkarlsson</groupId>
                <artifactId>db-scheduler-spring-boot-starter</artifactId>
                <version>${db-scheduler.version}</version>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <dependencies>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <scope>provided</scope>
        </dependency>
    </dependencies>

    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <version>3.3.0</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-deploy-plugin</artifactId>
                    <version>3.1.2</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.13.0</version>
                    <configuration>
                        <parameters>true</parameters>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-javadoc-plugin</artifactId>
                    <version>3.7.0</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-source-plugin</artifactId>
                    <version>3.3.1</version>
                </plugin>
                <plugin>
                    <groupId>org.jreleaser</groupId>
                    <artifactId>jreleaser-maven-plugin</artifactId>
                    <version>1.12.0</version>
                    <configuration>
                        <jreleaser>
                            <release>
                                <github>
                                    <enabled>true</enabled>
                                    <skipTag>true</skipTag>
                                    <skipRelease>true</skipRelease>
                                </github>
                            </release>
                        </jreleaser>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>
        <plugins>
            <plugin>
                <artifactId>maven-surefire-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>com.diffplug.spotless</groupId>
                <artifactId>spotless-maven-plugin</artifactId>
                <version>2.43.0</version>
                <configuration>
                    <java>
                        <includes>
                            <include>src/main/java/**/*.java</include>
                            <!-- Check application code -->
                            <include>src/test/java/**/*.java</include>
                            <!-- Check application tests
                            code -->
                        </includes>
                        <googleJavaFormat>
                            <version>1.17.0</version>
                            <style>GOOGLE</style>
                        </googleJavaFormat>
                        <importOrder/>
                        <removeUnusedImports/>
                        <toggleOffOn/>
                        <trimTrailingWhitespace/>
                        <endWithNewline/>
                    </java>
                </configuration>
            </plugin>
            <plugin>
                <groupId>com.github.ekryd.sortpom</groupId>
                <artifactId>sortpom-maven-plugin</artifactId>
                <version>3.3.0</version>
                <configuration>
                    <nrOfIndentSpace>4</nrOfIndentSpace>
                    <createBackupFile>false</createBackupFile>
                    <sortDependencies>scope,groupId,artifactId</sortDependencies>
                    <expandEmptyElements>false</expandEmptyElements>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-javadoc-plugin</artifactId>
                <configuration>
                    <doclint>none</doclint>
                </configuration>
                <executions>
                    <execution>
                        <id>attach-javadocs</id>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-gpg-plugin</artifactId>
                <version>3.2.4</version>
                <configuration>
                    <gpgArguments>
                        <arg>--pinentry-mode</arg>
                        <arg>loopback</arg>
                    </gpgArguments>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.jreleaser</groupId>
                <artifactId>jreleaser-maven-plugin</artifactId>
                <inherited>false</inherited>
                <configuration>
                    <jreleaser>
                        <signing>
                            <active>ALWAYS</active>
                            <armored>true</armored>
                        </signing>
                        <release>
                            <github>
                                <enabled>true</enabled>
                                <skipTag>true</skipTag>
                                <skipRelease>true</skipRelease>
                            </github>
                        </release>
                        <deploy>
                            <maven>
                                <nexus2>
                                    <maven-central>
                                        <active>ALWAYS</active>
                                        <url>https://oss.sonatype.org/service/local/</url>
                                        <snapshotUrl>https://oss.sonatype.org/content/repositories/snapshots
                                        </snapshotUrl>
                                        <closeRepository>true</closeRepository>
                                        <releaseRepository>true</releaseRepository>
                                        <stagingRepositories>target/staging-deploy</stagingRepositories>
                                    </maven-central>
                                </nexus2>
                            </maven>
                        </deploy>
                    </jreleaser>
                </configuration>
            </plugin>
            <plugin>
                <groupId>com.mycila</groupId>
                <artifactId>license-maven-plugin</artifactId>
                <version>4.5</version>
                <configuration>
                    <mapping>
                        <ts>SLASHSTAR_STYLE</ts>
                        <tsx>SLASHSTAR_STYLE</tsx>
                    </mapping>
                    <licenseSets>
                        <licenseSet>
                            <header>./.license/license-header.txt</header>
                            <includes>
                                <include>**/*.java</include>
                                <include>**/*.tsx</include>
                                <include>**/*.ts</include>
                            </includes>
                            <excludes>
                                <exclude>.github/**</exclude>
                                <exclude>**/src/test/**</exclude>
                            </excludes>
                        </licenseSet>
                    </licenseSets>
                    <failIfMissing>true</failIfMissing>
                </configuration>
                <executions>
                    <execution>
                        <id>check-license-header</id>
                        <goals>
                            <goal>check</goal>
                        </goals>
                        <phase>test</phase>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-clean-plugin</artifactId>
                <version>3.4.0</version>
                <configuration>
                    <filesets>
                        <fileset>
                            <directory>frontend/node_modules</directory>
                            <directory>db-scheduler-ui/src/main/resources/static</directory>
                            <directory>db-scheduler-ui/src/main/resources/templates</directory>
                        </fileset>
                    </filesets>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>3.3.0</version>
                <inherited>false</inherited>
                <executions>
                    <execution>
                        <id>npm-install</id>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                        <configuration>
                            <executable>npm</executable>
                            <arguments>
                                <argument>install</argument>
                            </arguments>
                            <workingDirectory>./db-scheduler-ui-frontend</workingDirectory>
                        </configuration>
                    </execution>
                    <execution>
                        <id>npm-build</id>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                        <phase>generate-resources</phase>
                        <configuration>
                            <executable>npm</executable>
                            <arguments>
                                <argument>run</argument>
                                <argument>build</argument>
                            </arguments>
                            <workingDirectory>./db-scheduler-ui-frontend</workingDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <artifactId>maven-resources-plugin</artifactId>
                <version>3.3.1</version>
                <executions>
                    <execution>
                        <id>copy-files-to-backend</id>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <phase>process-classes</phase>
                        <configuration>
                            <encoding>UTF-8</encoding>
                            <outputDirectory>db-scheduler-ui/src/main/resources/static/db-scheduler</outputDirectory>
                            <resources>
                                <resource>
                                    <directory>db-scheduler-ui-frontend/dist</directory>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>

                </executions>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>publication</id>
            <properties>
                <altDeploymentRepository>local::file:./target/staging-deploy</altDeploymentRepository>
            </properties>
            <build>
                <defaultGoal>deploy</defaultGoal>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-javadoc-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>attach-javadocs</id>
                                <goals>
                                    <goal>jar</goal>
                                </goals>
                                <configuration>
                                    <attach>true</attach>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-source-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>attach-sources</id>
                                <goals>
                                    <goal>jar</goal>
                                </goals>
                                <configuration>
                                    <attach>true</attach>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
