<?xml version="1.0" encoding="UTF-8"?>

<!--
 * Copyright (c) 2020, WSO2 Inc. (http://www.wso2.com). All Rights Reserved.
 *
 * This software is the property of WSO2 Inc. and its suppliers, if any.
 * Dissemination of any information or reproduction of any material contained
 * herein in any form is strictly forbidden, unless permitted by WSO2 expressly.
 * You may not alter or remove any copyright or other notice from copies of this content."
-->

<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.wso2</groupId>
        <artifactId>wso2</artifactId>
        <version>1.2</version>
    </parent>
    <groupId>org.wso2.identity.apps</groupId>
    <artifactId>identity-apps-cloud</artifactId>
    <packaging>pom</packaging>
    <version>0.0.1621</version>
    <name>WSO2 Identity Cloud Apps - Parent</name>
    <description>WSO2 Identity Cloud Web Apps</description>

    <url>http://wso2.org</url>

    <scm>
        <url>https://github.com/wso2-enterprise/iam-cloud-app-extensions.git</url>
        <developerConnection>scm:git:https://github.com/wso2-enterprise/iam-cloud-app-extensions.git</developerConnection>
        <connection>scm:git:https://github.com/wso2-enterprise/iam-cloud-app-extensions.git</connection>
        <tag>v0.0.1621</tag>
    </scm>

    <modules>
        <module>distributions/console</module>
        <module>distributions/myaccount</module>
    </modules>

    <build>
        <finalName>${project.artifactId}</finalName>

        <plugins>

            <!-- Initialize the repository by downloading dependency artifact -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <version>3.0.0</version>
                <artifactId>maven-antrun-plugin</artifactId>
                <inherited>false</inherited>
                <executions>
                    <!-- Initialize Identity Apps Dependency -->
                    <execution>
                        <id>build-pack</id>
                        <phase>initialize</phase>
                        <configuration>
                            <target>
                                <ant antfile="init-repo.xml">
                                    <target name="init-repo" />
                                </ant>
                            </target>
                        </configuration>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </execution>
                    <!-- Initialize Extensions -->
                    <execution>
                        <id>init-extensions</id>
                        <phase>generate-sources</phase>
                        <configuration>
                            <target>
                                <ant antfile="init-ext.xml">
                                    <target name="init-extensions" />
                                </ant>
                            </target>
                        </configuration>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </execution>
                    <!-- Initialize Extensions -->
                    <execution>
                        <id>init-artefacts</id>
                        <phase>prepare-package</phase>
                        <configuration>
                            <target>
                                <ant antfile="init-artefacts.xml">
                                    <target name="init-artefacts" />
                                </ant>
                            </target>
                        </configuration>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <!-- Initialize Identity Apps module which is downloaded in the `initialize` phase -->
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <version>1.6.0</version>
                <artifactId>exec-maven-plugin</artifactId>
                <inherited>false</inherited>
                <executions>
                    <execution>
                        <id>install dependencies (install)</id>
                        <phase>process-sources</phase>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                        <configuration>
                            <executable>pnpm</executable>
                            <arguments>
                                <argument>install</argument>
                            </arguments>
                            <skip>${bootstrap.exec.skip}</skip>
                            <workingDirectory>${basedir}/target/identity-apps</workingDirectory>
                        </configuration>
                    </execution>
                    <execution>
                        <id>maven clean install (layout controlling tag library)</id>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                        <phase>compile</phase>
                        <configuration>
                            <executable>mvn</executable>
                            <arguments>
                                <argument>clean</argument>
                                <argument>install</argument>
                            </arguments>
                            <workingDirectory>${basedir}/target/identity-apps/components/org.wso2.identity.apps.taglibs.layout.controller</workingDirectory>
                        </configuration>
                    </execution>
                    <execution>
                        <id>maven clean install (login-portal-layouts component)</id>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                        <phase>compile</phase>
                        <configuration>
                            <executable>mvn</executable>
                            <arguments>
                                <argument>clean</argument>
                                <argument>install</argument>
                            </arguments>
                            <workingDirectory>${basedir}/target/identity-apps/components/login-portal-layouts</workingDirectory>
                        </configuration>
                    </execution>
                    <execution>
                        <id>install console extensions dependencies (install)</id>
                        <phase>compile</phase>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                        <configuration>
                            <executable>node</executable>
                            <arguments>
                                <argument>scripts/pre-install.js</argument>
                            </arguments>
                            <skip>${bootstrap.exec.skip}</skip>
                            <workingDirectory>${basedir}/target/identity-apps/apps/console</workingDirectory>
                        </configuration>
                    </execution>
                    <execution>
                        <id>install myaccount extensions dependencies (install)</id>
                        <phase>compile</phase>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                        <configuration>
                            <executable>node</executable>
                            <arguments>
                                <argument>scripts/pre-install.js</argument>
                            </arguments>
                            <skip>${bootstrap.exec.skip}</skip>
                            <workingDirectory>${basedir}/target/identity-apps/apps/myaccount</workingDirectory>
                        </configuration>
                    </execution>
                    <execution>
                        <id>npm run lint:ci (static analysis)</id>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                        <phase>compile</phase>
                        <configuration>
                            <executable>pnpm</executable>
                            <arguments>
                                <argument>lint</argument>
                            </arguments>
                            <skip>${lint.exec.skip}</skip>
                            <workingDirectory>${basedir}/target/identity-apps</workingDirectory>
                        </configuration>
                    </execution>
                    <execution>
                        <id>npm run build (compile)</id>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                        <phase>compile</phase>
                        <configuration>
                            <executable>pnpm</executable>
                            <arguments>
                                <argument>build</argument>
                            </arguments>
                            <workingDirectory>${basedir}/target/identity-apps</workingDirectory>
                        </configuration>
                    </execution>
                    <execution>
                        <id>maven clean install (authentication-portal)</id>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                        <phase>compile</phase>
                        <configuration>
                            <executable>mvn</executable>
                            <arguments>
                                <argument>install</argument>
                            </arguments>
                            <workingDirectory>${basedir}/target/identity-apps/apps/authentication-portal</workingDirectory>
                        </configuration>
                    </execution>
                    <execution>
                        <id>maven clean install (recovery-portal)</id>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                        <phase>compile</phase>
                        <configuration>
                            <executable>mvn</executable>
                            <arguments>
                                <argument>install</argument>
                            </arguments>
                            <workingDirectory>${basedir}/target/identity-apps/apps/recovery-portal</workingDirectory>
                        </configuration>
                    </execution>
                    <execution>
                        <id>maven clean install (x509-certificate-authentication-portal)</id>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                        <phase>compile</phase>
                        <configuration>
                            <executable>mvn</executable>
                            <arguments>
                                <argument>install</argument>
                            </arguments>
                            <workingDirectory>${basedir}/target/identity-apps/apps/x509-certificate-authentication-portal</workingDirectory>
                        </configuration>
                    </execution>
                </executions>
                <configuration>
                    <environmentVariables>
                        <NPM_CONFIG_PREFIX>${basedir}/npm</NPM_CONFIG_PREFIX>
                        <NPM_CONFIG_CACHE>${NPM_CONFIG_PREFIX}/cache</NPM_CONFIG_CACHE>
                        <NPM_CONFIG_TMP>${project.build.directory}/npmtmp</NPM_CONFIG_TMP>
                    </environmentVariables>
                </configuration>
            </plugin>

            <!-- SpotBugs Static Analysis -->
            <plugin>
                <groupId>com.github.spotbugs</groupId>
                <artifactId>spotbugs-maven-plugin</artifactId>
                <version>4.0.4</version>
                <configuration>
                    <effort>Max</effort>
                    <threshold>medium</threshold>
                    <failOnError>true</failOnError>
                    <plugins>
                        <plugin>
                            <groupId>com.h3xstream.findsecbugs</groupId>
                            <artifactId>findsecbugs-plugin</artifactId>
                            <version>1.10.1</version>
                        </plugin>
                    </plugins>
                </configuration>
            </plugin>

        </plugins>
    </build>

    <properties>
        <identity.apps.version>1.4.122</identity.apps.version>
        <identity.apps.theme>asgardio</identity.apps.theme>

        <lint.exec.skip>true</lint.exec.skip>
        <bootstrap.exec.skip>false</bootstrap.exec.skip>
    </properties>
</project>
