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

    <parent>
        <groupId>dev.promptlm</groupId>
        <artifactId>promptlm-dependencies</artifactId>
        <version>0.1.0</version>
        <relativePath>../promptlm-dependencies/pom.xml</relativePath>
    </parent>

    <artifactId>promptlm-parent</artifactId>
    <packaging>pom</packaging>

    <name>promptLM Parent</name>
    <description>
        Build-policy parent for promptLM repositories. Extends promptlm-dependencies
        (inheriting all dependency management) and adds compiler/plugin policy,
        shared test dependencies, and the dynamic-agent-loading profile.
        Consumers that already have their own parent should import
        promptlm-dependencies directly instead. See ADR 0004 in
        promptLM/promptlm-test-support.
    </description>
    <url>https://github.com/promptLM/promptlm-platform</url>

    <properties>
        <maven.compiler.release>21</maven.compiler.release>
        <project.scm.id>github</project.scm.id>

        <!-- Surefire wiring: argLine for module-overridable JVM args; api.key wires the OpenAI key into tests. -->
        <api.key>${env.OPENAI_API_KEY}</api.key>
        <argLine/>
        <surefire.extraArgs/>

        <maven-compiler-plugin.version>3.13.0</maven-compiler-plugin.version>
        <maven-surefire-plugin.version>3.5.6</maven-surefire-plugin.version>
        <maven-failsafe-plugin.version>3.5.6</maven-failsafe-plugin.version>
        <maven-jar-plugin.version>3.5.0</maven-jar-plugin.version>
        <maven-source-plugin.version>3.4.0</maven-source-plugin.version>
        <maven-javadoc-plugin.version>3.12.0</maven-javadoc-plugin.version>
        <maven-release-plugin.version>3.3.1</maven-release-plugin.version>
        <maven-deploy-plugin.version>3.1.3</maven-deploy-plugin.version>
        <spring-boot-maven-plugin.version>${spring-boot.version}</spring-boot-maven-plugin.version>
        <native.maven.plugin.version>1.1.1</native.maven.plugin.version>
        <cyclonedx-maven-plugin.version>2.9.1</cyclonedx-maven-plugin.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit-pioneer</groupId>
            <artifactId>junit-pioneer</artifactId>
            <version>2.3.0</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>${maven-compiler-plugin.version}</version>
                    <configuration>
                        <release>${maven.compiler.release}</release>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-failsafe-plugin</artifactId>
                    <version>${maven-failsafe-plugin.version}</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-jar-plugin</artifactId>
                    <version>${maven-jar-plugin.version}</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-source-plugin</artifactId>
                    <version>${maven-source-plugin.version}</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-javadoc-plugin</artifactId>
                    <version>${maven-javadoc-plugin.version}</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-deploy-plugin</artifactId>
                    <version>${maven-deploy-plugin.version}</version>
                </plugin>
                <plugin>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-maven-plugin</artifactId>
                    <version>${spring-boot-maven-plugin.version}</version>
                    <configuration>
                        <skip>true</skip>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.graalvm.buildtools</groupId>
                    <artifactId>native-maven-plugin</artifactId>
                    <version>${native.maven.plugin.version}</version>
                </plugin>
            </plugins>
        </pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-release-plugin</artifactId>
                <version>${maven-release-plugin.version}</version>
                <configuration>
                    <tagNameFormat>v@{project.version}</tagNameFormat>
                    <autoVersionSubmodules>true</autoVersionSubmodules>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>${maven-surefire-plugin.version}</version>
                <configuration>
                    <argLine>${argLine} ${surefire.extraArgs}</argLine>
                    <systemPropertyVariables>
                        <apiKey>${api.key}</apiKey>
                        <junit.jupiter.tags.exclude>manual</junit.jupiter.tags.exclude>
                    </systemPropertyVariables>
                </configuration>
            </plugin>
            <!--
                License header enforcement is handled in CI by the
                apache/skywalking-eyes/header GitHub Action
                (.github/workflows/oss-checks.yml + .licenserc.yaml).
                There is no stable skywalking-eyes Maven plugin on Central,
                so the action is the authoritative cross-language check.

                Java formatting is intentionally not enforced at the build
                level yet. Adopt a formatter (googleJavaFormat AOSP, Palantir,
                or similar) in a dedicated one-shot reformat PR before
                re-introducing build-time enforcement.
            -->
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>github</id>
        </profile>
        <!--
            Adds the jar-level artifacts Central requires (sources, javadoc) and a
            CycloneDX SBOM. No-ops for the pom-packaging artifacts in this repo;
            meaningful for the jar-producing repos that inherit promptlm-parent.
            GPG signing, reproducible timestamps and Portal publishing are inherited
            from the release profile in promptlm-dependencies.
        -->
        <profile>
            <id>release</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-source-plugin</artifactId>
                        <version>${maven-source-plugin.version}</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>${maven-javadoc-plugin.version}</version>
                        <executions>
                            <execution>
                                <id>attach-javadocs</id>
                                <goals>
                                    <goal>jar</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.cyclonedx</groupId>
                        <artifactId>cyclonedx-maven-plugin</artifactId>
                        <version>${cyclonedx-maven-plugin.version}</version>
                        <executions>
                            <execution>
                                <id>build-sbom</id>
                                <phase>package</phase>
                                <goals>
                                    <goal>makeAggregateBom</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>enable-dynamic-agent-loading</id>
            <activation>
                <jdk>[21,)</jdk>
            </activation>
            <properties>
                <surefire.extraArgs>-XX:+EnableDynamicAgentLoading</surefire.extraArgs>
            </properties>
        </profile>

    </profiles>
</project>
