<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>ru.entaxy.esb</groupId>
        <artifactId>root</artifactId>
        <version>1.10.1</version>
    </parent>
    <artifactId>ui</artifactId>
    <packaging>pom</packaging>
    <name>ENTAXY :: UI</name>
    <description>ENTAXY :: UI</description>
    <modules>
        <module>entaxy-hawtio</module>
        <module>h2-console</module>
    </modules>

    <profiles>
        <profile>
            <id>install-script-ui-license</id>
            <activation>
                <property>
                    <name>processLicense</name>
                    <value>true</value>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>license-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>update-file-header</id>
                                <goals>
                                    <goal>update-file-header</goal>
                                </goals>
                                <phase>process-sources</phase>
                                <configuration>
                                    <organizationName>${license.organizationName}</organizationName>
                                    <inceptionYear>${license.inceptionYear}</inceptionYear>
                                    <projectName>${license.projectName}</projectName>
                                    <copyrightOwners>${license.copyrightOwners}</copyrightOwners>
                                    <licenseName>${license.licenseName}</licenseName>

                                    <!-- plugin documentation recommends "true"
                                    but we use "false" to look like Apache sources -->
                                    <addJavaLicenseAfterPackage>false</addJavaLicenseAfterPackage>
                                    <emptyLineAfterHeader>false</emptyLineAfterHeader>

                                    <!-- excludes>
                                        <exclude>**/*.json</exclude>
                                    </excludes-->
                                    <extraExtensions>
                                        <!-- treat *.install files as *.properties -->
                                        <install>properties</install>
                                    </extraExtensions>

                                    <ignoreNoFileToScan>true</ignoreNoFileToScan>
                                    <keepBackup>true</keepBackup>

                                    <processStartTag>${license.processStartTag}</processStartTag>
                                    <processEndTag>${license.processEndTag}</processEndTag>
                                    <sectionDelimiter>${license.sectionDelimiter}</sectionDelimiter>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <profile>
            <id>generate-provided-repo</id>
            <activation>
                <activeByDefault>false</activeByDefault>
                <file>
                    <exists>generate-provided</exists>
                </file>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-dependency-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>download-provided-descriptor</id>
                                <phase>process-sources</phase>
                                <goals>
                                    <goal>copy</goal>
                                </goals>
                                <configuration>
                                    <failOnWarning>false</failOnWarning>
                                    <artifactItems>

                                        <!-- descriptor -->
                                        <artifactItem>
                                            <groupId>${platform.provided.groupId}</groupId>
                                            <artifactId>${platform.provided.data.artifactId}</artifactId>
                                            <version>${project.version}</version>
                                            <type>xml</type>
                                            <classifier>ui</classifier>
                                            <outputDirectory>${project.build.directory}/ui-support</outputDirectory>
                                            <destFileName>ui.xml</destFileName>
                                        </artifactItem>

                                    </artifactItems>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>

                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>xml-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>generate-ui-features-repo</id>
                                <phase>generate-resources</phase>
                                <goals>
                                    <goal>transform</goal>
                                </goals>
                                <configuration>
                                    <forceCreation>true</forceCreation>
                                    <transformationSets>
                                        <transformationSet>
                                            <dir>
                                                ${project.build.directory}/ui-support
                                            </dir>
                                            <includes>
                                                <include>ui.xml</include>
                                            </includes>
                                            <stylesheet>
                                                ${project.basedir}/support/xslt/generate-provided-repo.xslt
                                            </stylesheet>
                                            <outputDir>
                                                ${project.basedir}/generated-resources/provided
                                            </outputDir>
                                            <fileMappers>
                                                <fileMapper
                                                        implementation="org.codehaus.plexus.components.io.filemappers.FileExtensionMapper">
                                                    <targetExtension>.xml</targetExtension>
                                                </fileMapper>
                                            </fileMappers>
                                        </transformationSet>
                                    </transformationSets>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>

                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-resources-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>filter-generated-repo</id>
                                <phase>process-resources</phase>
                                <goals>
                                    <goal>copy-resources</goal>
                                </goals>
                                <configuration>
                                    <resources>
                                        <resource>
                                            <directory>generated-resources/provided</directory>
                                            <filtering>true</filtering>
                                        </resource>
                                    </resources>
                                    <outputDirectory>${project.build.directory}/ui-generated</outputDirectory>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>

                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>build-helper-maven-plugin</artifactId>
                        <version>${build-helper-maven-plugin.version}</version>
                        <executions>
                            <execution>
                                <id>attach-generated-repo</id>
                                <phase>package</phase>
                                <goals>
                                    <goal>attach-artifact</goal>
                                </goals>
                                <configuration>
                                    <artifacts>
                                        <artifact>
                                            <file>${project.build.directory}/ui-generated/ui.xml</file>
                                            <type>xml</type>
                                            <classifier>platform-provided</classifier>
                                        </artifact>
                                    </artifacts>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>


                </plugins>
            </build>
        </profile>


        <!--
            @DISABLED @TO_REMOVE
         -->
        <profile>
            <id>install-script-ui</id>
            <activation>
                <activeByDefault>false</activeByDefault>
                <file>
                    <exists>src/main/scripts/entaxy-ui.install_</exists>
                </file>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>license-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>update-file-header</id>
                                <goals>
                                    <goal>update-file-header</goal>
                                </goals>
                                <phase>process-sources</phase>
                                <configuration>
                                    <organizationName>${license.organizationName}</organizationName>
                                    <inceptionYear>${license.inceptionYear}</inceptionYear>
                                    <projectName>${license.projectName}</projectName>
                                    <copyrightOwners>${license.copyrightOwners}</copyrightOwners>
                                    <licenseName>${license.licenseName}</licenseName>

                                    <!-- plugin documentation recommends "true"
                                    but we use "false" to look like Apache sources -->
                                    <addJavaLicenseAfterPackage>false</addJavaLicenseAfterPackage>
                                    <emptyLineAfterHeader>false</emptyLineAfterHeader>

                                    <!-- excludes>
                                        <exclude>**/*.json</exclude>
                                    </excludes-->
                                    <extraExtensions>
                                        <!-- treat *.install files as *.properties -->
                                        <install>properties</install>
                                    </extraExtensions>

                                    <ignoreNoFileToScan>true</ignoreNoFileToScan>
                                    <keepBackup>true</keepBackup>

                                    <processStartTag>${license.processStartTag}</processStartTag>
                                    <processEndTag>${license.processEndTag}</processEndTag>
                                    <sectionDelimiter>${license.sectionDelimiter}</sectionDelimiter>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-resources-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>copy-resources</id>
                                <phase>validate</phase>
                                <goals>
                                    <goal>copy-resources</goal>
                                </goals>
                                <configuration>
                                    <outputDirectory>${basedir}/target/scripts</outputDirectory>
                                    <resources>
                                        <resource>
                                            <directory>src/main/scripts</directory>
                                            <filtering>true</filtering>
                                        </resource>
                                    </resources>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>build-helper-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>attach-script-ui</id>
                                <phase>verify</phase>
                                <goals>
                                    <goal>attach-artifact</goal>
                                </goals>
                                <configuration>
                                    <runOnlyAtExecutionRoot>false</runOnlyAtExecutionRoot>
                                    <artifacts>
                                        <artifact>
                                            <file>target/scripts/entaxy-ui.install</file>
                                            <type>install</type>
                                            <classifier>entaxy-ui</classifier>
                                        </artifact>
                                    </artifacts>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>

    </profiles>


</project>
