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

    <groupId>fi.jubic</groupId>
    <artifactId>snoozy-starter-parent</artifactId>
    <version>0.9.3</version>
    <packaging>pom</packaging>

    <name>snoozy-starter-parent</name>
    <description>Recommended starter application pom</description>
    <url>https://github.com/jubicoy/snoozy</url>
    <licenses>
        <license>
            <name>MIT License</name>
            <url>http://www.opensource.org/licenses/mit-license.php</url>
            <distribution>repo</distribution>
        </license>
    </licenses>
    <scm>
        <url>https://github.com/jubicoy/snoozy-starter</url>
    </scm>
    <developers>
        <developer>
            <name>Aleksi Gold</name>
            <email>aleksi.gold@jubic.fi</email>
        </developer>
        <developer>
            <name>Vilppu Vuorinen</name>
            <email>vilppu.vuorinen@jubic.fi</email>
        </developer>
    </developers>

    <distributionManagement>
        <snapshotRepository>
            <id>ossrh</id>
            <url>https://s01.oss.sonatype.org/content/repositories/snapshots</url>
        </snapshotRepository>
        <repository>
            <id>ossrh</id>
            <url>https://s01.oss.sonatype.org/content/repositories/snapshots</url>
        </repository>
    </distributionManagement>

    <modules>
        <module>snoozy-starter</module>
        <module>snoozy-starter-jooq</module>
    </modules>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <snoozy.version>0.9.1</snoozy.version>
        <dagger.version>2.45</dagger.version>
        <easyconfig.version>0.9.2</easyconfig.version>
        <easyvalue.version>1.3.8</easyvalue.version>
        <spotbugs.version>4.7.3.4</spotbugs.version>
        <findsecbugs.version>1.12.0</findsecbugs.version>
        <snoozy.front.testPhase>test</snoozy.front.testPhase>
        <snoozy.linter.execPhase>test</snoozy.linter.execPhase>
    </properties>

    <dependencies>
        <dependency>
            <groupId>fi.jubic</groupId>
            <artifactId>easyconfig-core</artifactId>
            <version>${easyconfig.version}</version>
        </dependency>
        <dependency>
            <groupId>fi.jubic</groupId>
            <artifactId>easyconfig-snoozy</artifactId>
            <version>${easyconfig.version}</version>
        </dependency>
        <dependency>
            <groupId>fi.jubic</groupId>
            <artifactId>easyconfig-logback</artifactId>
            <version>${easyconfig.version}</version>
        </dependency>
        <dependency>
            <groupId>fi.jubic</groupId>
            <artifactId>snoozy-auth</artifactId>
            <version>${snoozy.version}</version>
        </dependency>
        <dependency>
            <groupId>fi.jubic</groupId>
            <artifactId>snoozy-core</artifactId>
            <version>${snoozy.version}</version>
        </dependency>
        <dependency>
            <groupId>fi.jubic</groupId>
            <artifactId>snoozy-undertow</artifactId>
            <version>${snoozy.version}</version>
        </dependency>

        <dependency>
            <groupId>com.google.dagger</groupId>
            <artifactId>dagger</artifactId>
            <version>${dagger.version}</version>
        </dependency>
        <dependency>
            <groupId>com.google.dagger</groupId>
            <artifactId>dagger-compiler</artifactId>
            <version>${dagger.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>fi.jubic</groupId>
            <artifactId>easyvalue</artifactId>
            <version>${easyvalue.version}</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>fi.jubic</groupId>
            <artifactId>snoozy-test</artifactId>
            <version>${snoozy.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-api</artifactId>
            <version>5.9.2</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-engine</artifactId>
            <version>5.9.2</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-core</artifactId>
            <version>5.2.0</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-junit-jupiter</artifactId>
            <version>5.2.0</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.11.0</version>
                    <configuration>
                        <source>11</source>
                        <target>11</target>
                        <annotationProcessorPaths>
                            <path>
                                <groupId>com.google.dagger</groupId>
                                <artifactId>dagger-compiler</artifactId>
                                <version>${dagger.version}</version>
                            </path>
                            <path>
                                <groupId>fi.jubic</groupId>
                                <artifactId>easyvalue</artifactId>
                                <version>${easyvalue.version}</version>
                            </path>
                        </annotationProcessorPaths>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <version>3.0.0</version>
                </plugin>
                <plugin>
                    <groupId>org.jacoco</groupId>
                    <artifactId>jacoco-maven-plugin</artifactId>
                    <version>0.8.9</version>
                    <executions>
                        <execution>
                            <goals>
                                <goal>prepare-agent</goal>
                            </goals>
                        </execution>
                        <execution>
                            <id>report</id>
                            <phase>test</phase>
                            <goals>
                                <goal>report</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-jar-plugin</artifactId>
                    <version>3.3.0</version>
                    <configuration>
                        <archive>
                            <manifest>
                                <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
                                <addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
                            </manifest>
                        </archive>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-shade-plugin</artifactId>
                    <version>3.4.1</version>
                </plugin>
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>exec-maven-plugin</artifactId>
                    <version>3.1.0</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-resources-plugin</artifactId>
                    <version>3.3.1</version>
                </plugin>
            </plugins>
        </pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-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-enforcer-plugin</artifactId>
                <version>3.3.0</version>
                <executions>
                    <execution>
                        <id>enforce-properties</id>
                        <goals>
                            <goal>enforce</goal>
                        </goals>
                        <configuration>
                            <rules>
                                <requireProperty>
                                    <property>snoozy.mainClass</property>
                                    <message>Set snoozy.mainClass property to main class name</message>
                                    <regex>^([\p{L}_$][\p{L}\p{N}_$]*\.)*[\p{L}_$][\p{L}\p{N}_$]*$</regex>
                                    <regexMessage>Set snoozy.mainClass property to main class name. Use the qualified class name.</regexMessage>
                                </requireProperty>
                            </rules>
                            <fail>true</fail>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>com.github.spotbugs</groupId>
                <artifactId>spotbugs-maven-plugin</artifactId>
                <version>${spotbugs.version}</version>
                <executions>
                    <execution>
                        <id>check</id>
                        <phase>${snoozy.linter.execPhase}</phase>
                        <goals>
                            <goal>check</goal>
                        </goals>
                    </execution>
                </executions>
                <dependencies>
                    <dependency>
                        <groupId>fi.jubic</groupId>
                        <artifactId>snoozy-starter-resources</artifactId>
                        <version>0.2.0</version>
                    </dependency>
                </dependencies>
                <configuration>
                    <excludeFilterFile>spotbugs-exclude.xml</excludeFilterFile>
                    <plugins>
                        <plugin>
                            <groupId>com.h3xstream.findsecbugs</groupId>
                            <artifactId>findsecbugs-plugin</artifactId>
                            <version>${findsecbugs.version}</version>
                        </plugin>
                    </plugins>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.owasp</groupId>
                <artifactId>dependency-check-maven</artifactId>
                <version>8.2.1</version>
                <configuration>
                    <failBuildOnCVSS>1</failBuildOnCVSS>
                    <cveValidForHours>168</cveValidForHours>
                    <suppressionFile>suppressions.xml</suppressionFile>
                    <assemblyAnalyzerEnabled>false</assemblyAnalyzerEnabled>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-checkstyle-plugin</artifactId>
                <version>3.2.1</version>
                <configuration>
                    <configLocation>checkstyle.xml</configLocation>
                    <encoding>UTF-8</encoding>
                    <consoleOutput>true</consoleOutput>
                    <failsOnError>true</failsOnError>
                    <failOnViolation>true</failOnViolation>
                    <linkXRef>false</linkXRef>
                    <sourceDirectories>
                        <sourceDirectory>${project.build.sourceDirectory}</sourceDirectory>
                        <sourceDirectory>${project.build.testSourceDirectory}</sourceDirectory>
                    </sourceDirectories>
                </configuration>
                <executions>
                    <execution>
                        <id>check</id>
                        <phase>${snoozy.linter.execPhase}</phase>
                        <goals>
                            <goal>check</goal>
                        </goals>
                    </execution>
                </executions>
                <dependencies>
                    <dependency>
                        <groupId>com.puppycrawl.tools</groupId>
                        <artifactId>checkstyle</artifactId>
                        <version>10.9.3</version>
                    </dependency>
                    <dependency>
                        <groupId>fi.jubic</groupId>
                        <artifactId>checkstyle</artifactId>
                        <version>0.4.0</version>
                    </dependency>
                </dependencies>
            </plugin>
            <plugin>
                <groupId>com.google.cloud.tools</groupId>
                <artifactId>jib-maven-plugin</artifactId>
                <version>3.3.1</version>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>starter-release</id>
            <activation>
                <activeByDefault>false</activeByDefault>
            </activation>
            <properties>
                <snoozy.dev>true</snoozy.dev>
                <enforcer.skip>true</enforcer.skip>
            </properties>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-gpg-plugin</artifactId>
                        <version>3.0.1</version>
                        <executions>
                            <execution>
                                <id>sign-artifacts</id>
                                <phase>verify</phase>
                                <goals>
                                    <goal>sign</goal>
                                </goals>
                                <configuration>
                                    <gpgArguments>
                                        <arg>--pinentry-mode</arg>
                                        <arg>loopback</arg>
                                    </gpgArguments>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.sonatype.plugins</groupId>
                        <artifactId>nexus-staging-maven-plugin</artifactId>
                        <version>1.6.13</version>
                        <extensions>true</extensions>
                        <configuration>
                            <serverId>ossrh</serverId>
                            <nexusUrl>https://s01.oss.sonatype.org/</nexusUrl>
                            <autoReleaseAfterClose>true</autoReleaseAfterClose>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>shade</id>
            <activation>
                <activeByDefault>false</activeByDefault>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-shade-plugin</artifactId>
                        <configuration>
                            <createDependencyReducedPom>true</createDependencyReducedPom>
                            <filters>
                                <filter>
                                    <artifact>*:*</artifact>
                                    <excludes>
                                        <exclude>module-info.class</exclude>
                                        <exclude>META-INF/*.SF</exclude>
                                        <exclude>META-INF/*.DSA</exclude>
                                        <exclude>META-INF/*.RSA</exclude>
                                    </excludes>
                                </filter>
                                <filter>
                                    <artifact>com.google.code.findbugs:jsr305</artifact>
                                    <excludes>
                                        <exclude>javax/annotation/**</exclude>
                                    </excludes>
                                </filter>
                                <filter>
                                    <artifact>net.jcip:jcip-annotations</artifact>
                                    <excludes>
                                        <exclude>net/jcip/annotations/**</exclude>
                                    </excludes>
                                </filter>
                            </filters>
                            <artifactSet>
                                <excludes>
                                    <exclude>org.jboss.spec.javax.servlet:*</exclude>
                                    <exclude>org.jboss.spec.javax.ws.rs:*</exclude>
                                    <exclude>org.jboss.spec.javax.annotation:*</exclude>
                                    <exclude>org.jboss.spec.javax.xml.bind:*</exclude>
                                </excludes>
                            </artifactSet>
                        </configuration>
                        <executions>
                            <execution>
                                <phase>package</phase>
                                <goals>
                                    <goal>shade</goal>
                                </goals>
                                <configuration>
                                    <transformers>
                                        <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
                                        <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                            <mainClass>${snoozy.mainClass}</mainClass>
                                        </transformer>
                                    </transformers>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>front</id>
            <activation>
                <property>
                    <name>!snoozy.dev</name>
                </property>
                <file>
                    <exists>${basedir}/front/package.json</exists>
                </file>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>exec-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>npm install</id>
                                <goals><goal>exec</goal></goals>
                                <phase>process-resources</phase>
                                <configuration>
                                    <executable>npm</executable>
                                    <workingDirectory>${basedir}/front/</workingDirectory>
                                    <arguments>
                                        <argument>ci</argument>
                                        <argument>--prefer-offline</argument>
                                    </arguments>
                                </configuration>
                            </execution>
                            <execution>
                                <id>npm run build</id>
                                <goals><goal>exec</goal></goals>
                                <phase>process-resources</phase>
                                <configuration>
                                    <executable>npm</executable>
                                    <workingDirectory>${basedir}/front/</workingDirectory>
                                    <arguments>
                                        <argument>run</argument>
                                        <argument>build</argument>
                                    </arguments>
                                    <environmentVariables>
                                        <NODE_ENV>production</NODE_ENV>
                                        <APPLICATION_VERSION>${project.version}</APPLICATION_VERSION>
                                    </environmentVariables>
                                </configuration>
                            </execution>
                            <execution>
                                <id>npm test</id>
                                <goals><goal>exec</goal></goals>
                                <phase>${snoozy.front.testPhase}</phase>
                                <configuration>
                                    <executable>npm</executable>
                                    <workingDirectory>${basedir}/front</workingDirectory>
                                    <arguments>
                                        <argument>test</argument>
                                    </arguments>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-resources-plugin</artifactId>
                        <version>3.3.1</version>
                        <executions>
                            <execution>
                                <id>copy static assets</id>
                                <phase>compile</phase>
                                <goals>
                                    <goal>
                                        copy-resources
                                    </goal>
                                </goals>
                                <configuration>
                                    <outputDirectory>${project.basedir}/target/classes/static</outputDirectory>
                                    <resources>
                                        <resource>
                                            <directory>front/build</directory>
                                        </resource>
                                    </resources>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>skip-tests</id>
            <activation>
                <property>
                    <name>skipTests</name>
                </property>
            </activation>
            <properties>
                <snoozy.front.testPhase>none</snoozy.front.testPhase>
                <snoozy.linter.execPhase>none</snoozy.linter.execPhase>
            </properties>
        </profile>
    </profiles>
</project>
