<?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">
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.7.3</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <modules>
        <module>liquibase-r2dbc-spring-boot-starter</module>
        <module>examples/mysql</module>
        <module>examples/postgresql</module>
        <module>examples/h2/file</module>
        <module>examples/h2/mem</module>
        <module>examples/mariadb</module>
    </modules>
    <packaging>pom</packaging>
    <modelVersion>4.0.0</modelVersion>
    <groupId>io.github.daggerok</groupId>
    <artifactId>liquibase-r2dbc-spring-boot-starter-parent</artifactId>
    <version>2.1.2</version>
    <name>${project.artifactId}</name>
    <description>The liquibase-r2dbc-spring-boot-starter maven parent project</description>
    <url>https://github.com/daggerok/liquibase-r2dbc-spring-boot-starter</url>
    <developers>
        <developer>
            <name>Maksim Kostromin</name>
            <email>daggerok@gmail.com</email>
            <organization>Sets of open source Maksim Kostromin aka daggerok projects</organization>
            <organizationUrl>https://github.com/daggerok/</organizationUrl>
        </developer>
    </developers>
    <organization>
        <name>Maksim Kostromin aka daggerok open source projects sets</name>
        <url>https://github.com/daggerok/</url>
    </organization>
    <licenses>
        <license>
            <name>MIT License</name>
            <distribution>repo</distribution>
            <!-- <url>https://opensource.org/licenses/MIT</url> -->
            <url>https://github.com/daggerok/liquibase-r2dbc-spring-boot-starter/blob/master/LICENSE</url>
        </license>
    </licenses>
    <scm>
        <developerConnection>scm:git:git@github.com:daggerok/liquibase-r2dbc-spring-boot-starter.git</developerConnection>
        <connection>scm:git:https://github.com/daggerok/liquibase-r2dbc-spring-boot-starter.git</connection>
        <url>https://github.com/daggerok/liquibase-r2dbc-spring-boot-starter</url>
        <!-- <tag>master</tag> -->
        <tag>HEAD</tag>
    </scm>
    <properties>
        <gpg.skip>true</gpg.skip>
        <kotlin.version>1.7.10</kotlin.version>
        <spring-boot.version>2.7.3</spring-boot.version>
        <testcontainers.version>1.17.3</testcontainers.version>
        <r2dbc-mysql.version>0.8.2.RELEASE</r2dbc-mysql.version>
        <log4j-api-kotlin.version>1.2.0</log4j-api-kotlin.version>
        <maven-gpg-plugin.version>3.0.1</maven-gpg-plugin.version>
        <webjars.npm.mvp.css.version>1.8.0</webjars.npm.mvp.css.version>
        <javax.activation-api.version>1.2.0</javax.activation-api.version>
        <frontend-maven-plugin.version>1.12.1</frontend-maven-plugin.version>
        <frontend-maven-plugin.npmVersion>8.16.0</frontend-maven-plugin.npmVersion>
        <frontend-maven-plugin.nodeVersion>v18.7.0</frontend-maven-plugin.nodeVersion>
        <nexus-staging-maven-plugin.version>1.6.13</nexus-staging-maven-plugin.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.jetbrains.kotlin</groupId>
            <artifactId>kotlin-reflect</artifactId>
        </dependency>
        <dependency>
            <groupId>org.jetbrains.kotlin</groupId>
            <artifactId>kotlin-stdlib-jdk8</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-api-kotlin</artifactId>
        </dependency>
        <!--  -->
        <dependency>
            <groupId>io.projectreactor.kotlin</groupId>
            <artifactId>reactor-kotlin-extensions</artifactId>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.jetbrains.kotlinx</groupId>
            <artifactId>kotlinx-coroutines-reactor</artifactId>
            <optional>true</optional>
        </dependency>
        <!--  -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-configuration-processor</artifactId>
            <optional>true</optional>
        </dependency>
        <!--  -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>io.projectreactor</groupId>
            <artifactId>reactor-test</artifactId>
            <scope>test</scope>
        </dependency>
        <!--  -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-r2dbc</artifactId>
            <scope>test</scope>
        </dependency>
        <!--  -->
        <dependency>
            <groupId>org.testcontainers</groupId>
            <artifactId>junit-jupiter</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.testcontainers</groupId>
            <artifactId>mysql</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.testcontainers</groupId>
            <artifactId>mariadb</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.testcontainers</groupId>
            <artifactId>postgresql</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.testcontainers</groupId>
            <artifactId>mssqlserver</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.testcontainers</groupId>
                <artifactId>testcontainers-bom</artifactId>
                <version>${testcontainers.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
            <dependency>
                <groupId>org.apache.logging.log4j</groupId>
                <artifactId>log4j-api-kotlin</artifactId>
                <version>${log4j-api-kotlin.version}</version>
                <type>jar</type>
            </dependency>
        </dependencies>
    </dependencyManagement>
    <build>
        <defaultGoal>verify</defaultGoal>
        <sourceDirectory>${project.basedir}/src/main/kotlin</sourceDirectory>
        <testSourceDirectory>${project.basedir}/src/test/kotlin</testSourceDirectory>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-maven-plugin</artifactId>
                    <executions>
                        <execution>
                            <goals>
                                <goal>build-info</goal>
                                <goal>repackage</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.jetbrains.kotlin</groupId>
                <artifactId>kotlin-maven-plugin</artifactId>
                <configuration>
                    <args>
                        <arg>-Xjsr305=strict</arg>
                    </args>
                    <compilerPlugins>
                        <plugin>spring</plugin>
                    </compilerPlugins>
                </configuration>
                <dependencies>
                    <dependency>
                        <groupId>org.jetbrains.kotlin</groupId>
                        <artifactId>kotlin-maven-allopen</artifactId>
                        <version>${kotlin.version}</version>
                    </dependency>
                </dependencies>
                <executions>
                    <execution>
                        <id>kapt</id>
                        <goals>
                            <goal>kapt</goal>
                        </goals>
                        <configuration>
                            <sourceDirs>
                                <sourceDir>src/main/kotlin</sourceDir>
                            </sourceDirs>
                            <annotationProcessorPaths>
                                <annotationProcessorPath>
                                    <groupId>org.springframework.boot</groupId>
                                    <artifactId>spring-boot-configuration-processor</artifactId>
                                    <version>${spring-boot.version}</version>
                                </annotationProcessorPath>
                            </annotationProcessorPaths>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-source-plugin</artifactId>
                <executions>
                    <execution>
                        <phase>generate-sources</phase>
                        <id>attach-sources</id>
                        <goals>
                            <goal>jar-no-fork</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>build-helper-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>fix-kotlin-missing-javadoc-and-attach-empty-archive-instead</id>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>attach-artifact</goal>
                        </goals>
                        <configuration>
                            <artifacts>
                                <artifact>
                                    <!--suppress UnresolvedMavenProperty -->
                                    <file>${maven.multiModuleProjectDirectory}/.ossrh/kotlin-empty-javadoc.zip</file>
                                    <type>jar</type>
                                    <classifier>javadoc</classifier>
                                </artifact>
                            </artifacts>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-gpg-plugin</artifactId>
                <version>${maven-gpg-plugin.version}</version>
                <configuration>
                    <skip>${gpg.skip}</skip>
                </configuration>
                <executions>
                    <execution>
                        <phase>verify</phase>
                        <id>sign-artifacts</id>
                        <goals>
                            <goal>sign</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
    <profiles>
        <profile>
            <id>set-npm-version</id>
            <activation>
                <file>
                    <exists>./docs/package.json</exists>
                </file>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>com.github.eirslett</groupId>
                        <artifactId>frontend-maven-plugin</artifactId>
                        <version>${frontend-maven-plugin.version}</version>
                        <configuration>
                            <!--suppress UnresolvedMavenProperty -->
                            <installDirectory>${maven.multiModuleProjectDirectory}/target</installDirectory>
                            <workingDirectory>${maven.multiModuleProjectDirectory}/docs</workingDirectory>
                            <nodeVersion>${frontend-maven-plugin.nodeVersion}</nodeVersion>
                            <npmVersion>${frontend-maven-plugin.npmVersion}</npmVersion>
                        </configuration>
                        <executions>
                            <execution>
                                <phase>initialize</phase>
                                <id>install node and npm</id>
                                <goals>
                                    <goal>install-node-and-npm</goal>
                                </goals>
                            </execution>
                            <execution>
                                <phase>initialize</phase>
                                <id>npm version ${project.version}</id>
                                <goals>
                                    <goal>npm</goal>
                                </goals>
                                <configuration>
                                    <arguments>version ${project.version} --allow-same-version</arguments>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>template-variables-substitutions</id>
            <activation>
                <file>
                    <exists>./src/main/templates</exists>
                </file>
            </activation>
            <build>
                <resources>
                    <resource>
                        <directory>./src/main/templates</directory>
                        <filtering>true</filtering>
                    </resource>
                </resources>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-resources-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>template-variables-substitutions</id>
                                <phase>initialize</phase>
                                <goals>
                                    <goal>resources</goal>
                                </goals>
                                <configuration>
                                    <delimiters>
                                        <delimiter>${*}</delimiter>
                                    </delimiters>
                                    <outputDirectory>./</outputDirectory>
                                    <overwrite>true</overwrite>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>local-publish</id>
            <!--
                This profile must be used to simply verify how local maven publishing with works:

                ./mvnw clean ; ./mvnw -DskipTests -P local-publish -Dgpg.passphrase=yourPassphrase
            -->
            <build>
                <defaultGoal>clean deploy</defaultGoal>
            </build>
            <distributionManagement>
                <repository>
                    <id>local-maven-repo</id>
                    <!--suppress UnresolvedMavenProperty -->
                    <url>file://${maven.multiModuleProjectDirectory}/target/.m2/repository</url>
                </repository>
            </distributionManagement>
        </profile>
        <profile>
            <id>local-release</id>
            <!--
                This profile can be used if you want to:
                    - change x.y.z-SNAPSHOT version to released x.y.z
                    - commit that change
                    - create x.y.z git tag
                    - change x.y.z version to next development x.y.(z+1)-SNAPSHOT
                    - commit that change
                    - and finally publish everything to GitHub

                ./mvnw -B -P local-release
            -->
            <build>
                <defaultGoal>release:clean release:prepare release:perform</defaultGoal>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-release-plugin</artifactId>
                        <configuration>
                            <releaseProfiles>local-publish</releaseProfiles>
                            <arguments>-B -DskipTests -Dmaven.deploy.skip=true -DgenerateBackupPoms=false</arguments>
                            <autoVersionSubmodules>true</autoVersionSubmodules>
                            <tagNameFormat>@{project.version}</tagNameFormat>
                            <generateReleasePoms>false</generateReleasePoms>
                            <resume>false</resume>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>read gpg.passphrase system property</id>
            <!--
                This profile will pick `gpg.passphrase` java system property to configure maven-gpg-plugin passphrase implicitly

                ./mvnw -Dgpg.passphrase=...
            -->
            <activation>
                <property>
                    <name>gpg.passphrase</name>
                </property>
            </activation>
            <properties>
                <gpg.skip>false</gpg.skip>
            </properties>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-gpg-plugin</artifactId>
                        <version>${maven-gpg-plugin.version}</version>
                        <executions>
                            <execution>
                                <id>sign-artifacts</id>
                                <phase>verify</phase>
                                <goals>
                                    <goal>sign</goal>
                                </goals>
                                <configuration>
                                    <passphrase>${gpg.passphrase}</passphrase>
                                    <gpgArguments>
                                        <arg>--pinentry-mode</arg>
                                        <arg>loopback</arg>
                                    </gpgArguments>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>read GPG_PASSPHRASE environment variable</id>
            <!--
                This profile will pick `GPG_PASSPHRASE` environment variable to configure maven-gpg-plugin passphrase implicitly

                GPG_PASSPHRASE=... ./mvnw ...
            -->
            <activation>
                <property>
                    <name>env.GPG_PASSPHRASE</name>
                </property>
            </activation>
            <properties>
                <gpg.skip>false</gpg.skip>
            </properties>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-gpg-plugin</artifactId>
                        <version>${maven-gpg-plugin.version}</version>
                        <executions>
                            <execution>
                                <id>sign-artifacts</id>
                                <phase>verify</phase>
                                <goals>
                                    <goal>sign</goal>
                                </goals>
                            </execution>
                        </executions>
                        <configuration>
                            <passphrase>${env.GPG_PASSPHRASE}</passphrase>
                            <!-- Prevent `gpg` from using pinentry programs -->
                            <gpgArguments>
                                <arg>--pinentry-mode</arg>
                                <arg>loopback</arg>
                            </gpgArguments>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>central-release</id>
            <!--
                This profile mainly must be used to release project artifacts to central maven repository

                Prerequisites are:
                    - gpg install, private key with passphrase generated
                    - maven pom.xml required plugins added and configured with proper profiles

                Workflow:

                    - Let's say your version is x.y.z-SNAPSHOT
                        ./mvnw help:evaluate -Dexpression=project.version -q -DforceStdout

                    - Then you can deploy snapshot version to maven central just like so:
                        GPG_PASSPHRASE=... ./mvnw -P central-release clean deploy

                    - When testing of deployed x.y.z-SNAPSHOT is done, you can change version to released: x.y.z-SNAPSHOT -> x.y.z
                        ./mvnw build-helper:parse-version versions:set -DnewVersion=\${parsedVersion.majorVersion}.\${parsedVersion.minorVersion}.\${parsedVersion.incrementalVersion}

                    - If something goes wrong, you can simply revert last change with help of previously created pom.xml.versionsBackup files:
                        ./mvnw build-helper:parse-version versions:revert

                    - Otherwise commit, this will remove all generated pom.xml.versionsBackup files:
                        ./mvnw build-helper:parse-version versions:commit

                    - Let's commit release version with these commands:
                        VERSION=`mvn help:evaluate -Dexpression=project.version -q -DforceStdout`
                        git add . ; git commit -am "Release $VERSION version manually." ; git push origin master

                    - And release x.y.z version artifacts to maven central:
                        GPG_PASSPHRASE=... ./mvnw -P central-release clean deploy

                    - It's time to create and push GitHub tag released version:
                        git tag $VERSION ; git push origin $VERSION

                    - Finally create next SNAPSHOT version for future development iteration: x.y.z -> x.y.(z+1)-SNAPSHOT
                        ./mvnw build-helper:parse-version versions:set -DnewVersion=\${parsedVersion.majorVersion}.\${parsedVersion.minorVersion}.\${parsedVersion.nextIncrementalVersion}-SNAPSHOT
                        ./mvnw build-helper:parse-version versions:commit
                        VERSION=`mvn help:evaluate -Dexpression=project.version -q -DforceStdout`
                        git add . ; git commit -am "Start next $VERSION development iteration." ; git push origin master

                see: https://central.sonatype.org/publish/publish-maven/#nexus-staging-maven-plugin-for-deployment-and-release
            -->
            <distributionManagement>
                <snapshotRepository>
                    <id>ossrh</id>
                    <url>https://s01.oss.sonatype.org/content/repositories/snapshots</url>
                </snapshotRepository>
            </distributionManagement>
            <build>
                <defaultGoal>clean deploy</defaultGoal>
                <plugins>
                    <plugin>
                        <groupId>org.sonatype.plugins</groupId>
                        <artifactId>nexus-staging-maven-plugin</artifactId>
                        <version>${nexus-staging-maven-plugin.version}</version>
                        <extensions>true</extensions>
                        <configuration>
                            <serverId>ossrh</serverId>
                            <nexusUrl>https://s01.oss.sonatype.org/</nexusUrl>
                            <autoReleaseAfterClose>true</autoReleaseAfterClose>
                            <tags>
                                <localUsername>${env.USER}</localUsername>
                                <javaVersion>${java.version}</javaVersion>
                            </tags>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
