<?xml version="1.0"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://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>io.apicurio</groupId>
        <artifactId>apicurio-registry</artifactId>
        <version>2.1.3.Final</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 and Yarn -->
                    <execution>
                        <id>install node and yarn</id>
                        <phase>initialize</phase>
                        <goals>
                            <goal>install-node-and-yarn</goal>
                        </goals>
                        <configuration>
                            <nodeVersion>v${node.version}</nodeVersion>
                            <yarnVersion>v${yarn.version}</yarnVersion>
                        </configuration>
                    </execution>
                    <!-- Install npm/yarn dependencies -->
                    <execution>
                        <id>yarn install</id>
                        <phase>compile</phase>
                        <goals>
                            <goal>yarn</goal>
                        </goals>
                        <configuration>
                            <arguments>install</arguments>
                            <npmRegistryURL>${npmRegistryURL2}</npmRegistryURL>
                        </configuration>
                    </execution>
                    <!-- Build the app -->
                    <execution>
                        <id>yarn build</id>
                        <phase>compile</phase>
                        <goals>
                            <goal>yarn</goal>
                        </goals>
                        <configuration>
                            <arguments>build</arguments>
                            <yarnInheritsProxyConfigFromMaven>false</yarnInheritsProxyConfigFromMaven>
                        </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>
    <profiles>
        <profile>
            <id>with-proxy</id>
            <activation>
                <property>
                    <name>proxy-server</name>
                </property>
            </activation>
            <properties>
                <yarn-install-args>--network-concurrency=30 --child-concurrency=1 --network-timeout=100000</yarn-install-args>
            </properties>
            <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>yarn</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>yarn</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>yarn</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>yarn set registry</id>
                                <phase>generate-sources</phase>
                                <goals>
                                    <goal>yarn</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>yarn set cafile</id>
                                <phase>generate-sources</phase>
                                <goals>
                                    <goal>yarn</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>yarn set no-strict ssl</id>
                                <phase>generate-sources</phase>
                                <goals>
                                    <goal>yarn</goal>
                                </goals>
                                <configuration>
                                    <arguments>config set strict-ssl false</arguments>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>verbose</id>
            <properties>
                <yarn-verbose>--verbose</yarn-verbose>
                <npm-verbose>--loglevel=silly</npm-verbose>
            </properties>
        </profile>
    </profiles>
</project>
