<?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>io.github.a-simeshin</groupId>
        <artifactId>spring-ai-mcp-inspector-parent</artifactId>
        <version>2.0.0</version>
        <relativePath>../pom.xml</relativePath>
    </parent>

    <artifactId>spring-ai-mcp-inspector-ui</artifactId>
    <packaging>jar</packaging>
    <name>spring-ai-mcp-inspector-ui</name>
    <description>Pre-built MCP Inspector web UI bundle (vendored React/Vite client) packaged as
        a classpath resource for the Spring AI MCP Inspector starters.</description>

    <properties>
        <skipUI>false</skipUI>
        <!-- No Java sources to cover; this module bundles the vendored
             React/Vite client only. -->
        <jacoco.skip>true</jacoco.skip>
        <!-- Vendored upstream client, no first-party Java: checkstyle gate off. -->
        <checkstyle.skip>true</checkstyle.skip>
        <!-- Vendored upstream client, no first-party Java: SpotBugs gate off. -->
        <spotbugs.skip>true</spotbugs.skip>
    </properties>

    <build>
        <plugins>
            <plugin>
                <groupId>com.github.eirslett</groupId>
                <artifactId>frontend-maven-plugin</artifactId>
                <version>1.15.1</version>
                <configuration>
                    <workingDirectory>upstream-client</workingDirectory>
                    <installDirectory>target</installDirectory>
                    <skip>${skipUI}</skip>
                </configuration>
                <executions>
                    <execution>
                        <id>install-node-and-npm</id>
                        <goals>
                            <goal>install-node-and-npm</goal>
                        </goals>
                        <configuration>
                            <nodeVersion>v20.18.0</nodeVersion>
                            <npmVersion>10.8.2</npmVersion>
                        </configuration>
                    </execution>
                    <execution>
                        <id>npm-install</id>
                        <goals>
                            <goal>npm</goal>
                        </goals>
                        <configuration>
                            <arguments>install</arguments>
                        </configuration>
                    </execution>
                    <execution>
                        <id>npm-build</id>
                        <goals>
                            <goal>npm</goal>
                        </goals>
                        <phase>generate-resources</phase>
                        <configuration>
                            <arguments>run build</arguments>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <executions>
                    <execution>
                        <id>copy-ui-dist</id>
                        <phase>process-resources</phase>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${project.build.outputDirectory}/mcp-inspector-bundle</outputDirectory>
                            <resources>
                                <resource>
                                    <directory>upstream-client/dist</directory>
                                    <filtering>false</filtering>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <!-- This module ships only the vendored JS bundle — there are no Java sources,
             so the parent release profile's source/javadoc plugins emit nothing. Maven
             Central still requires a -sources and -javadoc jar per published jar artifact,
             so attach empty (signed) stubs during `-Prelease`. -->
        <profile>
            <id>release</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-jar-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>empty-sources-jar</id>
                                <phase>package</phase>
                                <goals>
                                    <goal>jar</goal>
                                </goals>
                                <configuration>
                                    <classifier>sources</classifier>
                                    <classesDirectory>${project.build.directory}/empty-stub</classesDirectory>
                                    <forceCreation>true</forceCreation>
                                </configuration>
                            </execution>
                            <execution>
                                <id>empty-javadoc-jar</id>
                                <phase>package</phase>
                                <goals>
                                    <goal>jar</goal>
                                </goals>
                                <configuration>
                                    <classifier>javadoc</classifier>
                                    <classesDirectory>${project.build.directory}/empty-stub</classesDirectory>
                                    <forceCreation>true</forceCreation>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
