<?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>

    <parent>
        <groupId>org.alexmond</groupId>
        <artifactId>unitrack-parent</artifactId>
        <version>0.1.0</version>
        <relativePath>../pom.xml</relativePath>
    </parent>

    <artifactId>unitrack-cli</artifactId>
    <name>unitrack-cli</name>
    <description>UniTrack CI uploader — a Spring Boot CLI that pushes test/coverage/perf results to a UniTrack server</description>

    <properties>
        <picocli.version>4.7.7</picocli.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
        </dependency>
        <!-- RestClient + multipart form writer; no servlet container is pulled in (CLI runs web-application-type=none). -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
        </dependency>
        <dependency>
            <groupId>info.picocli</groupId>
            <artifactId>picocli</artifactId>
            <version>${picocli.version}</version>
        </dependency>
        <!-- Retry/backoff uses org.springframework.core.retry from spring-core
             (Spring Framework 7) — no extra dependency needed. -->
        <!-- Reads the GitHub Actions event payload to recover the PR head SHA. -->
        <dependency>
            <groupId>tools.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <finalName>unitrack-cli</finalName>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <mainClass>org.alexmond.unitrack.cli.UnitrackCliApplication</mainClass>
                    <!-- Attach the executable jar under the 'exec' classifier so the plain main
                         jar stays a usable library (the Maven/Gradle plugins depend on it). The
                         runnable artifact is unitrack-cli-exec.jar (used by Docker/Action). -->
                    <classifier>exec</classifier>
                    <!-- Image name for the buildpacks builder; the shared 'docker' profile supplies the build-image execution. -->
                    <image>
                        <name>unitrack-cli:${project.version}</name>
                    </image>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>coverage-check</id>
                        <phase>verify</phase>
                        <goals>
                            <goal>check</goal>
                        </goals>
                        <configuration>
                            <!-- The Spring Boot entry point is not unit-tested by design. -->
                            <excludes>
                                <exclude>org/alexmond/unitrack/cli/UnitrackCliApplication.class</exclude>
                            </excludes>
                            <rules>
                                <rule>
                                    <element>BUNDLE</element>
                                    <limits>
                                        <limit>
                                            <counter>LINE</counter>
                                            <value>COVEREDRATIO</value>
                                            <minimum>0.80</minimum>
                                        </limit>
                                    </limits>
                                </rule>
                            </rules>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>
