<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <modelVersion>4.0.0</modelVersion>
  <parent>
    <groupId>com.baizhukui</groupId>
    <artifactId>knife4j</artifactId>
    <version>5.0.11</version>
  </parent>
  <groupId>com.baizhukui</groupId>
  <artifactId>knife4j-openapi3-ui</artifactId>
  <version>5.0.11</version>
  <name>knife4j-openapi3-ui</name>
  <description>springdoc-openapi的Ui模块</description>
  <licenses>
    <license>
      <name>The Apache Software License, Version 2.0</name>
      <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
    </license>
  </licenses>
  <properties>
    <knife4j-ui-react.dir>${project.basedir}/../../knife4j-front/knife4j-ui-react</knife4j-ui-react.dir>
    <knife4j-ui-react.outDir>${project.build.directory}/knife4j-ui-react-dist</knife4j-ui-react.outDir>
    <destDir>${project.build.outputDirectory}/META-INF/resources/</destDir>
  </properties>
  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.13.2</version>
      <scope>test</scope>
    </dependency>
  </dependencies>
  <build>
    <resources>
      <resource>
        <targetPath>META-INF/resources/</targetPath>
        <directory>${project.basedir}/src/main/resources</directory>
        <excludes>
          <exclude>webjars/knife4j-ui-react/**</exclude>
        </excludes>
      </resource>
    </resources>
    <plugins>
      <plugin>
        <artifactId>maven-clean-plugin</artifactId>
        <version>3.3.2</version>
        <executions>
          <execution>
            <id>wipe-stale-react-webjar</id>
            <phase>initialize</phase>
            <goals>
              <goal>clean</goal>
            </goals>
            <configuration>
              <excludeDefaultDirectories>true</excludeDefaultDirectories>
              <filesets>
                <fileset>
                  <directory>${project.basedir}/src/main/resources/webjars/knife4j-ui-react</directory>
                  <followSymlinks>false</followSymlinks>
                </fileset>
              </filesets>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>exec-maven-plugin</artifactId>
        <version>3.1.0</version>
        <executions>
          <execution>
            <id>bun-install</id>
            <phase>generate-resources</phase>
            <goals>
              <goal>exec</goal>
            </goals>
            <configuration>
              <executable>bun</executable>
              <arguments>
                <argument>install</argument>
                <argument>--frozen-lockfile</argument>
              </arguments>
              <workingDirectory>${knife4j-ui-react.dir}</workingDirectory>
            </configuration>
          </execution>
          <execution>
            <id>vite-build</id>
            <phase>generate-resources</phase>
            <goals>
              <goal>exec</goal>
            </goals>
            <configuration>
              <executable>bun</executable>
              <arguments>
                <argument>x</argument>
                <argument>vite</argument>
                <argument>build</argument>
                <argument>--outDir=${knife4j-ui-react.outDir}</argument>
                <argument>--emptyOutDir</argument>
              </arguments>
              <workingDirectory>${knife4j-ui-react.dir}</workingDirectory>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <artifactId>maven-resources-plugin</artifactId>
        <version>3.3.1</version>
        <executions>
          <execution>
            <id>copy-react-dist</id>
            <phase>process-resources</phase>
            <goals>
              <goal>copy-resources</goal>
            </goals>
            <configuration>
              <outputDirectory>${project.build.outputDirectory}/META-INF/resources/webjars/knife4j-ui-react</outputDirectory>
              <overwrite>true</overwrite>
              <resources>
                <resource>
                  <directory>${knife4j-ui-react.outDir}</directory>
                  <filtering>false</filtering>
                </resource>
              </resources>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>
