<?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>org.opengauss</groupId>
        <artifactId>visualtool-parent</artifactId>
        <version>${admin.version}</version>
        <relativePath>../../pom.xml</relativePath>
    </parent>

    <artifactId>er-model</artifactId>

    <properties>
        <maven.compiler.source>17</maven.compiler.source>
        <maven.compiler.target>17</maven.compiler.target>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <web.build.skip>false</web.build.skip>
        <npm.run.script>build:prod</npm.run.script>
    </properties>
    <dependencies>

        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
        </dependency>
        <dependency>
            <groupId>com.gitee.starblues</groupId>
            <artifactId>spring-brick</artifactId>
            <version>3.1.0</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.opengauss</groupId>
            <artifactId>visualtool-service</artifactId>
        </dependency>
        <dependency>
            <groupId>org.opengauss</groupId>
            <artifactId>visualtool-common</artifactId>
        </dependency>
        <dependency>
            <groupId>org.opengauss</groupId>
            <artifactId>opengauss-jdbc</artifactId>
            <version>5.0.2-og</version>
        </dependency>
        <dependency>
            <groupId>org.opengauss</groupId>
            <artifactId>visualtool-framework</artifactId>
        </dependency>
        <dependency>
            <groupId>com.gitee.starblues</groupId>
            <artifactId>spring-brick-bootstrap</artifactId>
        </dependency>
        <dependency>
            <groupId>io.github.nilswende</groupId>
            <artifactId>dbml-java</artifactId>
            <version>1.4.0</version>
        </dependency>
        <dependency>
            <groupId>com.github.jsqlparser</groupId>
            <artifactId>jsqlparser</artifactId>
            <version>4.6</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>com.gitee.starblues</groupId>
                <artifactId>spring-brick-maven-packager</artifactId>
                <version>${spring-brick.version}</version>
                <configuration>
                    <mode>prod</mode>
                    <pluginInfo>
                        <id>er-model</id>
                        <bootstrapClass>org.opengauss.admin.plugin.ERModelPluginApplication</bootstrapClass>
                        <version>${project.version}</version>
                        <provider>lita</provider>
                        <description>ER建模插件</description>
                    </pluginInfo>
                    <loadMainResourcePattern>
                        <includes>
                            <include>org.intarkdb.**</include>
                        </includes>
                    </loadMainResourcePattern>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>repackage</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <skip>true</skip>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-clean-plugin</artifactId>
                <version>3.2.0</version>
                <configuration>
                    <filesets>
                        <fileset>
                            <directory>web-ui/dist</directory>
                            <includes>
                                <include>**/*</include>
                            </includes>
                            <followSymlinks>false</followSymlinks>
                        </fileset>
                        <fileset>
                            <directory>${basedir}/src/main/resources/resources</directory>
                            <includes>
                                <include>**/*</include>
                            </includes>
                            <followSymlinks>false</followSymlinks>
                        </fileset>
                    </filesets>
                    <skip>false</skip>
                    <failOnError>true</failOnError>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>1.6.0</version>
                <configuration>
                    <skip>${web.build.skip}</skip>
                </configuration>
                <executions>
                    <execution>
                        <id>exec-npm-install</id>
                        <phase>generate-resources</phase>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                        <configuration>
                            <skip>${web.build.skip}</skip>
                            <executable>npm</executable>
                            <arguments>
                                <argument>install</argument>
                                <argument>--frozen-lockfile</argument>
                                <argument>--prefer-offline</argument>
                                <argument>--no-optional</argument>
                            </arguments>
                            <workingDirectory>web-ui</workingDirectory>
                        </configuration>
                    </execution>

                    <execution>
                        <id>exec-npm-run-build</id>
                        <phase>generate-resources</phase>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                        <configuration>
                            <skip>${web.build.skip}</skip>
                            <executable>npm</executable>
                            <arguments>
                                <argument>run</argument>
                                <argument>${npm.run.script}</argument>
                            </arguments>
                            <workingDirectory>web-ui</workingDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <version>2.5</version>
                <executions>
                    <execution>
                        <id>copy-web</id>
                        <phase>generate-resources</phase>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${basedir}/src/main/resources</outputDirectory>
                            <resources>
                                <resource>
                                    <directory>web-ui/dist</directory>
                                    <targetPath>resources</targetPath>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>


</project>