<?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>com.netmoor.moorhaven</groupId>
        <artifactId>moorhaven-parent</artifactId>
        <version>0.3.0-SNAPSHOT</version>
    </parent>

    <artifactId>moorhaven-sqlite-slim</artifactId>
    <name>Moorhaven :: SQLite JDBC (slim)</name>
    <description>
        org.xerial:sqlite-jdbc repacked for one target platform: the upstream jar bundles native libraries for
        every OS/arch (14 MB); the native.platform profiles in the parent pick what to keep
        (property native.sqlite.excludes). Same org.sqlite API, so it is a drop-in replacement.
    </description>

    <properties>
        <!-- SpotBugs/FindSecBugs skip: this module only repacks third-party org.sqlite.* (xerial sqlite-jdbc) classes
             for one target platform (see description) and contains no project code, so findings
             there are not ours to fix. Upstream advisories are covered by the Trivy fat-jar scan.
             Added 2026-09-20 (#38); revisit 2026-12-20 or when the repack starts adding own classes. -->
        <spotbugs.skip>true</spotbugs.skip>
        <!-- Coverage ratchet (#50): repacked third-party bytecode only, no project code to
             exercise (see doc/coverage-baseline.md) — stays at the parent default. -->
        <jacoco.min>0.00</jacoco.min>
    </properties>

    <dependencies>
        <!-- Upstream declares slf4j-api as its only runtime dependency; keep it. -->
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <!-- The unpacked tree depends on the native-* profile, not on any source file, so an
                 incremental build after switching profile would keep the previous platform's files.
                 Always start from an empty target/. -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-install-plugin</artifactId>
                <configuration>
                    <skip>${native.slim.install.skip}</skip>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-deploy-plugin</artifactId>
                <configuration>
                    <skip>${native.slim.install.skip}</skip>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-clean-plugin</artifactId>
                <executions>
                    <execution>
                        <id>reset-target</id>
                        <phase>initialize</phase>
                        <goals>
                            <goal>clean</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <id>unpack-sqlite-jdbc</id>
                        <phase>generate-resources</phase>
                        <goals>
                            <goal>unpack</goal>
                        </goals>
                        <configuration>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>org.xerial</groupId>
                                    <artifactId>sqlite-jdbc</artifactId>
                                    <version>${sqlite-jdbc.version}</version>
                                    <outputDirectory>${project.build.outputDirectory}</outputDirectory>
                                    <excludes>${native.sqlite.excludes}</excludes>
                                </artifactItem>
                            </artifactItems>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <configuration>
                    <archive>
                        <manifestEntries>
                            <!-- The upstream manifest is not unpacked; sqlite-jdbc ships META-INF/versions/9. -->
                            <Multi-Release>true</Multi-Release>
                        </manifestEntries>
                    </archive>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <systemPropertyVariables>
                        <native.excludes>${native.sqlite.excludes}</native.excludes>
                    </systemPropertyVariables>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>
