<?xml version="1.0"?>
<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>io.apicurio</groupId>
        <artifactId>apicurio-registry</artifactId>
        <version>2.6.11.redhat-00001</version>
        <relativePath>../pom.xml</relativePath>
    </parent>

    <artifactId>apicurio-registry-ui</artifactId>
    <name>apicurio-registry-ui</name>

    <build>
        <plugins>
            <plugin>
                <artifactId>maven-clean-plugin</artifactId>
                <configuration>
                    <filesets>
                        <fileset>
                            <directory>packages/models</directory>
                            <includes>
                                <include>packages/models/dist/**</include>
                                <include>packages/models/node_modules/**</include>
                                <include>packages/registry/dist/**</include>
                                <include>packages/registry/node_modules/**</include>
                                <include>packages/services/dist/**</include>
                                <include>packages/services/node_modules/**</include>
                                <include>node/**</include>
                                <include>node_modules/**</include>
                            </includes>
                        </fileset>
                    </filesets>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <executions>
                    <execution>
                        <id>attach-javadocs</id>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                        <configuration>
                            <skip>true</skip>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>com.github.eirslett</groupId>
                <artifactId>frontend-maven-plugin</artifactId>
                <executions>
                    <!-- Install Node -->
                    <execution>
                        <id>install node</id>
                        <phase>initialize</phase>
                        <goals>
                            <goal>install-node-and-npm</goal>
                        </goals>
                        <configuration>
                            <nodeVersion>v${node.version}</nodeVersion>
                        </configuration>
                    </execution>
                    <!-- Install npm dependencies -->
                    <execution>
                        <id>npm install</id>
                        <phase>compile</phase>
                        <goals>
                            <goal>npm</goal>
                        </goals>
                        <configuration>
                            <arguments>install</arguments>
                            <npmRegistryURL>${npmRegistryURL2}</npmRegistryURL>
                        </configuration>
                    </execution>
                    <!-- Lint the app -->
                    <execution>
                        <id>npm run lint</id>
                        <phase>compile</phase>
                        <goals>
                            <goal>npm</goal>
                        </goals>
                        <configuration>
                            <arguments>run lint</arguments>
                        </configuration>
                    </execution>
                    <!-- Build the app -->
                    <execution>
                        <id>npm build</id>
                        <phase>compile</phase>
                        <goals>
                            <goal>npm</goal>
                        </goals>
                        <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-dist</id>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${project.build.outputDirectory}</outputDirectory>
                            <resources>
                                <resource>
                                    <directory>${project.basedir}/dist</directory>
                                    <filtering>false</filtering>
                                    <excludes>
                                        <exclude>config.js</exclude>
                                        <exclude>keycloak.js</exclude>
                                        <exclude>keycloak.json</exclude>
                                        <exclude>version.js</exclude>
                                    </excludes>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <properties>
    <quarkus.version>3.15.3.redhat-00002</quarkus.version>
  </properties>
    <profiles>
        <profile>
            <id>with-proxy</id>
            <activation>
                <property>
                    <name>proxy-server</name>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <artifactId>maven-enforcer-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>require-proxy-properties</id>
                                <goals>
                                    <goal>enforce</goal>
                                </goals>
                                <configuration>
                                    <rules>
                                        <requireProperty>
                                            <property>proxy-user</property>
                                        </requireProperty>
                                        <requireProperty>
                                            <property>proxy-password</property>
                                        </requireProperty>
                                        <requireProperty>
                                            <property>proxy-port</property>
                                        </requireProperty>
                                    </rules>
                                    <fail>true</fail>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>com.github.eirslett</groupId>
                        <artifactId>frontend-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>set https proxy</id>
                                <phase>generate-sources</phase>
                                <goals>
                                    <goal>npm</goal>
                                </goals>
                                <configuration>
                                    <arguments>config set https-proxy http://${proxy-user}:${proxy-password}@${proxy-server}:${proxy-port}</arguments>
                                </configuration>
                            </execution>
                            <execution>
                                <id>set http proxy</id>
                                <phase>generate-sources</phase>
                                <goals>
                                    <goal>npm</goal>
                                </goals>
                                <configuration>
                                    <arguments>config set proxy http://${proxy-user}:${proxy-password}@${proxy-server}:${proxy-port}</arguments>
                                </configuration>
                            </execution>
                            <execution>
                                <id>set maxconn</id>
                                <phase>generate-sources</phase>
                                <goals>
                                    <goal>npm</goal>
                                </goals>
                                <configuration>
                                    <arguments>config set maxsockets 30</arguments>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>with-custom-registry</id>
            <activation>
                <property>
                    <name>custom-registry</name>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>com.github.eirslett</groupId>
                        <artifactId>frontend-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>npm set registry</id>
                                <phase>generate-sources</phase>
                                <goals>
                                    <goal>npm</goal>
                                </goals>
                                <configuration>
                                    <arguments>config set registry ${custom-registry}</arguments>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>with-custom-cafile</id>
            <activation>
                <property>
                    <name>custom-cafile</name>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>com.github.eirslett</groupId>
                        <artifactId>frontend-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>npm set cafile</id>
                                <phase>generate-sources</phase>
                                <goals>
                                    <goal>npm</goal>
                                </goals>
                                <configuration>
                                    <arguments>config set cafile ${custom-cafile}</arguments>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>insecure</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>com.github.eirslett</groupId>
                        <artifactId>frontend-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>npm set no-strict ssl</id>
                                <phase>generate-sources</phase>
                                <goals>
                                    <goal>npm</goal>
                                </goals>
                                <configuration>
                                    <arguments>config set strict-ssl false</arguments>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>verbose</id>
            <properties>
                <npm-verbose>--loglevel=silly</npm-verbose>
            </properties>
        </profile>
    </profiles>
</project>
