<?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>in.virit.sb</groupId>
    <artifactId>project-parent</artifactId>
    <name>project-parent</name>
    <description>A parent project (or starter in SB lingo) for Vaadin Flow + Spring Boot apps</description>
    <packaging>pom</packaging>
    <version>0.0.6</version>

    <properties>
        <java.version>17</java.version>
        <resource.delimiter>@</resource.delimiter>
        <maven.compiler.release>${java.version}</maven.compiler.release>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <spring-boot.run.main-class>${start-class}</spring-boot.run.main-class>
        <vaadin.version>24.4.10</vaadin.version>
        <flow.version>24.4.6</flow.version>
        <spring-boot.version>3.3.3</spring-boot.version>
    </properties>

    <organization>
        <name>Viritin</name>
    </organization>
    <url>https://github.com/viritin/viritin-sb</url>
    <developers>
        <developer>
            <name>Matti Tahvonen</name>
        </developer>
    </developers>
    <scm>
        <url>https://github.com/viritin/viritin-sb</url>
        <connection>scm:git:git://github.com/viritin/viritin-sb.git</connection>
        <developerConnection>scm:git:ssh://git@github.com:/viritin/viritin-sb.git</developerConnection>
        <tag>project-parent-0.0.6</tag>
    </scm>

    <issueManagement>
        <system>GitHub</system>
        <url>https://github.com/viritin/viritin-sb/issues</url>
    </issueManagement>
    <licenses>
        <license>
            <name>Apache 2</name>
            <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
            <distribution>repo</distribution>
        </license>
    </licenses>
    
    <dependencyManagement>
        <dependencies>
            <dependency>
                <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.vaadin</groupId>
                <artifactId>vaadin-bom</artifactId>
                <version>${vaadin.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>
  
    <dependencies>
        <dependency>
            <groupId>com.vaadin</groupId>
            <artifactId>vaadin-spring-boot-starter</artifactId>
            <version>${vaadin.version}</version>
            <exclusions>
                <exclusion>
                    <groupId>com.vaadin</groupId>
                    <artifactId>vaadin-dev</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        
        <dependency>
            <groupId>com.vaadin</groupId>
            <artifactId>vaadin-dev</artifactId>
            <scope>test</scope>
        </dependency>

        <!-- A tooling from here kicks in to enforece dev mod if present. In an ideal situation, this logic would be in vaadin development mode. -->
        <dependency>
            <groupId>in.virit.sb</groupId>
            <artifactId>sb-configs</artifactId>
            <version>0.0.2</version>
        </dependency>
        
    </dependencies>
    
    
    <build>
        <plugins>
            <plugin>
                <!-- Note: using flow-maven-plugin directly as the vaadin-maven-plugin causes some (obsolete) executions unknown to me... -->
                <groupId>com.vaadin</groupId>
                <artifactId>flow-maven-plugin</artifactId>
                <version>${flow.version}</version>
                <!-- Configure front-end build "production bundle" when a deployment artifact is packaged. No special profiles neede. -->
                <executions>
                    <execution>
                        <id>frontend</id>
                        <!-- Not yet on compile, but before actual packaging -->
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>prepare-frontend</goal>
                            <goal>build-frontend</goal>
                        </goals>
                    </execution>
                </executions>
                <dependencies>
                    <dependency>
                        <groupId>com.vaadin</groupId>
                        <artifactId>vaadin-prod-bundle</artifactId>
                        <version>${vaadin.version}</version>
                    </dependency>
                    <!-- Dev bundle is needed to copy package-lock file from it to the project, -->
                    <!-- this speeds up the production bundle build -->
                    <dependency>
                        <groupId>com.vaadin</groupId>
                        <artifactId>vaadin-dev-bundle</artifactId>
                        <version>${vaadin.version}</version>
                    </dependency>
                </dependencies>
            </plugin>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <version>${spring-boot.version}</version>
                <executions>
                    <execution>
                        <id>repackage</id>
                        <goals>
                            <goal>repackage</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <mainClass>${spring-boot.run.main-class}</mainClass>
                </configuration>
            </plugin>
        </plugins>
    </build>
    
    
    <profiles>
        <profile>
            <id>release</id>
            <properties>
                <altReleaseDeploymentRepository>releases::https://oss.sonatype.org/service/local/staging/deploy/maven2/</altReleaseDeploymentRepository>
            </properties>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-release-plugin</artifactId>
                        <version>3.1.0</version>
                        <configuration>
                            <autoVersionSubmodules>true</autoVersionSubmodules>
                            <useReleaseProfile>false</useReleaseProfile>
                            <releaseProfiles>release</releaseProfiles>
                            <goals>deploy</goals>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>flatten-maven-plugin</artifactId>
                        <version>1.6.0</version>
                        <configuration>
                            <flattenMode>oss</flattenMode>
                        </configuration>
                        <executions>
                            <execution>
                                <id>flatten</id>
                                <phase>process-resources</phase>
                                <goals>
                                    <goal>flatten</goal>
                                </goals>
                            </execution>
                            <execution>
                                <id>flatten.clean</id>
                                <phase>clean</phase>
                                <goals>
                                    <goal>clean</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.sonatype.plugins</groupId>
                        <artifactId>nexus-staging-maven-plugin</artifactId>
                        <version>1.7.0</version>
                        <extensions>true</extensions>
                        <configuration>
                            <serverId>ossrh</serverId>
                            <nexusUrl>https://oss.sonatype.org/</nexusUrl>
                            <autoReleaseAfterClose>true</autoReleaseAfterClose>
                        </configuration>
                    </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>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-javadoc-plugin</artifactId>
                        <version>3.7.0</version>
                        <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>
                        <executions>
                            <execution>
                                <id>sign-artifacts</id>
                                <phase>verify</phase>
                                <goals>
                                    <goal>sign</goal>
                                </goals>
                            </execution>
                        </executions>
                        <configuration>
                            <!-- Prevent gpg from using pinentry programs -->
                            <gpgArguments>
                                <arg>--pinentry-mode</arg>
                                <arg>loopback</arg>
                            </gpgArguments>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

</project>