<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>apicurito</artifactId>
        <version>1.2.2.fuse-7_10_1-00006-redhat-00001</version>
        <relativePath>../pom.xml</relativePath>
    </parent>
    <artifactId>apicurito-ui</artifactId>
    <packaging>jar</packaging>
    <name>apicurito-ui</name>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-assembly-plugin</artifactId>
                <executions>
                    <execution>
                        <id>dist</id>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                        <configuration>
                            <ignoreMissingDescriptor>false</ignoreMissingDescriptor>
                            <descriptors>
                                <descriptor>src/assembly/unix-dist.xml</descriptor>
                            </descriptors>
                            <tarLongFileMode>posix</tarLongFileMode>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <executions>
                    <execution>
                        <id>copy-static</id>
                        <phase>process-resources</phase>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${basedir}/dist</outputDirectory>
                            <resources>
                                <resource>
                                    <directory>${basedir}/static</directory>
                                    <filtering>true</filtering>
                                    <includes>
                                        <include>version.js</include>
                                    </includes>
                                </resource>
                                <resource>
                                    <directory>${basedir}/static</directory>
                                    <filtering>true</filtering>
                                    <excludes>
                                        <exclude>version.js</exclude>
                                    </excludes>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-clean-plugin</artifactId>
                <configuration>
                    <followSymLinks>false</followSymLinks>
                    <filesets>
                        <fileset>
                            <directory>node_modules</directory>
                            <includes>
                                <include>**/*</include>
                            </includes>
                        </fileset>
                        <fileset>
                            <directory>dist</directory>
                            <includes>
                                <include>**/*</include>
                            </includes>
                        </fileset>
                    </filesets>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>noproxy</id>
            <activation>
                <property>
                    <name>!productization</name>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>com.github.eirslett</groupId>
                        <artifactId>frontend-maven-plugin</artifactId>
                        <executions>
                            <!-- Install Node and Yarn -->
                            <execution>
                                <id>install node and yarn</id>
                                <goals>
                                    <goal>install-node-and-yarn</goal>
                                </goals>
                                <configuration>
                                    <nodeVersion>v8.11.3</nodeVersion>
                                    <yarnVersion>v1.9.4</yarnVersion>
                                </configuration>
                            </execution>
                            <!-- Install npm/yarn dependencies -->
                            <execution>
                                <id>yarn install</id>
                                <goals>
                                    <goal>yarn</goal>
                                </goals>
                                <configuration>
                                    <arguments>install</arguments>
                                </configuration>
                            </execution>
                            <!-- Build the app -->
                            <execution>
                                <id>ng build</id>
                                <goals>
                                    <goal>yarn</goal>
                                </goals>
                                <phase>generate-resources</phase>
                                <configuration>
                                    <arguments>build</arguments>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>productization</id>
            <activation>
                <property>
                    <name>productization</name>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>com.github.eirslett</groupId>
                        <artifactId>frontend-maven-plugin</artifactId>
                        <executions>
                            <!-- Install Node and Yarn -->
                            <execution>
                                <id>install node and yarn</id>
                                <goals>
                                    <goal>install-node-and-yarn</goal>
                                </goals>
                                <configuration>
                                    <nodeVersion>v8.11.3</nodeVersion>
                                    <yarnVersion>v1.9.4</yarnVersion>
                                </configuration>
                            </execution>
                            <execution>
                                <id>set https proxy</id>
                                <goals>
                                    <goal>yarn</goal>
                                </goals>
                                <configuration>
                                    <arguments>config set https-proxy http://${buildContentId}+tracking:${accessToken}@${proxyServer}:${proxyPort}</arguments>
                                </configuration>
                            </execution>
                            <execution>
                                <id>set http proxy</id>
                                <goals>
                                <goal>yarn</goal>
                                </goals>
                                <configuration>
                                    <arguments>config set proxy http://${buildContentId}+tracking:${accessToken}@${proxyServer}:${proxyPort}</arguments>
                                </configuration>
                            </execution>
                            <execution>
                                <id>set maxconn</id>
                                <goals>
                                    <goal>yarn</goal>
                                </goals>
                                <configuration>
                                    <arguments>config set maxsockets 2</arguments>
                                </configuration>
                            </execution>
                            <execution>
                                <id>yarn set registry</id>
                                <goals>
                                    <goal>yarn</goal>
                                </goals>
                                <configuration>
                                    <arguments>config set registry ${npmRegistryURL2}</arguments>
                                </configuration>
                            </execution>
                            <execution>
                                <id>yarn set no-strict ssl</id>
                                <goals>
                                    <goal>yarn</goal>
                                </goals>
                                <configuration>
                                    <arguments>config set strict-ssl false</arguments>
                                </configuration>
                            </execution>
                            <!-- Install npm/yarn dependencies -->
                            <execution>
                                <id>yarn install</id>
                                <goals>
                                    <goal>yarn</goal>
                                </goals>
                                <configuration>
                                    <arguments>install</arguments>
                                </configuration>
                            </execution>
                            <!-- Build the app -->
                            <execution>
                                <id>ng build</id>
                                <goals>
                                    <goal>yarn</goal>
                                </goals>
                                <phase>generate-resources</phase>
                                <configuration>
                                    <arguments>build</arguments>
                                    <yarnInheritsProxyConfigFromMaven>false</yarnInheritsProxyConfigFromMaven>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>image</id>
            <activation>
                <property>
                    <name>::image</name>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>exec-maven-plugin</artifactId>
                        <version>1.6.0</version>
                        <executions>
                            <execution>
                                <goals>
                                    <goal>exec</goal>
                                </goals>
                                <phase>package</phase>
                                <configuration>
                                    <workingDirectory>${project.basedir}/cmd</workingDirectory>
                                    <executable>${project.basedir}/cmd/build.sh</executable>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-assembly-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>package-binaries</id>
                                <phase>package</phase>
                                <goals>
                                    <goal>single</goal>
                                </goals>
                                <configuration>
                                    <!-- <descriptorSourceDirectory>${project.basedir}/assembly-descriptors</descriptorSourceDirectory> -->
                                    <descriptors>
                                        <descriptor>${project.basedir}/assembly-descriptors/linux-amd64.xml</descriptor>
                                    </descriptors>
                                    <tarLongFileMode>posix</tarLongFileMode>
                                    <finalName>${project.name}-${project.version}</finalName>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>io.fabric8</groupId>
                        <artifactId>fabric8-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>exec</id>
                                <phase>package</phase>
                                <goals>
                                    <goal>build</goal>
                                </goals>
                            </execution>
                        </executions>
                        <configuration>
                            <!-- Important here, otherwise fmp silently ignores the build config -->
                            <skipBuildPom>false</skipBuildPom>
                            <verbose>true</verbose>
                            <!-- Only when running in openshift: -->
                            <buildStrategy>docker</buildStrategy>
                            <images>
                                <image>
                                    <name>${image.ui}</name>
                                    <build>
                                        <assembly>
                                            <inline>
                                                <fileSet>
                                                    <directory>target/go/linux-amd64</directory>
                                                </fileSet>
                                            </inline>
                                        </assembly>
                                        <dockerFile>${basedir}/docker/Dockerfile</dockerFile>
                                        <tags combine.children="append">
                                            <tag>latest</tag>
                                        </tags>
                                    </build>
                                </image>
                            </images>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
