<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xmlns="http://maven.apache.org/POM/4.0.0"
         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>de.bsommerfeld.jshepherd</groupId>
        <artifactId>jshepherd</artifactId>
        <version>4.1.0</version>
        <relativePath>../pom.xml</relativePath>
    </parent>

    <artifactId>json</artifactId>
    <version>4.1.0</version>

    <name>jShepherd JSON</name>
    <description>JSON format support for jShepherd configuration management using Jackson.</description>

    <dependencies>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <version>2.18.5</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.datatype</groupId>
            <artifactId>jackson-datatype-jsr310</artifactId>
            <version>2.18.5</version>
        </dependency>
        <dependency>
            <groupId>de.bsommerfeld.jshepherd</groupId>
            <artifactId>core</artifactId>
        </dependency>
        <dependency>
            <groupId>com.google.auto.service</groupId>
            <artifactId>auto-service-annotations</artifactId>
        </dependency>
        <dependency>
            <groupId>com.google.auto.service</groupId>
            <artifactId>auto-service</artifactId>
        </dependency>

        <!-- Test dependencies -->
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-api</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-engine</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-core</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-junit-jupiter</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                        <configuration>
                            <filters>
                                <filter>
                                    <artifact>*:*</artifact>
                                    <excludes>
                                        <exclude>module-info.class</exclude>
                                        <exclude>META-INF/versions/*/module-info.class</exclude>
                                    </excludes>
                                </filter>
                                <!-- Strip multi-release class entries from bundled JARs.
                                     The shade plugin does not relocate MR entries, so
                                     unrelocated packages would cause split-package conflicts
                                     on the module path. Root-level classes are sufficient. -->
                                <filter>
                                    <artifact>com.fasterxml.jackson.core:*</artifact>
                                    <excludes>
                                        <exclude>META-INF/versions/**</exclude>
                                    </excludes>
                                </filter>
                            </filters>
                            <relocations>
                                <relocation>
                                    <pattern>com.fasterxml.jackson</pattern>
                                    <shadedPattern>de.bsommerfeld.jshepherd.json.shared.jackson</shadedPattern>
                                </relocation>
                                <relocation>
                                    <pattern>com.google.auto.service</pattern>
                                    <shadedPattern>de.bsommerfeld.jshepherd.json.shared.autoservice</shadedPattern>
                                </relocation>
                            </relocations>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <!-- Shade strips module-info.class because it can't relocate module
                 descriptor references. Moditect re-injects a valid descriptor
                 that only references external (non-shaded) modules. -->
            <plugin>
                <groupId>org.moditect</groupId>
                <artifactId>moditect-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>add-module-info</id>
                        <phase>package</phase>
                        <goals>
                            <goal>add-module-info</goal>
                        </goals>
                        <configuration>
                            <overwriteExistingFiles>true</overwriteExistingFiles>
                            <module>
                                <moduleInfoSource>
                                    module de.bsommerfeld.jshepherd.json {
                                        exports de.bsommerfeld.jshepherd.json;
                                        opens de.bsommerfeld.jshepherd.json to de.bsommerfeld.jshepherd.core;
                                        requires de.bsommerfeld.jshepherd.core;
                                        requires java.logging;
                                        // Jackson's optional ext handlers probe these JDK modules at static
                                        // init time. "requires static" establishes the reads edge when
                                        // the module is present, without failing when it is absent.
                                        requires static java.desktop;
                                        requires static java.sql;
                                        requires static java.xml;
                                        provides de.bsommerfeld.jshepherd.core.PersistenceDelegateFactory
                                                with de.bsommerfeld.jshepherd.json.JsonPersistenceDelegateFactory;
                                    }
                                </moduleInfoSource>
                            </module>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

</project>
