<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.molgenis</groupId>
        <artifactId>molgenis</artifactId>
        <version>6.1.0</version>
    </parent>
    <artifactId>molgenis-core-ui</artifactId>
    <packaging>jar</packaging>

    <name>core-ui</name>
    <description>Spaghetti module containing core plugins and legacy UI components.</description>

    <build>
        <plugins>
            <!-- Bundle the javascript specified in webpack.config.js to target/generated-resources/js/dist -->
            <plugin>
                <groupId>com.github.eirslett</groupId>
                <artifactId>frontend-maven-plugin</artifactId>
                <version>${frontend-maven-plugin.version}</version>
                <executions>
                    <execution>
                        <id>install node and npm</id>
                        <goals>
                            <goal>install-node-and-npm</goal>
                        </goals>
                        <configuration>
                            <skip>${skip.js}</skip>
                            <nodeVersion>v5.12.0</nodeVersion>
                            <npmVersion>3.8.6</npmVersion>
                        </configuration>
                    </execution>
                    <execution>
                        <id>npm prune</id>
                        <goals>
                            <goal>npm</goal>
                        </goals>
                        <configuration>
                            <skip>${skip.js}</skip>
                            <arguments>prune</arguments>
                        </configuration>
                    </execution>
                    <execution>
                        <id>npm install</id>
                        <goals>
                            <goal>npm</goal>
                        </goals>
                        <configuration>
                            <skip>${skip.js}</skip>
                        </configuration>
                    </execution>
                    <execution>
                        <id>update package.json version</id>
                        <goals>
                            <goal>gulp</goal>
                        </goals>
                        <configuration>
                            <skip>${skip.js}</skip>
                            <arguments>update-version</arguments>
                        </configuration>
                    </execution>
                    <execution>
                        <id>npm test</id>
                        <goals>
                            <goal>npm</goal>
                        </goals>
                        <phase>test</phase>
                        <configuration>
                            <skip>${skip.js}</skip>
                            <arguments>test</arguments>
                        </configuration>
                    </execution>
                    <execution>
                        <id>webpack build</id>
                        <goals>
                            <goal>npm</goal>
                        </goals>
                        <phase>generate-resources</phase>
                        <configuration>
                            <skip>${webpack.production}</skip>
                            <arguments>run-script build</arguments>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <!-- compile XML schemas -->
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>jaxb2-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>ui-xjc</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>xjc</goal>
                        </goals>
                        <configuration>
                            <!--<quiet>true</quiet>-->
                            <packageName>org.molgenis.core.ui</packageName>
                            <schemaDirectory>src/main/resources/schemas</schemaDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <!-- add sources created by jaxb -->
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>build-helper-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>execution-jaxb</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>add-source</goal>
                        </goals>
                        <configuration>
                            <sources>
                                <source>target/generated-sources/jaxb</source>
                            </sources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>com.github.kongchen</groupId>
                <artifactId>swagger-maven-plugin</artifactId>
                <configuration>
                    <apiSources>
                        <apiSource>
                            <info>
                                <title>${project.name}</title>
                                <version>${project.version}</version>
                                <description>${project.description}</description>
                            </info>
                            <springmvc>true</springmvc>
                            <locations>
                                <location>org.molgenis.core.ui.admin.user</location>
                                <location>org.molgenis.core.ui.admin.usermanager</location>
                            </locations>
                            <swaggerDirectory>${project.build.directory}/generated-resources/swagger</swaggerDirectory>
                            <swaggerFileName>${project.name}-swagger</swaggerFileName>
                        </apiSource>
                    </apiSources>
                </configuration>
                <executions>
                    <execution>
                        <phase>compile</phase>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>skip-js-compile</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-clean-plugin</artifactId>
                        <version>2.5</version>
                        <configuration>
                            <excludeDefaultDirectories>true</excludeDefaultDirectories>
                            <filesets>
                                <fileset>
                                    <directory>target</directory>
                                    <includes>
                                        <include>classes/*</include>
                                    </includes>
                                    <excludes>
                                        <exclude>classes/js</exclude>
                                        <exclude>classes/css</exclude>
                                        <exclude>classes/index.html</exclude>
                                    </excludes>
                                </fileset>
                            </filesets>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
            <properties>
                <webpack.production>true</webpack.production>
            </properties>
        </profile>

        <profile>
            <id>production</id>
            <properties>
                <!-- This disables the development build. -->
                <webpack.production>true</webpack.production>
            </properties>
            <build>
                <plugins>
                    <plugin>
                        <groupId>com.github.eirslett</groupId>
                        <artifactId>frontend-maven-plugin</artifactId>
                        <version>${frontend-maven-plugin.version}</version>
                        <executions>
                            <execution>
                                <id>webpack production build</id>
                                <goals>
                                    <goal>webpack</goal>
                                </goals>
                                <configuration>
                                    <outputdir>target/classes/js/dist</outputdir>
                                    <arguments>-p --config webpack.production.config.js</arguments>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

    <dependencies>
        <dependency>
            <groupId>org.molgenis</groupId>
            <artifactId>molgenis-core</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>org.molgenis</groupId>
            <artifactId>molgenis-data</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>org.molgenis</groupId>
            <artifactId>molgenis-data-platform</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>org.molgenis</groupId>
            <artifactId>molgenis-data-plugin</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>org.molgenis</groupId>
            <artifactId>molgenis-data-csv</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>org.molgenis</groupId>
            <artifactId>molgenis-data-index</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>org.molgenis</groupId>
            <artifactId>molgenis-data-i18n</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>org.molgenis</groupId>
            <artifactId>molgenis-data-import</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>org.molgenis</groupId>
            <artifactId>molgenis-data-validation</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>org.molgenis</groupId>
            <artifactId>molgenis-data-file</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>org.molgenis</groupId>
            <artifactId>molgenis-security</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>org.molgenis</groupId>
            <artifactId>molgenis-jobs</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>org.molgenis</groupId>
            <artifactId>molgenis-web</artifactId>
            <version>${project.version}</version>
        </dependency>
        <!-- third party dependencies -->
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>jcl-over-slf4j</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpclient</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>commons-logging</groupId>
                    <artifactId>commons-logging</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <!-- Remove exclusions when https://issues.apache.org/jira/browse/MNG-5600 has been resolved -->
            <exclusions>
                <exclusion>
                    <groupId>commons-logging</groupId>
                    <artifactId>commons-logging</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-web</artifactId>
            <!-- Remove exclusions when https://issues.apache.org/jira/browse/MNG-5600 has been resolved -->
            <exclusions>
                <exclusion>
                    <groupId>commons-logging</groupId>
                    <artifactId>commons-logging</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>com.google.auto.value</groupId>
            <artifactId>auto-value</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>no.api.freemarker</groupId>
            <artifactId>freemarker-java8</artifactId>
            <version>1.1.2</version>
        </dependency>
        <dependency>
            <groupId>cz.jirutka.rsql</groupId>
            <artifactId>rsql-parser</artifactId>
            <version>2.0.0</version>
        </dependency>
        <dependency>
            <groupId>org.webjars</groupId>
            <artifactId>webjars-locator</artifactId>
            <version>0.30</version>
            <exclusions>
                <exclusion>
                    <artifactId>jackson-databind</artifactId>
                    <groupId>com.fasterxml.jackson.core</groupId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.hamcrest</groupId>
            <artifactId>hamcrest-all</artifactId>
            <version>1.3</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>eu.bitwalker</groupId>
            <artifactId>UserAgentUtils</artifactId>
            <version>1.17</version>
        </dependency>
        <dependency>
            <groupId>org.eclipse.rdf4j</groupId>
            <artifactId>rdf4j-rio-turtle</artifactId>
            <version>${apache.rdf4j.version}</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-validator</artifactId>
        </dependency>
        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
        </dependency>
        <dependency>
            <groupId>io.swagger</groupId>
            <artifactId>swagger-annotations</artifactId>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <!-- test dependencies -->
        <dependency>
            <groupId>org.molgenis</groupId>
            <artifactId>molgenis-i18n</artifactId>
            <version>${project.version}</version>
            <type>test-jar</type>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>commons-fileupload</groupId>
            <artifactId>commons-fileupload</artifactId>
            <version>1.2</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.molgenis</groupId>
            <artifactId>molgenis-data</artifactId>
            <version>${project.version}</version>
            <type>test-jar</type>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.molgenis</groupId>
            <artifactId>molgenis-data-import</artifactId>
            <version>${project.version}</version>
            <type>test-jar</type>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.molgenis</groupId>
            <artifactId>molgenis-data-security</artifactId>
            <version>${project.version}</version>
            <type>test-jar</type>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.molgenis</groupId>
            <artifactId>molgenis-test</artifactId>
            <version>${project.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-test</artifactId>
            <!-- Remove exclusions when https://issues.apache.org/jira/browse/MNG-5600 has been resolved -->
            <exclusions>
                <exclusion>
                    <groupId>commons-logging</groupId>
                    <artifactId>commons-logging</artifactId>
                </exclusion>
            </exclusions>
            <scope>test</scope>
        </dependency>
    </dependencies>
</project>
