<?xml version="1.0"?>
<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>
  <artifactId>opencast-admin-ui-frontend</artifactId>
  <packaging>bundle</packaging>
  <name>Opencast :: admin-ui-frontend</name>
  <parent>
    <groupId>org.opencastproject</groupId>
    <artifactId>base</artifactId>
    <version>10.1</version>
    <relativePath>../../pom.xml</relativePath>
  </parent>
  <properties>
    <opencast.basedir>${project.basedir}/../..</opencast.basedir>
    <checkstyle.skip>false</checkstyle.skip>
    <skipTests>false</skipTests>
  </properties>
  <profiles>
    <profile>
      <id>frontend-no-prebuilt</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>exec-maven-plugin</artifactId>
            <executions>
              <execution>
                <id>npm ci</id>
                <goals>
                  <goal>exec</goal>
                </goals>
                <phase>initialize</phase>
                <configuration>
                  <executable>npm</executable>
                  <arguments>
                    <argument>ci</argument>
                  </arguments>
                </configuration>
              </execution>
              <execution>
                <id>bower install</id>
                <goals>
                  <goal>exec</goal>
                </goals>
                <phase>initialize</phase>
                <configuration>
                  <executable>node_modules/.bin/bower</executable>
                  <arguments>
                    <argument>--allow-root</argument>
                    <argument>install</argument>
                  </arguments>
                </configuration>
              </execution>
              <execution>
                <id>frontend build</id>
                <goals>
                  <goal>exec</goal>
                </goals>
                <phase>compile</phase>
                <configuration>
                  <executable>node_modules/grunt-cli/bin/grunt</executable>
                  <arguments>
                    <argument>build</argument>
                    <argument>--skipTests=${skipTests}</argument>
                  </arguments>
                </configuration>
              </execution>
              <execution>
                <id>esline</id>
                <goals>
                  <goal>exec</goal>
                </goals>
                <phase>test</phase>
                <configuration>
                  <executable>npm</executable>
                  <arguments>
                    <argument>run</argument>
                    <argument>eslint</argument>
                  </arguments>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
    <profile>
      <id>frontend</id>
      <activation>
        <activeByDefault>true</activeByDefault>
      </activation>
      <build>
        <plugins>
          <plugin>
            <groupId>com.github.eirslett</groupId>
            <artifactId>frontend-maven-plugin</artifactId>
            <executions>
              <execution>
                <id>install node and npm</id>
                <goals>
                  <goal>install-node-and-npm</goal>
                </goals>
                <configuration>
                  <nodeVersion>${node.version}</nodeVersion>
                </configuration>
              </execution>
              <execution>
                <id>npm ci</id>
                <goals>
                  <goal>npm</goal>
                </goals>
                <configuration>
                  <arguments>ci</arguments>
                </configuration>
              </execution>
              <execution>
                <id>bower install</id>
                <goals>
                  <goal>bower</goal>
                </goals>
                <configuration>
                  <arguments>--allow-root install</arguments>
                </configuration>
              </execution>
              <execution>
                <id>grunt build</id>
                <goals>
                  <goal>grunt</goal>
                </goals>
                <configuration>
                  <arguments>build --skipTests=${skipTests}</arguments>
                </configuration>
              </execution>
              <execution>
                <phase>test</phase>
                <id>eslint</id>
                <goals>
                  <goal>npm</goal>
                </goals>
                <configuration>
                  <arguments>run eslint</arguments>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>
  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-resources-plugin</artifactId>
        <executions>
          <execution>
            <id>copy-grunt</id>
            <phase>compile</phase>
            <goals>
              <goal>copy-resources</goal>
            </goals>
            <configuration>
              <outputDirectory>${basedir}/target/classes/webapp/</outputDirectory>
              <resources>
                <resource>
                  <directory>./target/grunt/webapp</directory>
                  <includes>
                    <include>**</include>
                  </includes>
                  <filtering>false</filtering>
                </resource>
              </resources>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
      </plugin>
      <plugin>
        <groupId>org.apache.felix</groupId>
        <artifactId>maven-bundle-plugin</artifactId>
        <extensions>true</extensions>
        <configuration>
          <instructions>
            <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
            <Build-Number>${buildNumber}</Build-Number>
            <Http-Alias>/admin-ng</Http-Alias>
            <Http-Classpath>/webapp</Http-Classpath>
            <Http-Welcome>index.html</Http-Welcome>
<!--            <Import-Package>
              net.fortuna.ical4j.*,
              org.opencastproject.index.service.message,
              org.opencastproject.adminui.index,
              javax.ws.rs;version=2.0.1,
              javax.ws.rs.core;version=2.0.1,
              *
            </Import-Package>-->
            <Private-Package>
              webapp.*
            </Private-Package>
          </instructions>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>
