<?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>

    <artifactId>rdm-frontend</artifactId>

    <parent>
        <groupId>ru.i-novus.ms.rdm</groupId>
        <artifactId>rdm</artifactId>
        <version>3.2.0</version>
    </parent>

    <properties>
        <backend.default.path>http://localhost:8081/rdm/api</backend.default.path>
        <frontend.default.port>8080</frontend.default.port>
        <config.server.enable>false</config.server.enable>
        <maven.deploy.skip>true</maven.deploy.skip>
        <jacoco.skip>false</jacoco.skip>

        <rdm.l10n.support>false</rdm.l10n.support>
        <rdm.l10n.messages />
    </properties>

    <dependencies>

        <dependency>
            <groupId>ru.i-novus.ms.rdm</groupId>
            <artifactId>rdm-api</artifactId>
        </dependency>

        <dependency>
            <groupId>ru.i-novus.ms.rdm</groupId>
            <artifactId>rdm-n2o-api</artifactId>
        </dependency>

        <dependency>
            <groupId>ru.i-novus.ms.rdm</groupId>
            <artifactId>rdm-n2o</artifactId>
        </dependency>

        <dependency>
            <groupId>net.n2oapp.framework</groupId>
            <artifactId>n2o-spring-boot-starter</artifactId>
        </dependency>

        <dependency>
            <groupId>net.n2oapp.platform</groupId>
            <artifactId>n2o-platform-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>net.n2oapp.platform</groupId>
            <artifactId>n2o-platform-starter-jaxrs-client</artifactId>
        </dependency>

        <dependency>
            <groupId>net.n2oapp.platform</groupId>
            <artifactId>n2o-platform-starter-ms</artifactId>
        </dependency>

        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-core</artifactId>
        </dependency>

        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
        </dependency>

        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
        </dependency>

        <dependency>
            <groupId>net.n2oapp.framework.security</groupId>
            <artifactId>security-admin-rest-client</artifactId>
        </dependency>

        <dependency>
            <groupId>net.n2oapp.framework.security</groupId>
            <artifactId>security-auth</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.security.oauth.boot</groupId>
            <artifactId>spring-security-oauth2-autoconfigure</artifactId>
        </dependency>
        
        <dependency>
            <groupId>net.n2oapp.framework.security</groupId>
            <artifactId>security-auth-common</artifactId>
        </dependency>

        <dependency>
            <groupId>com.sun.xml.ws</groupId>
            <artifactId>rt</artifactId>
        </dependency>

        <dependency>
            <groupId>javax.activation</groupId>
            <artifactId>activation</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.retry</groupId>
            <artifactId>spring-retry</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-aop</artifactId>
        </dependency>

        <dependency>
            <groupId>net.n2oapp.platform</groupId>
            <artifactId>n2o-platform-i18n-autoconfigure</artifactId>
        </dependency>

        <dependency>
            <groupId>ru.i-novus.ms.audit</groupId>
            <artifactId>audit-client-spring-boot-starter</artifactId>
        </dependency>

    </dependencies>

    <build>
        <finalName>rdm</finalName>

        <resources>
            <resource>
                <directory>rdm-react/packages/rdm-frontend/build</directory>
                <targetPath>META-INF/resources</targetPath>
            </resource>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
            </resource>
        </resources>

        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-war-plugin</artifactId>
                    <version>3.2.1</version>
                    <configuration>
                        <failOnMissingWebXml>false</failOnMissingWebXml>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>

    <profiles>
        <profile>
            <id>frontend-build</id>
            <activation>
                <activeByDefault>false</activeByDefault>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>exec-maven-plugin</artifactId>
                        <version>1.3.2</version>

                        <configuration>
                            <workingDirectory>rdm-react</workingDirectory>
                        </configuration>

                        <executions>
                            <execution>
                                <id>yarn install (initialize)</id>
                                <goals>
                                    <goal>exec</goal>
                                </goals>
                                <phase>generate-resources</phase>

                                <configuration>
                                    <executable>yarn</executable>
                                    <arguments>
                                        <argument>install</argument>
                                        <argument>--registry=${npm.registry}</argument>
                                    </arguments>
                                </configuration>
                            </execution>

                            <execution>
                                <id>yarn run build</id>
                                <goals>
                                    <goal>exec</goal>
                                </goals>
                                <phase>generate-resources</phase>

                                <configuration>
                                    <executable>yarn</executable>
                                    <arguments>
                                        <argument>run</argument>
                                        <argument>build</argument>
                                    </arguments>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <profile>
            <id>production</id>
            <properties>
                <backend.default.path>http://backend:8080/rdm/api</backend.default.path>
                <frontend.default.port>8080</frontend.default.port>
                <config.server.enable>true</config.server.enable>
            </properties>
            <activation>
                <activeByDefault>false</activeByDefault>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.springframework.boot</groupId>
                        <artifactId>spring-boot-maven-plugin</artifactId>
                        <configuration>
                            <executable>true</executable>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <profile>
            <id>external-tracing-tool</id>
            <activation>
                <activeByDefault>false</activeByDefault>
            </activation>
            <dependencies>
                <dependency>
                    <groupId>org.springframework.cloud</groupId>
                    <artifactId>spring-cloud-sleuth-zipkin</artifactId>
                </dependency>
            </dependencies>
        </profile>

        <profile>
            <id>l10n</id>
            <activation>
                <activeByDefault>false</activeByDefault>
            </activation>

            <properties>
                <rdm.l10n.support>true</rdm.l10n.support>
                <rdm.l10n.messages>,messages.rdm_n2o_l10n</rdm.l10n.messages>
            </properties>

            <dependencies>
                <dependency>
                    <groupId>ru.i-novus.ms.rdm</groupId>
                    <artifactId>rdm-l10n-api</artifactId>
                </dependency>

                <dependency>
                    <groupId>ru.i-novus.ms.rdm</groupId>
                    <artifactId>rdm-n2o-l10n</artifactId>
                </dependency>
            </dependencies>
        </profile>
    </profiles>

</project>
