<?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>
    <groupId>xyz.block.ftl</groupId>
    <artifactId>ftl-jvm-parent</artifactId>
    <version>0.446.0</version>
    <packaging>pom</packaging>
    <name>FTL Java Runtime - Parent</name>
    <description>Towards a 𝝺-calculus for large-scale systems</description>
    <url>https://block.github.io/ftl/</url>

    <scm>
        <connection>scm:git:git://github.com/block/ftl.git</connection>
        <!-- This has to be HTTPS, not git://, for maven-release-plugin to do AUTH correctly -->
        <developerConnection>scm:git:https://github.com/block/ftl.git</developerConnection>
        <url>https://github.com/block/ftl</url>
        <tag>HEAD</tag>
    </scm>

    <developers>
        <developer>
            <id>block</id>
            <name>Block, Inc.</name>
            <email>releases@tbd.email</email>
        </developer>
    </developers>

    <issueManagement>
        <system>github</system>
        <url>https://github.com/block/ftl/issues</url>
    </issueManagement>

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

    <modules>
        <module>common</module>
        <module>java</module>
        <module>kotlin</module>
        <module>test-framework</module>
    </modules>

    <properties>
        <compiler-plugin.version>3.13.0</compiler-plugin.version>
        <failsafe-plugin.version>${surefire-plugin.version}</failsafe-plugin.version>
        <maven.compiler.release>17</maven.compiler.release>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <quarkus.version>3.18.1</quarkus.version>
        <surefire-plugin.version>3.5.2</surefire-plugin.version>
        <rootDir>${basedir}/../../../..</rootDir>
        <grpc.version>1.70.0</grpc.version>
        <javapoet.version>1.13.0</javapoet.version>
        <version.formatter.plugin>2.24.1</version.formatter.plugin>
        <version.impsort.plugin>1.12.0</version.impsort.plugin>
        <kotlinpoet.version>2.0.0</kotlinpoet.version>
        <tomlj.version>1.1.1</tomlj.version>
        <antlr4-runtime.version>4.13.2</antlr4-runtime.version>
    </properties>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>io.quarkus</groupId>
                <artifactId>quarkus-bom</artifactId>
                <version>${quarkus.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
            <dependency>
                <groupId>xyz.block.ftl</groupId>
                <artifactId>ftl-jvm-hot-reload</artifactId>
                <version>0.446.0</version>
            </dependency>
            <dependency>
                <groupId>xyz.block.ftl</groupId>
                <artifactId>ftl-jvm-runtime</artifactId>
                <version>0.446.0</version>
            </dependency>
            <dependency>
                <groupId>xyz.block.ftl</groupId>
                <artifactId>ftl-java-runtime</artifactId>
                <version>0.446.0</version>
            </dependency>
            <dependency>
                <groupId>xyz.block.ftl</groupId>
                <artifactId>ftl-java-runtime-deployment</artifactId>
                <version>0.446.0</version>
            </dependency>
            <dependency>
                <groupId>xyz.block.ftl</groupId>
                <artifactId>ftl-kotlin-runtime</artifactId>
                <version>0.446.0</version>
            </dependency>
            <dependency>
                <groupId>xyz.block.ftl</groupId>
                <artifactId>ftl-jvm-runtime-deployment</artifactId>
                <version>0.446.0</version>
            </dependency>
            <dependency>
                <groupId>xyz.block.ftl</groupId>
                <artifactId>ftl-jvm-test-framework</artifactId>
                <version>0.446.0</version>
            </dependency>
            <dependency>
                <groupId>io.grpc</groupId>
                <artifactId>grpc-bom</artifactId>
                <version>${grpc.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
            <dependency>
                <groupId>org.tomlj</groupId>
                <artifactId>tomlj</artifactId>
                <version>${tomlj.version}</version>
            </dependency>

            <dependency>
                <groupId>com.squareup</groupId>
                <artifactId>javapoet</artifactId>
                <version>${javapoet.version}</version>
            </dependency>
            <dependency>
                <groupId>com.squareup</groupId>
                <artifactId>kotlinpoet-jvm</artifactId>
                <version>${kotlinpoet.version}</version>
            </dependency>


            <dependency>
                <groupId>com.squareup.wire</groupId>
                <artifactId>wire-runtime-jvm</artifactId>
                <version>${wire.version}</version>
            </dependency>
            <dependency>
                <groupId>com.squareup.wire</groupId>
                <artifactId>wire-grpc-server</artifactId>
                <version>${wire.version}</version>
            </dependency>
            <dependency>
                <groupId>com.squareup.wire</groupId>
                <artifactId>wire-grpc-client-jvm</artifactId>
                <version>${wire.version}</version>
            </dependency>

            <!-- GRPC dependencies -->
            <dependency>
                <groupId>io.grpc</groupId>
                <artifactId>grpc-netty</artifactId>
                <version>${grpc.version}</version>
            </dependency>
            <dependency>
                <groupId>io.grpc</groupId>
                <artifactId>grpc-protobuf</artifactId>
                <version>${grpc.version}</version>
            </dependency>
            <dependency>
                <groupId>io.grpc</groupId>
                <artifactId>grpc-stub</artifactId>
                <version>${grpc.version}</version>
            </dependency>
            <dependency>
                <groupId>org.antlr</groupId>
                <artifactId>antlr4-runtime</artifactId>
                <version>${antlr4-runtime.version}</version>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>io.quarkus</groupId>
                    <artifactId>quarkus-maven-plugin</artifactId>
                    <version>${quarkus.version}</version>
                </plugin>
                <plugin>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <version>${surefire-plugin.version}</version>
                    <configuration>
                        <systemPropertyVariables>
                            <java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
                            <maven.home>${maven.home}</maven.home>
                            <maven.repo>${settings.localRepository}</maven.repo>
                        </systemPropertyVariables>
                    </configuration>
                </plugin>
                <plugin>
                    <artifactId>maven-failsafe-plugin</artifactId>
                    <version>${failsafe-plugin.version}</version>
                    <configuration>
                        <systemPropertyVariables>
                            <java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
                            <maven.home>${maven.home}</maven.home>
                            <maven.repo>${settings.localRepository}</maven.repo>
                        </systemPropertyVariables>
                    </configuration>
                </plugin>
                <plugin>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>${compiler-plugin.version}</version>
                    <configuration>
                        <compilerArgs>
                            <arg>-parameters</arg>
                        </compilerArgs>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>net.revelc.code.formatter</groupId>
                    <artifactId>formatter-maven-plugin</artifactId>
                    <version>${version.formatter.plugin}</version>
                    <dependencies>
                        <dependency>
                            <artifactId>quarkus-ide-config</artifactId>
                            <groupId>io.quarkus</groupId>
                            <version>${quarkus.version}</version>
                        </dependency>
                    </dependencies>
                    <configuration>
                        <!-- store outside of target to speed up formatting when mvn clean is used -->
                        <cachedir>.cache/formatter-maven-plugin-${version.formatter.plugin}</cachedir>
                        <configFile>eclipse-format.xml</configFile>
                        <lineEnding>LF</lineEnding>
                        <skip>${format.skip}</skip>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>net.revelc.code</groupId>
                    <artifactId>impsort-maven-plugin</artifactId>
                    <version>${version.impsort.plugin}</version>
                    <configuration>
                        <!-- store outside of target to speed up formatting when mvn clean is used -->
                        <cachedir>.cache/impsort-maven-plugin-${version.impsort.plugin}</cachedir>
                        <groups>java.,javax.,jakarta.,org.,com.</groups>
                        <staticGroups>*</staticGroups>
                        <skip>${format.skip}</skip>
                        <removeUnused>true</removeUnused>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>io.quarkus</groupId>
                    <artifactId>quarkus-extension-maven-plugin</artifactId>
                    <version>${quarkus.version}</version>
                </plugin>
                <plugin>
                    <artifactId>maven-deploy-plugin</artifactId>
                    <version>3.1.3</version>
                    <configuration>
                        <deployAtEnd>true</deployAtEnd>
                    </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</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <groupId>org.simplify4u.plugins</groupId>
                    <artifactId>sign-maven-plugin</artifactId>
                    <version>1.1.0</version>
                    <executions>
                        <execution>
                            <goals>
                                <goal>sign</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </pluginManagement>
        <plugins>
            <!-- handles the deployment of the project's artifacts to a remote repository -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-deploy-plugin</artifactId>
            </plugin>
        </plugins>
    </build>


    <profiles>
        <profile>
            <id>format</id>
            <activation>
                <activeByDefault>true</activeByDefault>
                <property>
                    <name>!no-format</name>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>net.revelc.code.formatter</groupId>
                        <artifactId>formatter-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <phase>process-sources</phase>
                                <goals>
                                    <goal>format</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>net.revelc.code</groupId>
                        <artifactId>impsort-maven-plugin</artifactId>
                        <configuration>
                            <removeUnused>true</removeUnused>
                        </configuration>
                        <executions>
                            <execution>
                                <id>sort-imports</id>
                                <goals>
                                    <goal>sort</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>validate</id>
            <activation>
                <activeByDefault>true</activeByDefault>
                <property>
                    <name>no-format</name>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>net.revelc.code.formatter</groupId>
                        <artifactId>formatter-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <phase>process-sources</phase>
                                <goals>
                                    <goal>validate</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>net.revelc.code</groupId>
                        <artifactId>impsort-maven-plugin</artifactId>
                        <configuration>
                            <removeUnused>true</removeUnused>
                        </configuration>
                        <executions>
                            <execution>
                                <id>check-imports</id>
                                <goals>
                                    <goal>check</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <profile>
            <!-- Profile for releasing artifacts to Maven Central -->
            <id>release</id>
            <build>
                <plugins>
                    <!-- produce signed artifacts -->
                    <plugin>
                        <groupId>org.simplify4u.plugins</groupId>
                        <artifactId>sign-maven-plugin</artifactId>
                    </plugin>
                    <!-- generates a JAR file containing the source code of the project -->
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-source-plugin</artifactId>
                    </plugin>
                    <plugin>
                        <groupId>org.jetbrains.dokka</groupId>
                        <artifactId>dokka-maven-plugin</artifactId>
                        <version>2.0.0</version>
                        <executions>
                            <execution>
                                <phase>package</phase>
                                <goals>
                                    <goal>javadocJar</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <!-- used to deploy artifacts to Maven Central via OSSRH (OSS Repository Hosting).
             It configures the nexus-staging-maven-plugin for automated deployment and release,
             and sets up the distribution management for both snapshot and release repositories.
             Activate this profile when deploying open-source projects to Maven Central. -->
        <profile>
            <!-- https://central.sonatype.org/publish/publish-maven/#deployment -->
            <id>ossrh</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.sonatype.plugins</groupId>
                        <artifactId>nexus-staging-maven-plugin</artifactId>
                        <version>1.7.0</version>
                        <extensions>true</extensions>
                        <configuration>
                            <serverId>ossrh-releases</serverId>
                            <nexusUrl>https://s01.oss.sonatype.org/</nexusUrl>
                            <autoReleaseAfterClose>true</autoReleaseAfterClose>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
            <!-- specifies where the project artifacts should be distributed or deployed. -->
            <!-- tells Maven where to deploy your project's artifacts when you run mvn deploy -->
            <distributionManagement>
                <snapshotRepository>
                    <id>ossrh-snapshots</id>
                    <url>https://s01.oss.sonatype.org/content/repositories/snapshots</url>
                </snapshotRepository>
                <!-- Sonatype's OSSRH - replicates to Maven Central within 30min of publish -->
                <repository>
                    <id>ossrh-releases</id>
                    <url>https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/</url>
                </repository>
            </distributionManagement>
        </profile>
    </profiles>

</project>
